diff --git a/src/WKWebKit/Defs.cs b/src/WKWebKit/Defs.cs index 716827ca0932..169b248dacc8 100644 --- a/src/WKWebKit/Defs.cs +++ b/src/WKWebKit/Defs.cs @@ -56,6 +56,14 @@ public enum WKErrorCode : nint { JavaScriptExceptionOccurred, [iOS (9,0)][Mac (10,11, onlyOn64 : true)] JavaScriptResultTypeIsUnsupported, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreCompileFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreLookUpFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreRemoveFailed, + [iOS (11,0)][Mac (10,13, onlyOn64 : true)] + ContentRuleListStoreVersionMismatch } #if !MONOMAC || !XAMCORE_4_0 diff --git a/src/wkwebkit.cs b/src/wkwebkit.cs index 0bd498567bda..e70f89b38f49 100644 --- a/src/wkwebkit.cs +++ b/src/wkwebkit.cs @@ -61,6 +61,77 @@ interface WKBackForwardList { WKBackForwardListItem ItemAtIndex (nint index); } + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKContentRuleList + { + [Export ("identifier")] + string Identifier { get; } + } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKContentRuleListStore + { + [Static] + [Export ("defaultStore")] + WKContentRuleListStore DefaultStore { get; } + + [Static] + [Export ("storeWithURL:")] + WKContentRuleListStore FromUrl (NSUrl url); + + [Export ("compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:")] + [Async] + void CompileContentRuleList (string identifier, string encodedContentRuleList, Action completionHandler); + + [Export ("lookUpContentRuleListForIdentifier:completionHandler:")] + [Async] + void LookUpContentRuleList (string identifier, Action completionHandler); + + [Export ("removeContentRuleListForIdentifier:completionHandler:")] + [Async] + void RemoveContentRuleList (string identifier, Action completionHandler); + + [Export ("getAvailableContentRuleListIdentifiers:")] + [Async] + void GetAvailableContentRuleListIdentifiers (Action callback); + } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + [DisableDefaultCtor] + interface WKHttpCookieStore + { + [Export ("getAllCookies:")] + [Async] + void GetAllCookies (Action completionHandler); + + [Export ("setCookie:completionHandler:")] + [Async] + void SetCookie (NSHttpCookie cookie, [NullAllowed] Action completionHandler); + + [Export ("deleteCookie:completionHandler:")] + [Async] + void DeleteCookie (NSHttpCookie cookie, [NullAllowed] Action completionHandler); + + [Export ("addObserver:")] + void AddObserver (IWKHttpCookieStoreObserver observer); + + [Export ("removeObserver:")] + void RemoveObserver (IWKHttpCookieStoreObserver observer); + } + + interface IWKHttpCookieStoreObserver {} + + [Mac (10,13), iOS (11,0)] + [Protocol] + interface WKHttpCookieStoreObserver + { + [Export ("cookiesDidChangeInCookieStore:")] + void CookiesDidChangeInCookieStore (WKHttpCookieStore cookieStore); + } + [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit [BaseType (typeof (NSObject))] interface WKFrameInfo : NSCopying { @@ -227,6 +298,59 @@ interface WKSecurityOrigin { nint Port { get; } } + + [Mac (10,13), iOS (11,0)] + [BaseType (typeof(NSObject))] + interface WKSnapshotConfiguration { + [Export ("rect")] + CGRect Rect { get; set; } + + [Export ("snapshotWidth")] + NSNumber SnapshotWidth { get; set; } + } + +#if XAMCORE_2_0 + interface IWKUrlSchemeHandler {} + [Mac (10,13), iOS (11,0)] + [Protocol] + interface WKUrlSchemeHandler + { + [Abstract] + [Export ("webView:startURLSchemeTask:")] + void StartUrlSchemeTask (WKWebView webView, IWKUrlSchemeTask urlSchemeTask); + + [Abstract] + [Export ("webView:stopURLSchemeTask:")] + void StopUrlSchemeTask (WKWebView webView, IWKUrlSchemeTask urlSchemeTask); + } +#endif + interface IWKUrlSchemeTask {} + + [Mac (10,13), iOS (11,0)] + [Protocol] + interface WKUrlSchemeTask + { + [Abstract] + [Export ("request", ArgumentSemantic.Copy)] + NSUrlRequest Request { get; } + + [Abstract] + [Export ("didReceiveResponse:")] + void DidReceiveResponse (NSUrlResponse response); + + [Abstract] + [Export ("didReceiveData:")] + void DidReceiveData (NSData data); + + [Abstract] + [Export ("didFinish")] + void DidFinish (); + + [Abstract] + [Export ("didFailWithError:")] + void DidFailWithError (NSError error); + } + [iOS (9,0), Mac(10,11, onlyOn64 : true)] [BaseType (typeof(NSObject))] interface WKWebsiteDataRecord @@ -296,6 +420,10 @@ interface WKWebsiteDataStore : NSCoding { [Export ("removeDataOfTypes:modifiedSince:completionHandler:")] [Async] void RemoveDataOfTypes (NSSet websiteDataTypes, NSDate date, Action completionHandler); + + [Mac (10, 13), iOS (11, 0)] + [Export ("httpCookieStore")] + WKHttpCookieStore HttpCookieStore { get; } } [Mac (10,10, onlyOn64 : true), iOS (8,0)] @@ -355,6 +483,18 @@ interface WKUserContentController : NSCoding { [Export ("removeScriptMessageHandlerForName:")] void RemoveScriptMessageHandler (string name); + + [Mac (10,13), iOS (11,0)] + [Export ("addContentRuleList:")] + void AddContentRuleList (WKContentRuleList contentRuleList); + + [Mac (10,13), iOS (11,0)] + [Export ("removeContentRuleList:")] + void RemoveContentRuleList (WKContentRuleList contentRuleList); + + [Mac (10,13), iOS (11,0)] + [Export ("removeAllContentRuleLists")] + void RemoveAllContentRuleLists (); } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit @@ -519,6 +659,23 @@ interface WKWebView { [iOS (10,0)][Mac (10,12, onlyOn64 : true)] [NullAllowed, Export ("serverTrust")] SecTrust ServerTrust { get; } + +#if !MONOMAC + [iOS (11,0)] + [Async] + [Export ("takeSnapshotWithConfiguration:completionHandler:")] + void TakeSnapshot ([NullAllowed] WKSnapshotConfiguration snapshotConfiguration, Action completionHandler); +#else + [Mac (10,13)] + [Export ("takeSnapshotWithConfiguration:completionHandler:")] + [Async] + void TakeSnapshot ([NullAllowed] WKSnapshotConfiguration snapshotConfiguration, Action completionHandler); +#endif + [Mac (10,13), iOS (11,0)] + [Static] + [Export ("handlesURLScheme:")] + bool HandlesUrlScheme (string urlScheme); + } delegate void WKJavascriptEvaluationResult (NSObject result, NSError error); @@ -586,6 +743,17 @@ interface WKWebViewConfiguration : NSCopying, NSCoding { [NoMac] [Export ("ignoresViewportScaleLimits")] bool IgnoresViewportScaleLimits { get; set; } + +#if XAMCORE_2_0 + [Mac (10,13), iOS (11,0)] + [Export ("setURLSchemeHandler:forURLScheme:")] + void SetUrlSchemeHandler ([NullAllowed] IWKUrlSchemeHandler urlSchemeHandler, string urlScheme); + + [Mac (10,13), iOS (11,0)] + [Export ("urlSchemeHandlerForURLScheme:")] + [return: NullAllowed] + IWKUrlSchemeHandler GetUrlSchemeHandler (string urlScheme); +#endif } [iOS (8,0), Mac (10,10, onlyOn64 : true)] // Not defined in 32-bit