22// Use of this source code is governed by a BSD-style license that can be 
33// found in the LICENSE file. 
44
5+ /// Times at which to inject script content into a webpage. 
6+ /// 
7+ /// Wraps [WKUserScriptInjectionTime] (https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime?language=objc). 
8+ enum  WKUserScriptInjectionTime  {
9+   /// Inject the script after the creation of the webpage’s document element, but before loading any other content. 
10+   /// 
11+   /// See https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentstart?language=objc. 
12+    atDocumentStart,
13+ 
14+   /// Inject the script after the document finishes loading, but before loading any other subresources. 
15+   /// 
16+   /// See https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime/wkuserscriptinjectiontimeatdocumentend?language=objc. 
17+    atDocumentEnd,
18+ }
19+ 
520/// The media types that require a user gesture to begin playing. 
621/// 
722/// Wraps [WKAudiovisualMediaTypes] (https://developer.apple.com/documentation/webkit/wkaudiovisualmediatypes?language=objc). 
@@ -27,10 +42,149 @@ enum WKAudiovisualMediaType {
2742   all,
2843}
2944
45+ /// A script that the web view injects into a webpage. 
46+ /// 
47+ /// Wraps [WKUserScript] (https://developer.apple.com/documentation/webkit/wkuserscript?language=objc). 
48+ class  WKUserScript  {
49+   /// Constructs a [UserScript] . 
50+    WKUserScript (
51+     this .source,
52+     this .injectionTime, {
53+     required  this .isMainFrameOnly,
54+   });
55+ 
56+   /// The script’s source code. 
57+    final  String  source;
58+ 
59+   /// The time at which to inject the script into the webpage. 
60+    final  WKUserScriptInjectionTime  injectionTime;
61+ 
62+   /// Indicates whether to inject the script into the main frame or all frames. 
63+    final  bool  isMainFrameOnly;
64+ }
65+ 
66+ /// An object that encapsulates a message sent by JavaScript code from a webpage. 
67+ /// 
68+ /// Wraps [WKScriptMessage] (https://developer.apple.com/documentation/webkit/wkscriptmessage?language=objc). 
69+ class  WKScriptMessage  {
70+   /// Constructs a [WKScriptMessage] . 
71+    WKScriptMessage ({required  this .name, this .body});
72+ 
73+   /// The name of the message handler to which the message is sent. 
74+    final  String  name;
75+ 
76+   /// The body of the message. 
77+   /// 
78+   /// Allowed types are [num] , [String] , [List] , [Map] , and `null` . 
79+    final  Object ?  body;
80+ }
81+ 
82+ /// An interface for receiving messages from JavaScript code running in a webpage. 
83+ /// 
84+ /// Wraps [WKScriptMessageHandler] (https://developer.apple.com/documentation/webkit/wkscriptmessagehandler?language=objc) 
85+ class  WKScriptMessageHandler  {
86+   /// Tells the handler that a webpage sent a script message. 
87+   /// 
88+   /// Use this method to respond to a message sent from the webpage’s 
89+   /// JavaScript code. Use the [message]  parameter to get the message contents and 
90+   /// to determine the originating web view. 
91+    Future <void > setDidReceiveScriptMessage (
92+     void  Function (
93+       WKUserContentController  userContentController,
94+       WKScriptMessage  message,
95+     )
96+         didReceiveScriptMessage,
97+   ) {
98+     throw  UnimplementedError ();
99+   }
100+ }
101+ 
102+ /// Manages interactions between JavaScript code and your web view. 
103+ /// 
104+ /// Use this object to do the following: 
105+ /// 
106+ /// * Inject JavaScript code into webpages running in your web view. 
107+ /// * Install custom JavaScript functions that call through to your app’s native 
108+ ///   code. 
109+ /// 
110+ /// Wraps [WKUserContentController] (https://developer.apple.com/documentation/webkit/wkusercontentcontroller?language=objc). 
111+ class  WKUserContentController  {
112+   /// Constructs a [WKUserContentController] . 
113+    WKUserContentController ();
114+ 
115+   // A WKUserContentController that is owned by configuration. 
116+   WKUserContentController ._fromWebViewConfiguretion (
117+     // TODO(bparrishMines): Remove ignore once constructor is implemented. 
118+     // ignore: avoid_unused_constructor_parameters 
119+     WKWebViewConfiguration  configuration,
120+   );
121+ 
122+   /// Installs a message handler that you can call from your JavaScript code. 
123+   /// 
124+   /// This name of the parameter must be unique within the user content 
125+   /// controller and must not be an empty string. The user content controller 
126+   /// uses this parameter to define a JavaScript function for your message 
127+   /// handler in the page’s main content world. The name of this function is 
128+   /// `window.webkit.messageHandlers.<name>.postMessage(<messageBody>)` , where 
129+   /// `<name>`  corresponds to the value of this parameter. For example, if you 
130+   /// specify the string `MyFunction` , the user content controller defines the ` 
131+   /// `window.webkit.messageHandlers.MyFunction.postMessage()`  function in 
132+   /// JavaScript. 
133+    Future <void > addScriptMessageHandler (
134+     WKScriptMessageHandler  handler,
135+     String  name,
136+   ) {
137+     assert (name.isNotEmpty);
138+     throw  UnimplementedError ();
139+   }
140+ 
141+   /// Uninstalls the custom message handler with the specified name from your JavaScript code. 
142+   /// 
143+   /// If no message handler with this name exists in the user content 
144+   /// controller, this method does nothing. 
145+   /// 
146+   /// Use this method to remove a message handler that you previously installed 
147+   /// using the [addScriptMessageHandler]  method. This method removes the 
148+   /// message handler from the page content world. If you installed the message 
149+   /// handler in a different content world, this method doesn’t remove it. 
150+    Future <void > removeScriptMessageHandler (String  name) {
151+     throw  UnimplementedError ();
152+   }
153+ 
154+   /// Uninstalls all custom message handlers associated with the user content controller. 
155+    Future <void > removeAllScriptMessageHandlers () {
156+     throw  UnimplementedError ();
157+   }
158+ 
159+   /// Injects the specified script into the webpage’s content. 
160+    Future <void > addUserScript (WKUserScript  userScript) {
161+     throw  UnimplementedError ();
162+   }
163+ 
164+   /// Removes all user scripts from the web view. 
165+    Future <void > removeAllUserScripts () {
166+     throw  UnimplementedError ();
167+   }
168+ }
169+ 
30170/// A collection of properties that you use to initialize a web view. 
31171/// 
32172/// Wraps [WKWebViewConfiguration] (https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc) 
33173class  WKWebViewConfiguration  {
174+   /// Constructs a [WKWebViewConfiguration] . 
175+    WKWebViewConfiguration ({required  this .userContentController});
176+ 
177+   // A WKWebViewConfiguration that is owned by webView. 
178+   // TODO(bparrishMines): Remove ignore once constructor is implemented. 
179+   // ignore: avoid_unused_constructor_parameters 
180+   WKWebViewConfiguration ._fromWebView (WKWebView  webView) {
181+     userContentController = 
182+         WKUserContentController ._fromWebViewConfiguretion (this );
183+   }
184+ 
185+   /// Coordinates interactions between your app’s code and the webpage’s scripts and other content. 
186+    late  final  WKUserContentController  userContentController;
187+ 
34188  /// Indicates whether HTML5 videos play inline or use the native full-screen controller. 
35189   set  allowsInlineMediaPlayback (bool  allow) {
36190    throw  UnimplementedError ();
@@ -52,7 +206,7 @@ class WKWebViewConfiguration {
52206/// 
53207/// Wraps [WKWebView] (https://developer.apple.com/documentation/webkit/wkwebview?language=objc). 
54208class  WKWebView  {
55-   /// Construct  a [WKWebView] . 
209+   /// Constructs  a [WKWebView] . 
56210  /// 
57211  /// [configuration]  contains the configuration details for the web view. This 
58212  /// method saves a copy of your configuration object. Changes you make to your 
@@ -66,4 +220,16 @@ class WKWebView {
66220  WKWebView ([WKWebViewConfiguration ?  configuration]) {
67221    throw  UnimplementedError ();
68222  }
223+ 
224+   /// Contains the configuration details for the web view. 
225+   /// 
226+   /// Use the object in this property to obtain information about your web 
227+   /// view’s configuration. Because this property returns a copy of the 
228+   /// configuration object, changes you make to that object don’t affect the web 
229+   /// view’s configuration. 
230+   /// 
231+   /// If you didn’t create your web view with a [WKWebViewConfiguration]  this 
232+   /// property contains a default configuration object. 
233+    late  final  WKWebViewConfiguration  configuration = 
234+       WKWebViewConfiguration ._fromWebView (this );
69235}
0 commit comments