Merge pull request #1 from pichillilorenzo/master

upgrade origin
This commit is contained in:
1/2 2019-11-11 10:03:19 +08:00 committed by GitHub
commit fead4fb247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1329 additions and 728 deletions

View File

@ -18,13 +18,12 @@
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/assets/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/example/assets/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/inline_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/FlutterWebViewController.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/FlutterWebViewController.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebView.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Classes/InAppWebViewOptions.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppWebViewOptions.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/in_app_webview.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_webview.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/lib/src/in_app_webview.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_webview.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/webview_options.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/webview_options.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/lib/src/types.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/types.dart" afterDir="false" />
</list> </list>
<ignored path="$PROJECT_DIR$/.dart_tool/" /> <ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" /> <ignored path="$PROJECT_DIR$/.idea/" />
@ -47,8 +46,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart"> <entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="143"> <state relative-caret-position="127">
<caret line="336" column="42" selection-start-line="336" selection-start-column="42" selection-end-line="336" selection-end-column="42" /> <caret line="1105" column="38" selection-start-line="1105" selection-start-column="12" selection-end-line="1105" selection-end-column="38" />
<folding> <folding>
<element signature="e#0#17#0" expanded="true" /> <element signature="e#0#17#0" expanded="true" />
</folding> </folding>
@ -56,23 +55,11 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="520">
<caret line="511" column="30" selection-start-line="511" selection-start-column="7" selection-end-line="511" selection-end-column="30" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/types.dart"> <entry file="file://$PROJECT_DIR$/lib/src/types.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="332"> <state relative-caret-position="20">
<caret line="482" column="6" selection-start-line="482" selection-start-column="6" selection-end-line="482" selection-end-column="6" /> <caret line="939" column="17" selection-start-line="939" selection-start-column="6" selection-end-line="939" selection-end-column="17" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
@ -80,41 +67,11 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-250">
<caret line="347" column="93" selection-start-line="347" selection-start-column="93" selection-end-line="347" selection-end-column="93" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1005">
<caret line="67" column="37" selection-start-line="67" selection-start-column="37" selection-end-line="67" selection-end-column="37" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1905">
<caret line="127" column="25" selection-start-line="127" selection-start-column="10" selection-end-line="127" selection-end-column="25" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart"> <entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="207"> <state relative-caret-position="703">
<caret line="295" column="18" selection-start-line="295" selection-start-column="18" selection-end-line="295" selection-end-column="18" /> <caret line="195" column="46" lean-forward="true" selection-start-line="195" selection-start-column="46" selection-end-line="195" selection-end-column="46" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
@ -123,10 +80,28 @@
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="258">
<caret line="127" column="25" selection-start-line="127" selection-start-column="10" selection-end-line="127" selection-end-column="25" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="446">
<caret line="88" selection-start-line="88" selection-end-line="88" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/CHANGELOG.md"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="173"> <state relative-caret-position="322">
<caret line="16" column="681" selection-start-line="16" selection-start-column="661" selection-end-line="16" selection-end-column="681" /> <caret line="44" column="52" lean-forward="true" selection-start-line="44" selection-start-column="52" selection-end-line="44" selection-end-column="52" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -143,36 +118,36 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>injectScriptUrlFile</find> <find>ClientCertResponse</find>
<find>[InAppWebView] window</find> <find>weBVIEWCONTROL</find>
<find>javaScriptEnabled</find> <find>getFa</find>
<find>onLoadRes</find> <find>supportZoom</find>
<find>onLoadResource</find> <find>layou</find>
<find>onLoadResource&quot;</find> <find>HttpAuthCredential</find>
<find>javaScriptHandlersMap</find> <find>layoutA</find>
<find>javaScriptHandlers</find> <find>AndroidInAppWebViewForceDark</find>
<find>onAjaxSend</find> <find>AndroidInAppWebViewModeMenuItem</find>
<find>AndroidInAppWebViewMixedContentMode</find>
<find>IosInAppWebViewSelectionGranularity</find>
<find>preferredContent</find>
<find>IosWebViewOptionsPresentationStyle</find>
<find>AndroidInAppWebViewCacheMode</find>
<find>Action</find> <find>Action</find>
<find>AjaxRequestEventType</find> <find>IosSafariOptionsDismissButtonStyle</find>
<find>onAjax</find> <find>method</find>
<find>onAjaxReadyStateChange</find> <find>AjaxRequestEvent</find>
<find>onAjaxEvent</find> <find>withCredentials</find>
<find>current</find>
<find>FetchRequest</find>
<find>my-special-custom-scheme</find>
<find>should</find>
<find>resourceCustomSchemes</find>
<find>evaluateJavascript</find>
<find>WebHistory</find>
<find>shouldInterceptAjaxRequest</find> <find>shouldInterceptAjaxRequest</find>
<find>onAjaxProgress</find> <find>flutterInAppBrowserPlatformReady</find>
<find>onAjaxReady</find> <find>evaluateJ</find>
<find>NAVIGATION</find> <find>AjaxRequest</find>
<find>onNavigationStateChange</find>
<find>shouldInterceptFetchRequest</find>
<find>scheme</find>
<find>applicationNameForUserAgent</find>
<find>cacheMOde</find>
<find>inco</find>
<find>cacheEna</find>
<find>appCacheEnabled</find>
<find>appC</find>
<find>cache</find>
<find>customScheme</find>
<find>transparentBackground</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>activity.getPreferences(0)</replace> <replace>activity.getPreferences(0)</replace>
@ -225,8 +200,6 @@
<option value="$PROJECT_DIR$/lib/src/credentials_database.dart" /> <option value="$PROJECT_DIR$/lib/src/credentials_database.dart" />
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" /> <option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
<option value="$PROJECT_DIR$/lib/src/channel_manager.dart" /> <option value="$PROJECT_DIR$/lib/src/channel_manager.dart" />
<option value="$PROJECT_DIR$/lib/src/cookie_manager.dart" />
<option value="$PROJECT_DIR$/lib/src/http_auth_credentials_database.dart" />
<option value="$PROJECT_DIR$/android/build.gradle" /> <option value="$PROJECT_DIR$/android/build.gradle" />
<option value="$PROJECT_DIR$/lib/t_rex_runner/index.js" /> <option value="$PROJECT_DIR$/lib/t_rex_runner/index.js" />
<option value="$PROJECT_DIR$/lib/t_rex_runner/index.css" /> <option value="$PROJECT_DIR$/lib/t_rex_runner/index.css" />
@ -235,20 +208,22 @@
<option value="$PROJECT_DIR$/pubspec.yaml" /> <option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/t_rex_runner/t-rex.css" /> <option value="$PROJECT_DIR$/lib/t_rex_runner/t-rex.css" />
<option value="$PROJECT_DIR$/example/lib/test.dart" /> <option value="$PROJECT_DIR$/example/lib/test.dart" />
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
<option value="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart" />
<option value="$PROJECT_DIR$/example/pubspec.yaml" /> <option value="$PROJECT_DIR$/example/pubspec.yaml" />
<option value="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" /> <option value="$PROJECT_DIR$/ios/flutter_inappbrowser.podspec" />
<option value="$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js" /> <option value="$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js" />
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
<option value="$PROJECT_DIR$/lib/src/http_auth_credentials_database.dart" />
<option value="$PROJECT_DIR$/lib/src/cookie_manager.dart" />
<option value="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" /> <option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/types.dart" /> <option value="$PROJECT_DIR$/lib/src/types.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
<option value="$PROJECT_DIR$/example/assets/index.html" /> <option value="$PROJECT_DIR$/example/assets/index.html" />
<option value="$PROJECT_DIR$/CHANGELOG.md" /> <option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
</list> </list>
</option> </option>
</component> </component>
@ -263,55 +238,6 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope">
<subPane subId="Project Files">
<expand>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="flutter_inappbrowser" type="cbb8eebc:String" user="flutter_inappbrowser" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
<item name="t_rex_runner" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="nodejs_server_test_auth_basic_and_ssl" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="AndroidView"> <pane id="AndroidView">
<subPane> <subPane>
<expand> <expand>
@ -341,6 +267,61 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="example" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="example" type="462c0819:PsiDirectoryNode" />
<item name="assets" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
<item name="t_rex_runner" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="Scope">
<subPane subId="Project Files">
<expand>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="flutter_inappbrowser" type="cbb8eebc:String" user="flutter_inappbrowser" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -505,7 +486,7 @@
<window_info id="Resources Explorer" order="8" /> <window_info id="Resources Explorer" order="8" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32642487" /> <window_info anchor="bottom" id="Find" order="1" weight="0.32642487" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49574015" visible="true" weight="0.29326424" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.49574015" weight="0.48290154" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.34196892" /> <window_info anchor="bottom" id="Debug" order="3" weight="0.34196892" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@ -513,7 +494,7 @@
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" /> <window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.50692225" side_tool="true" weight="0.38445595" /> <window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.50692225" side_tool="true" weight="0.38445595" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32953367" /> <window_info anchor="bottom" id="Version Control" order="9" weight="0.32953367" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" weight="0.3896373" /> <window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" visible="true" weight="0.41658032" />
<window_info anchor="bottom" id="Messages" order="11" weight="0.3253886" /> <window_info anchor="bottom" id="Messages" order="11" weight="0.3253886" />
<window_info anchor="bottom" id="Dependency Viewer" order="12" weight="0.32800853" /> <window_info anchor="bottom" id="Dependency Viewer" order="12" weight="0.32800853" />
<window_info anchor="bottom" id="Logcat" order="13" weight="0.32953367" /> <window_info anchor="bottom" id="Logcat" order="13" weight="0.32953367" />
@ -543,7 +524,6 @@
</ignored-roots> </ignored-roots>
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/example/assets/client1-crt.pem" />
<entry file="file://$PROJECT_DIR$/example/assets/client1-crt.crt" /> <entry file="file://$PROJECT_DIR$/example/assets/client1-crt.crt" />
<entry file="file://$PROJECT_DIR$/pubspec.lock"> <entry file="file://$PROJECT_DIR$/pubspec.lock">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
@ -571,26 +551,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http_auth_credentials_database.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="40">
<caret line="21" column="9" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="9" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/cookie_manager.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="21" column="9" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="9" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/uri.dart"> <entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/uri.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15"> <state relative-caret-position="15">
@ -677,43 +637,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="465">
<caret line="131" column="14" selection-start-line="131" selection-start-column="14" selection-end-line="131" selection-end-column="14" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-206">
<caret line="128" column="36" selection-start-line="128" selection-start-column="18" selection-end-line="128" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600">
<caret line="45" column="53" lean-forward="true" selection-start-line="45" selection-start-column="53" selection-end-line="45" selection-end-column="53" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/chrome_safari_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="394">
<caret line="94" column="5" selection-start-line="94" selection-start-column="5" selection-end-line="94" selection-end-column="5" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/build/app/outputs/apk/debug/output.json"> <entry file="file://$PROJECT_DIR$/example/build/app/outputs/apk/debug/output.json">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
@ -744,41 +667,110 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/example/assets/index.html"> <entry file="file://$PROJECT_DIR$/lib/src/cookie_manager.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1005"> <state relative-caret-position="613">
<caret line="67" column="37" selection-start-line="67" selection-start-column="37" selection-end-line="67" selection-end-column="37" /> <caret line="128" selection-start-line="128" selection-end-line="128" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1905">
<caret line="127" column="25" selection-start-line="127" selection-start-column="10" selection-end-line="127" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="173">
<caret line="16" column="681" selection-start-line="16" selection-start-column="661" selection-end-line="16" selection-end-column="681" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="520">
<caret line="511" column="30" selection-start-line="511" selection-start-column="7" selection-end-line="511" selection-end-column="30" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/chrome_safari_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="24" column="32" selection-start-line="24" selection-start-column="32" selection-end-line="24" selection-end-column="32" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="528">
<caret line="118" column="43" lean-forward="true" selection-start-line="118" selection-start-column="43" selection-end-line="118" selection-end-column="43" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="240">
<caret line="501" column="27" selection-start-line="501" selection-start-column="27" selection-end-line="501" selection-end-column="27" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http_auth_credentials_database.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1136">
<caret line="87" column="84" selection-start-line="87" selection-start-column="84" selection-end-line="87" selection-end-column="84" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="28" selection-start-line="15" selection-start-column="17" selection-end-line="15" selection-end-column="28" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="570">
<caret line="38" column="43" selection-start-line="38" selection-start-column="43" selection-end-line="38" selection-end-column="43" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_localhost_server.dart">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-4314">
<caret line="363" column="36" selection-start-line="363" selection-start-column="36" selection-end-line="363" selection-end-column="36" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="258">
<caret line="127" column="25" selection-start-line="127" selection-start-column="10" selection-end-line="127" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="446">
<caret line="88" selection-start-line="88" selection-end-line="88" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart"> <entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="207"> <state relative-caret-position="703">
<caret line="295" column="18" selection-start-line="295" selection-start-column="18" selection-end-line="295" selection-end-column="18" /> <caret line="195" column="46" lean-forward="true" selection-start-line="195" selection-start-column="46" selection-end-line="195" selection-end-column="46" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
@ -787,8 +779,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart"> <entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="143"> <state relative-caret-position="127">
<caret line="336" column="42" selection-start-line="336" selection-start-column="42" selection-end-line="336" selection-end-column="42" /> <caret line="1105" column="38" selection-start-line="1105" selection-start-column="12" selection-end-line="1105" selection-end-column="38" />
<folding> <folding>
<element signature="e#0#17#0" expanded="true" /> <element signature="e#0#17#0" expanded="true" />
</folding> </folding>
@ -797,21 +789,18 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/types.dart"> <entry file="file://$PROJECT_DIR$/lib/src/types.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="332"> <state relative-caret-position="20">
<caret line="482" column="6" selection-start-line="482" selection-start-column="6" selection-end-line="482" selection-end-column="6" /> <caret line="939" column="17" selection-start-line="939" selection-start-column="6" selection-end-line="939" selection-end-column="17" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-250"> <state relative-caret-position="322">
<caret line="347" column="93" selection-start-line="347" selection-start-column="93" selection-end-line="347" selection-end-column="93" /> <caret line="44" column="52" lean-forward="true" selection-start-line="44" selection-start-column="52" selection-end-line="44" selection-end-column="52" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>

View File

@ -8,6 +8,8 @@
- Merge "Fix abstract method error && swift version error" [#155](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/155) (thanks to [AlexVincent525](https://github.com/AlexVincent525)) - Merge "Fix abstract method error && swift version error" [#155](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/155) (thanks to [AlexVincent525](https://github.com/AlexVincent525))
- Merge "migrating to swift 5.0" [#162](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/162) (thanks to [fattiger00](https://github.com/fattiger00)) - Merge "migrating to swift 5.0" [#162](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/162) (thanks to [fattiger00](https://github.com/fattiger00))
- Merge "Update readme example" [#178](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/178) (thanks to [SebastienBtr](https://github.com/SebastienBtr)) - Merge "Update readme example" [#178](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/178) (thanks to [SebastienBtr](https://github.com/SebastienBtr))
- Merge "handle choose file callback in android" [#183](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/183) (thanks to [crazecoder](https://github.com/crazecoder))
- Merge "add initialScale in android" [#186](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/186) (thanks to [crazecoder](https://github.com/crazecoder))
- Added `horizontalScrollBarEnabled` and `verticalScrollBarEnabled` options to enable/disable the corresponding scrollbar of the WebView [#165](https://github.com/pichillilorenzo/flutter_inappbrowser/issues/165) - Added `horizontalScrollBarEnabled` and `verticalScrollBarEnabled` options to enable/disable the corresponding scrollbar of the WebView [#165](https://github.com/pichillilorenzo/flutter_inappbrowser/issues/165)
- Added `onDownloadStart` event and `useOnDownloadStart` option: event fires when the WebView recognizes and starts a downloadable file. - Added `onDownloadStart` event and `useOnDownloadStart` option: event fires when the WebView recognizes and starts a downloadable file.
- Added `onLoadResourceCustomScheme` event and `resourceCustomSchemes` option to set custom schemes that WebView must handle to load resources - Added `onLoadResourceCustomScheme` event and `resourceCustomSchemes` option to set custom schemes that WebView must handle to load resources
@ -43,6 +45,7 @@
- Renamed `injectScriptCode` to `evaluateJavascript` - Renamed `injectScriptCode` to `evaluateJavascript`
- Renamed `injectStyleCode` to `injectCSSCode` - Renamed `injectStyleCode` to `injectCSSCode`
- Renamed `injectStyleFile` to `injectCSSFileFromUrl` - Renamed `injectStyleFile` to `injectCSSFileFromUrl`
- No need to listen to `window.addEventListener("flutterInAppBrowserPlatformReady", fuction(){ })` javascript event anymore to call `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)` to use the JavaScript message handlers
## 1.2.1 ## 1.2.1

View File

@ -155,7 +155,7 @@ public class ContentBlockerHandler {
break; break;
case MAKE_HTTPS: case MAKE_HTTPS:
if (url.startsWith("http://")) { if (scheme.equals("http") && (port == -1 || port == 80)) {
String urlHttps = url.replace("http://", "https://"); String urlHttps = url.replace("http://", "https://");
Request mRequest = new Request.Builder().url(urlHttps).build(); Request mRequest = new Request.Builder().url(urlHttps).build();

View File

@ -117,10 +117,10 @@ public class InAppBrowserActivity extends AppCompatActivity {
if (!options.toolbarTop) if (!options.toolbarTop)
actionBar.hide(); actionBar.hide();
if (!options.toolbarTopBackgroundColor.isEmpty()) if (options.toolbarTopBackgroundColor != null && !options.toolbarTopBackgroundColor.isEmpty())
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(options.toolbarTopBackgroundColor))); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(options.toolbarTopBackgroundColor)));
if (!options.toolbarTopFixedTitle.isEmpty()) if (options.toolbarTopFixedTitle != null && !options.toolbarTopFixedTitle.isEmpty())
actionBar.setTitle(options.toolbarTopFixedTitle); actionBar.setTitle(options.toolbarTopFixedTitle);
} }

View File

@ -85,8 +85,6 @@ final public class InAppWebView extends InputAwareWebView {
" }" + " }" +
"})(window.console);"; "})(window.console);";
static final String platformReadyJS = "window.dispatchEvent(new Event('flutterInAppBrowserPlatformReady'));";
static final String variableForOnLoadResourceJS = "window._flutter_inappbrowser_useOnLoadResource"; static final String variableForOnLoadResourceJS = "window._flutter_inappbrowser_useOnLoadResource";
static final String enableVariableForOnLoadResourceJS = variableForOnLoadResourceJS + " = $PLACEHOLDER_VALUE;"; static final String enableVariableForOnLoadResourceJS = variableForOnLoadResourceJS + " = $PLACEHOLDER_VALUE;";
@ -116,6 +114,29 @@ final public class InAppWebView extends InputAwareWebView {
" ajax.prototype._flutter_inappbrowser_password = null;" + " ajax.prototype._flutter_inappbrowser_password = null;" +
" ajax.prototype._flutter_inappbrowser_already_onreadystatechange_wrapped = false;" + " ajax.prototype._flutter_inappbrowser_already_onreadystatechange_wrapped = false;" +
" ajax.prototype._flutter_inappbrowser_request_headers = {};" + " ajax.prototype._flutter_inappbrowser_request_headers = {};" +
" function convertRequestResponse(request, callback) {" +
" if (request.response != null && request.responseType != null) {" +
" switch (request.responseType) {" +
" case 'arraybuffer':" +
" callback(new Uint8Array(request.response));" +
" return;" +
" case 'blob':" +
" const reader = new FileReader();" +
" reader.addEventListener('loadend', function() { " +
" callback(new Uint8Array(reader.result));" +
" });" +
" reader.readAsArrayBuffer(blob);" +
" return;" +
" case 'document':" +
" callback(request.response.documentElement.outerHTML);" +
" return;" +
" case 'json':" +
" callback(request.response);" +
" return;" +
" };" +
" }" +
" callback(null);" +
" };" +
" ajax.prototype.open = function(method, url, isAsync, user, password) {" + " ajax.prototype.open = function(method, url, isAsync, user, password) {" +
" isAsync = (isAsync != null) ? isAsync : true;" + " isAsync = (isAsync != null) ? isAsync : true;" +
" this._flutter_inappbrowser_url = url;" + " this._flutter_inappbrowser_url = url;" +
@ -143,35 +164,40 @@ final public class InAppWebView extends InputAwareWebView {
" responseHeaders[header] = value;" + " responseHeaders[header] = value;" +
" });" + " });" +
" }" + " }" +
" var ajaxRequest = {" + " convertRequestResponse(this, function(response) {" +
" method: this._flutter_inappbrowser_method," + " var ajaxRequest = {" +
" url: this._flutter_inappbrowser_url," + " method: self._flutter_inappbrowser_method," +
" isAsync: this._flutter_inappbrowser_isAsync," + " url: self._flutter_inappbrowser_url," +
" user: this._flutter_inappbrowser_user," + " isAsync: self._flutter_inappbrowser_isAsync," +
" password: this._flutter_inappbrowser_password," + " user: self._flutter_inappbrowser_user," +
" withCredentials: this.withCredentials," + " password: self._flutter_inappbrowser_password," +
" headers: this._flutter_inappbrowser_request_headers," + " withCredentials: self.withCredentials," +
" readyState: this.readyState," + " headers: self._flutter_inappbrowser_request_headers," +
" status: this.status," + " readyState: self.readyState," +
" responseURL: this.responseURL," + " status: self.status," +
" responseType: this.responseType," + " responseURL: self.responseURL," +
" responseText: this.responseText," + " responseType: self.responseType," +
" statusText: this.statusText," + " response: response," +
" responseHeaders, responseHeaders," + " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," +
" event: {" + " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," +
" type: e.type," + " statusText: self.statusText," +
" loaded: e.loaded," + " responseHeaders, responseHeaders," +
" lengthComputable: e.lengthComputable" + " event: {" +
" }" + " type: e.type," +
" };" + " loaded: e.loaded," +
" window." + JavaScriptBridgeInterface.name + ".callHandler('onAjaxProgress', ajaxRequest).then(function(result) {" + " lengthComputable: e.lengthComputable," +
" if (result != null) {" + " total: e.total" +
" switch (result) {" + " }" +
" case 0:" + " };" +
" self.abort();" + " window." + JavaScriptBridgeInterface.name + ".callHandler('onAjaxProgress', ajaxRequest).then(function(result) {" +
" return;" + " if (result != null) {" +
" };" + " switch (result) {" +
" }" + " case 0:" +
" self.abort();" +
" return;" +
" };" +
" }" +
" });" +
" });" + " });" +
" }" + " }" +
" };" + " };" +
@ -194,33 +220,37 @@ final public class InAppWebView extends InputAwareWebView {
" responseHeaders[header] = value;" + " responseHeaders[header] = value;" +
" });" + " });" +
" }" + " }" +
" var ajaxRequest = {" + " convertRequestResponse(this, function(response) {" +
" method: this._flutter_inappbrowser_method," + " var ajaxRequest = {" +
" url: this._flutter_inappbrowser_url," + " method: self._flutter_inappbrowser_method," +
" isAsync: this._flutter_inappbrowser_isAsync," + " url: self._flutter_inappbrowser_url," +
" user: this._flutter_inappbrowser_user," + " isAsync: self._flutter_inappbrowser_isAsync," +
" password: this._flutter_inappbrowser_password," + " user: self._flutter_inappbrowser_user," +
" withCredentials: this.withCredentials," + " password: self._flutter_inappbrowser_password," +
" headers: this._flutter_inappbrowser_request_headers," + " withCredentials: self.withCredentials," +
" readyState: this.readyState," + " headers: self._flutter_inappbrowser_request_headers," +
" status: this.status," + " readyState: self.readyState," +
" responseURL: this.responseURL," + " status: self.status," +
" responseType: this.responseType," + " responseURL: self.responseURL," +
" responseText: this.responseText," + " responseType: self.responseType," +
" statusText: this.statusText," + " response: response," +
" responseHeaders: responseHeaders" + " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," +
" };" + " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," +
" window." + JavaScriptBridgeInterface.name + ".callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) {" + " statusText: self.statusText," +
" if (result != null) {" + " responseHeaders: responseHeaders" +
" switch (result) {" + " };" +
" case 0:" + " window." + JavaScriptBridgeInterface.name + ".callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) {" +
" self.abort();" + " if (result != null) {" +
" return;" + " switch (result) {" +
" };" + " case 0:" +
" }" + " self.abort();" +
" if (onreadystatechange != null) {" + " return;" +
" onreadystatechange();" + " };" +
" }" + " }" +
" if (onreadystatechange != null) {" +
" onreadystatechange();" +
" }" +
" });" +
" });" + " });" +
" } else if (onreadystatechange != null) {" + " } else if (onreadystatechange != null) {" +
" onreadystatechange();" + " onreadystatechange();" +
@ -233,6 +263,7 @@ final public class InAppWebView extends InputAwareWebView {
" this.addEventListener('progress', handleEvent);" + " this.addEventListener('progress', handleEvent);" +
" this.addEventListener('error', handleEvent);" + " this.addEventListener('error', handleEvent);" +
" this.addEventListener('abort', handleEvent);" + " this.addEventListener('abort', handleEvent);" +
" this.addEventListener('timeout', handleEvent);" +
" var ajaxRequest = {" + " var ajaxRequest = {" +
" data: data," + " data: data," +
" method: this._flutter_inappbrowser_method," + " method: this._flutter_inappbrowser_method," +
@ -241,7 +272,8 @@ final public class InAppWebView extends InputAwareWebView {
" user: this._flutter_inappbrowser_user," + " user: this._flutter_inappbrowser_user," +
" password: this._flutter_inappbrowser_password," + " password: this._flutter_inappbrowser_password," +
" withCredentials: this.withCredentials," + " withCredentials: this.withCredentials," +
" headers: this._flutter_inappbrowser_request_headers" + " headers: this._flutter_inappbrowser_request_headers," +
" responseType: this.responseType" +
" };" + " };" +
" window." + JavaScriptBridgeInterface.name + ".callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) {" + " window." + JavaScriptBridgeInterface.name + ".callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) {" +
" if (result != null) {" + " if (result != null) {" +
@ -252,6 +284,9 @@ final public class InAppWebView extends InputAwareWebView {
" };" + " };" +
" data = result.data;" + " data = result.data;" +
" self.withCredentials = result.withCredentials;" + " self.withCredentials = result.withCredentials;" +
" if (result.responseType != null) {" +
" self.responseType = result.responseType;" +
" };" +
" for (var header in result.headers) {" + " for (var header in result.headers) {" +
" var value = result.headers[header];" + " var value = result.headers[header];" +
" self.setRequestHeader(header, value);" + " self.setRequestHeader(header, value);" +
@ -405,7 +440,7 @@ final public class InAppWebView extends InputAwareWebView {
" controller.abort();" + " controller.abort();" +
" break;" + " break;" +
" }" + " }" +
" var resultResource = (result.resource != null) ? result.resource : resource;" + " var resultResource = (result.url != null) ? result.url : resource;" +
" var resultInit = init;" + " var resultInit = init;" +
" if (result.init != null) {" + " if (result.init != null) {" +
" resultInit.method = result.method;" + " resultInit.method = result.method;" +
@ -555,14 +590,17 @@ final public class InAppWebView extends InputAwareWebView {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && options.forceDark != null) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && options.forceDark != null)
settings.setForceDark(options.forceDark); settings.setForceDark(options.forceDark);
settings.setGeolocationEnabled(options.geolocationEnabled); settings.setGeolocationEnabled(options.geolocationEnabled);
if (options.layoutAlgorithm != null) if (options.layoutAlgorithm != null) {
settings.setLayoutAlgorithm(options.layoutAlgorithm); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && options.layoutAlgorithm.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
settings.setLayoutAlgorithm(options.layoutAlgorithm);
} else {
settings.setLayoutAlgorithm(options.layoutAlgorithm);
}
}
settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically); settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically);
settings.setMinimumFontSize(options.minimumFontSize); settings.setMinimumFontSize(options.minimumFontSize);
settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize); settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize);
if(options.initialScale != null) setInitialScale(options.initialScale);
setInitialScale(options.initialScale);
settings.setNeedInitialFocus(options.needInitialFocus); settings.setNeedInitialFocus(options.needInitialFocus);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
settings.setOffscreenPreRaster(options.offscreenPreRaster); settings.setOffscreenPreRaster(options.offscreenPreRaster);
@ -575,9 +613,8 @@ final public class InAppWebView extends InputAwareWebView {
setDesktopMode(true); setDesktopMode(true);
break; break;
case MOBILE: case MOBILE:
setDesktopMode(false);
break;
case RECOMMENDED: case RECOMMENDED:
setDesktopMode(false);
break; break;
} }
} }
@ -951,8 +988,13 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("geolocationEnabled") != null && options.geolocationEnabled != newOptions.geolocationEnabled) if (newOptionsMap.get("geolocationEnabled") != null && options.geolocationEnabled != newOptions.geolocationEnabled)
settings.setGeolocationEnabled(newOptions.geolocationEnabled); settings.setGeolocationEnabled(newOptions.geolocationEnabled);
if (newOptionsMap.get("layoutAlgorithm") != null && options.layoutAlgorithm != newOptions.layoutAlgorithm) if (newOptionsMap.get("layoutAlgorithm") != null && options.layoutAlgorithm != newOptions.layoutAlgorithm) {
settings.setLayoutAlgorithm(newOptions.layoutAlgorithm); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && newOptions.layoutAlgorithm.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
settings.setLayoutAlgorithm(newOptions.layoutAlgorithm);
} else {
settings.setLayoutAlgorithm(newOptions.layoutAlgorithm);
}
}
if (newOptionsMap.get("loadWithOverviewMode") != null && options.loadWithOverviewMode != newOptions.loadWithOverviewMode) if (newOptionsMap.get("loadWithOverviewMode") != null && options.loadWithOverviewMode != newOptions.loadWithOverviewMode)
settings.setLoadWithOverviewMode(newOptions.loadWithOverviewMode); settings.setLoadWithOverviewMode(newOptions.loadWithOverviewMode);
@ -985,6 +1027,18 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("standardFontFamily") != null && !options.standardFontFamily.equals(newOptions.standardFontFamily)) if (newOptionsMap.get("standardFontFamily") != null && !options.standardFontFamily.equals(newOptions.standardFontFamily))
settings.setStandardFontFamily(newOptions.standardFontFamily); settings.setStandardFontFamily(newOptions.standardFontFamily);
if (newOptionsMap.get("preferredContentMode") != null && !options.preferredContentMode.equals(newOptions.preferredContentMode)) {
switch (fromValue(newOptions.preferredContentMode)) {
case DESKTOP:
setDesktopMode(true);
break;
case MOBILE:
case RECOMMENDED:
setDesktopMode(false);
break;
}
}
if (newOptionsMap.get("saveFormData") != null && options.saveFormData != newOptions.saveFormData) if (newOptionsMap.get("saveFormData") != null && options.saveFormData != newOptions.saveFormData)
settings.setSaveFormData(newOptions.saveFormData); settings.setSaveFormData(newOptions.saveFormData);

View File

@ -32,6 +32,8 @@ import com.pichillilorenzo.flutter_inappbrowser.Util;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateEncodingException;
@ -182,12 +184,6 @@ public class InAppWebViewClient extends WebViewClient {
view.clearFocus(); view.clearFocus();
view.requestFocus(); view.requestFocus();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.evaluateJavascript(InAppWebView.platformReadyJS, (ValueCallback<String>) null);
} else {
webView.loadUrl("javascript:" + InAppWebView.platformReadyJS.replaceAll("[\r\n]+", ""));
}
Map<String, Object> obj = new HashMap<>(); Map<String, Object> obj = new HashMap<>();
if (inAppBrowserActivity != null) if (inAppBrowserActivity != null)
obj.put("uuid", inAppBrowserActivity.uuid); obj.put("uuid", inAppBrowserActivity.uuid);
@ -563,14 +559,21 @@ public class InAppWebViewClient extends WebViewClient {
}); });
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { public WebResourceResponse shouldInterceptRequest(WebView view, final String url) {
final InAppWebView webView = (InAppWebView) view; final InAppWebView webView = (InAppWebView) view;
final String url = request.getUrl().toString(); URI uri;
String scheme = request.getUrl().getScheme(); try {
uri = new URI(url);
} catch (URISyntaxException e) {
e.printStackTrace();
Log.e(LOG_TAG, e.getMessage());
return null;
}
String scheme = uri.getScheme();
if (webView.options.resourceCustomSchemes != null && webView.options.resourceCustomSchemes.contains(scheme)) { if (webView.options.resourceCustomSchemes != null && webView.options.resourceCustomSchemes.contains(scheme)) {
final Map<String, Object> obj = new HashMap<>(); final Map<String, Object> obj = new HashMap<>();
@ -619,6 +622,13 @@ public class InAppWebViewClient extends WebViewClient {
return response; return response;
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
String url = request.getUrl().toString();
return shouldInterceptRequest(view, url);
}
private MethodChannel getChannel() { private MethodChannel getChannel() {
return (inAppBrowserActivity != null) ? InAppBrowserFlutterPlugin.inAppBrowser.channel : flutterWebView.channel; return (inAppBrowserActivity != null) ? InAppBrowserFlutterPlugin.inAppBrowser.channel : flutterWebView.channel;
} }

View File

@ -1,13 +1,18 @@
package com.pichillilorenzo.flutter_inappbrowser.InAppWebView; package com.pichillilorenzo.flutter_inappbrowser.InAppWebView;
import android.os.Build;
import android.util.Log;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import com.pichillilorenzo.flutter_inappbrowser.Options; import com.pichillilorenzo.flutter_inappbrowser.Options;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static android.webkit.WebSettings.LayoutAlgorithm.NORMAL;
public class InAppWebViewOptions extends Options { public class InAppWebViewOptions extends Options {
public static final String LOG_TAG = "InAppWebViewOptions"; public static final String LOG_TAG = "InAppWebViewOptions";
@ -23,7 +28,6 @@ public class InAppWebViewOptions extends Options {
public Boolean debuggingEnabled = false; public Boolean debuggingEnabled = false;
public Boolean javaScriptCanOpenWindowsAutomatically = false; public Boolean javaScriptCanOpenWindowsAutomatically = false;
public Boolean mediaPlaybackRequiresUserGesture = true; public Boolean mediaPlaybackRequiresUserGesture = true;
public Integer textZoom = 100;
public Integer minimumFontSize = 8; public Integer minimumFontSize = 8;
public Boolean verticalScrollBarEnabled = true; public Boolean verticalScrollBarEnabled = true;
public Boolean horizontalScrollBarEnabled = true; public Boolean horizontalScrollBarEnabled = true;
@ -36,6 +40,7 @@ public class InAppWebViewOptions extends Options {
public Boolean cacheEnabled = true; public Boolean cacheEnabled = true;
public Boolean transparentBackground = false; public Boolean transparentBackground = false;
public Integer textZoom = 100;
public Boolean clearSessionCache = false; public Boolean clearSessionCache = false;
public Boolean builtInZoomControls = false; public Boolean builtInZoomControls = false;
public Boolean displayZoomControls = false; public Boolean displayZoomControls = false;
@ -66,7 +71,7 @@ public class InAppWebViewOptions extends Options {
public Boolean loadWithOverviewMode = true; public Boolean loadWithOverviewMode = true;
public Boolean loadsImagesAutomatically = true; public Boolean loadsImagesAutomatically = true;
public Integer minimumLogicalFontSize = 8; public Integer minimumLogicalFontSize = 8;
public Integer initialScale; public Integer initialScale = 0;
public Boolean needInitialFocus = true; public Boolean needInitialFocus = true;
public Boolean offscreenPreRaster = false; public Boolean offscreenPreRaster = false;
public String sansSerifFontFamily = "sans-serif"; public String sansSerifFontFamily = "sans-serif";
@ -75,4 +80,49 @@ public class InAppWebViewOptions extends Options {
public Boolean saveFormData = true; public Boolean saveFormData = true;
public Boolean thirdPartyCookiesEnabled = true; public Boolean thirdPartyCookiesEnabled = true;
public Boolean hardwareAcceleration = true; public Boolean hardwareAcceleration = true;
@Override
public Object onParse(Map.Entry<String, Object> pair) {
if (pair.getKey().equals("layoutAlgorithm")) {
String value = (String) pair.getValue();
if (value != null) {
switch (value) {
case "NORMAL":
pair.setValue(NORMAL);
return pair;
case "TEXT_AUTOSIZING":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return pair.setValue(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} else {
pair.setValue(NORMAL);
}
return pair;
}
}
}
return super.onParse(pair);
}
@Override
public Object onGetHashMap(Field field) {
if (field.getName().equals("layoutAlgorithm")) {
try {
WebSettings.LayoutAlgorithm value = (WebSettings.LayoutAlgorithm) field.get(this);
if (value != null) {
switch (value) {
case NORMAL:
return "NORMAL";
default:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
return "TEXT_AUTOSIZING";
}
return "NORMAL";
}
}
} catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage());
}
}
return super.onGetHashMap(field);
}
} }

View File

@ -15,8 +15,9 @@ public class Options {
Iterator it = options.entrySet().iterator(); Iterator it = options.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next(); Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next();
Object value = this.onParse(pair);
try { try {
this.getClass().getDeclaredField(pair.getKey()).set(this, pair.getValue()); this.getClass().getDeclaredField(pair.getKey()).set(this, value);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
Log.d(LOG_TAG, e.getMessage()); Log.d(LOG_TAG, e.getMessage());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
@ -26,16 +27,25 @@ public class Options {
return this; return this;
} }
public Object onParse(Map.Entry<String, Object> pair) {
return pair.getValue();
}
public HashMap<String, Object> getHashMap() { public HashMap<String, Object> getHashMap() {
HashMap<String, Object> options = new HashMap<>(); HashMap<String, Object> options = new HashMap<>();
for (Field f : this.getClass().getDeclaredFields()) { for (Field field : this.getClass().getDeclaredFields()) {
try { options.put(field.getName(), onGetHashMap(field));
options.put(f.getName(), f.get(this));
} catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage());
}
} }
return options; return options;
} }
public Object onGetHashMap(Field field) {
try {
return field.get(this);
} catch (IllegalAccessException e) {
Log.d(LOG_TAG, e.getMessage());
}
return null;
}
} }

View File

@ -77,26 +77,23 @@
window.location = "#foo-" + randomNumber; window.location = "#foo-" + randomNumber;
} }
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) { window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
console.log("ready"); console.log(result, typeof result);
console.log(JSON.stringify(result), result.bar);
window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
//console.log(result, typeof result);
//console.log(JSON.stringify(result), result.bar);
});
window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {foo: 'baz'}).then(function(result) {
//console.log(result, typeof result);
//console.log(JSON.stringify(result));
});
}); });
window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {foo: 'baz'}).then(function(result) {
console.log(result, typeof result);
console.log(JSON.stringify(result));
});
$(document).ready(function() { $(document).ready(function() {
console.log("jQuery ready"); console.log("jQuery ready");
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.addEventListener("load", function() { xhttp.addEventListener("load", function() {
console.log(this.responseText); console.log(this.response);
}); });
xhttp.open("POST", "http://192.168.1.20:8082/test-ajax-post"); xhttp.open("POST", "http://192.168.1.20:8082/test-ajax-post");
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyChromeSafariBrowser extends ChromeSafariBrowser { class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(browserFallback); MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);
@override @override
void onOpened() { void onOpened() {
print("ChromeSafari browser opened"); print("ChromeSafari browser opened");
@ -36,7 +36,7 @@ class _ChromeSafariExampleScreenState extends State<ChromeSafariExampleScreen> {
return new Center( return new Center(
child: new RaisedButton( child: new RaisedButton(
onPressed: () async { onPressed: () async {
await widget.browser.open("https://flutter.dev/", await widget.browser.open(url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions( options: ChromeSafariBrowserClassOptions(
androidChromeCustomTabsOptions: AndroidChromeCustomTabsOptions(addShareButton: false), androidChromeCustomTabsOptions: AndroidChromeCustomTabsOptions(addShareButton: false),
iosSafariOptions: IosSafariOptions(barCollapsingEnabled: true) iosSafariOptions: IosSafariOptions(barCollapsingEnabled: true)

View File

@ -104,10 +104,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
resourceCustomSchemes: ["my-special-custom-scheme"], resourceCustomSchemes: ["my-special-custom-scheme"],
contentBlockers: [ contentBlockers: [
ContentBlocker( ContentBlocker(
ContentBlockerTrigger(".*", trigger: ContentBlockerTrigger(
urlFilter: ".*",
resourceType: [ContentBlockerTriggerResourceType.IMAGE, ContentBlockerTriggerResourceType.STYLE_SHEET], resourceType: [ContentBlockerTriggerResourceType.IMAGE, ContentBlockerTriggerResourceType.STYLE_SHEET],
ifTopUrl: ["https://getbootstrap.com/"]), ifTopUrl: ["https://getbootstrap.com/"]),
ContentBlockerAction(ContentBlockerActionType.BLOCK) action: ContentBlockerAction(type: ContentBlockerActionType.BLOCK)
) )
] ]
), ),
@ -125,11 +126,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
if (Platform.isAndroid) if (Platform.isAndroid)
webView.startSafeBrowsing(); webView.startSafeBrowsing();
webView.addJavaScriptHandler('handlerFoo', (args) { webView.addJavaScriptHandler(handlerName:'handlerFoo', callback: (args) {
return new Foo(bar: 'bar_value', baz: 'baz_value'); return new Foo(bar: 'bar_value', baz: 'baz_value');
}); });
webView.addJavaScriptHandler('handlerFooWithArgs', (args) { webView.addJavaScriptHandler(handlerName: 'handlerFooWithArgs', callback: (args) {
print(args); print(args);
return [args[0] + 5, !args[1], args[2][0], args[3]['foo']]; return [args[0] + 5, !args[1], args[2][0], args[3]['foo']];
}); });
@ -155,20 +156,20 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
var tRexHtml = await controller.getTRexRunnerHtml(); var tRexHtml = await controller.getTRexRunnerHtml();
var tRexCss = await controller.getTRexRunnerCss(); var tRexCss = await controller.getTRexRunnerCss();
controller.loadData(""" controller.loadData(data: """
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<style>${tRexCss}</style> <style>$tRexCss</style>
</head> </head>
<body> <body>
${tRexHtml} $tRexHtml
<p> <p>
URL ${url} failed to load. URL $url failed to load.
</p> </p>
<p> <p>
Error: ${code}, ${message} Error: $code, $message
</p> </p>
</body> </body>
</html> </html>
@ -182,7 +183,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
}, },
shouldOverrideUrlLoading: (InAppWebViewController controller, String url) { shouldOverrideUrlLoading: (InAppWebViewController controller, String url) {
print("override $url"); print("override $url");
controller.loadUrl(url); controller.loadUrl(url: url);
}, },
onLoadResource: (InAppWebViewController controller, LoadedResource response) { onLoadResource: (InAppWebViewController controller, LoadedResource response) {
print("Resource type: '"+response.initiatorType + "' started at: " + print("Resource type: '"+response.initiatorType + "' started at: " +
@ -212,14 +213,14 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
onLoadResourceCustomScheme: (InAppWebViewController controller, String scheme, String url) async { onLoadResourceCustomScheme: (InAppWebViewController controller, String scheme, String url) async {
if (scheme == "my-special-custom-scheme") { if (scheme == "my-special-custom-scheme") {
var bytes = await rootBundle.load("assets/" + url.replaceFirst("my-special-custom-scheme://", "", 0)); var bytes = await rootBundle.load("assets/" + url.replaceFirst("my-special-custom-scheme://", "", 0));
var response = new CustomSchemeResponse(bytes.buffer.asUint8List(), "image/svg+xml", contentEnconding: "utf-8"); var response = new CustomSchemeResponse(data: bytes.buffer.asUint8List(), contentType: "image/svg+xml", contentEnconding: "utf-8");
return response; return response;
} }
return null; return null;
}, },
onTargetBlank: (InAppWebViewController controller, String url) { onTargetBlank: (InAppWebViewController controller, String url) {
print("target _blank: " + url); print("target _blank: " + url);
controller.loadUrl(url); controller.loadUrl(url: url);
}, },
onGeolocationPermissionsShowPrompt: (InAppWebViewController controller, String origin) async { onGeolocationPermissionsShowPrompt: (InAppWebViewController controller, String origin) async {
GeolocationPermissionShowPromptResponse response; GeolocationPermissionShowPromptResponse response;
@ -234,14 +235,14 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
FlatButton( FlatButton(
child: Text("Close"), child: Text("Close"),
onPressed: () { onPressed: () {
response = new GeolocationPermissionShowPromptResponse(origin, false, false); response = new GeolocationPermissionShowPromptResponse(origin: origin, allow: false, retain: false);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
FlatButton( FlatButton(
child: Text("Accept"), child: Text("Accept"),
onPressed: () { onPressed: () {
response = new GeolocationPermissionShowPromptResponse(origin, true, true); response = new GeolocationPermissionShowPromptResponse(origin: origin, allow: true, retain: true);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
@ -288,21 +289,24 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
print("Current highlighted: $activeMatchOrdinal, Number of matches found: $numberOfMatches, find operation completed: $isDoneCounting"); print("Current highlighted: $activeMatchOrdinal, Number of matches found: $numberOfMatches, find operation completed: $isDoneCounting");
}, },
shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}"); print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}");
if (ajaxRequest.url == "http://192.168.1.20:8082/test-ajax-post") {
ajaxRequest.responseType = 'json';
}
// ajaxRequest.method = "GET"; // ajaxRequest.method = "GET";
// ajaxRequest.url = "http://192.168.1.20:8082/test-download-file"; // ajaxRequest.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.headers = { // ajaxRequest.headers = {
// "Custom-Header": "Custom-Value" // "Custom-Header": "Custom-Value"
// }; // };
// return ajaxRequest; // return ajaxRequest;
return null; return ajaxRequest;
}, },
onAjaxReadyStateChange: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { onAjaxReadyStateChange: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}"); print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.response}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED; return AjaxRequestAction.PROCEED;
}, },
onAjaxProgress: (InAppWebViewController controller, AjaxRequest ajaxRequest) async { onAjaxProgress: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
//print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}"); print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED; return AjaxRequestAction.PROCEED;
}, },
shouldInterceptFetchRequest: (InAppWebViewController controller, FetchRequest fetchRequest) async { shouldInterceptFetchRequest: (InAppWebViewController controller, FetchRequest fetchRequest) async {
@ -312,7 +316,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return fetchRequest; return fetchRequest;
}, },
onNavigationStateChange: (InAppWebViewController controller, String url) async { onNavigationStateChange: (InAppWebViewController controller, String url) async {
print("NAVIGATION STATE CHANGE: ${url}"); print("NAVIGATION STATE CHANGE: $url");
setState(() { setState(() {
this.url = url; this.url = url;
}); });

View File

@ -3,7 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInappBrowser extends InAppBrowser { class MyInAppBrowser extends InAppBrowser {
@override @override
Future onBrowserCreated() async { Future onBrowserCreated() async {
@ -43,7 +43,7 @@ class MyInappBrowser extends InAppBrowser {
@override @override
void shouldOverrideUrlLoading(String url) { void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n"); print("\n\n override $url\n\n");
this.webViewController.loadUrl(url); this.webViewController.loadUrl(url: url);
} }
@override @override
@ -75,11 +75,13 @@ class MyInappBrowser extends InAppBrowser {
@override @override
Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) async { Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) async {
print("custom scheme: " + scheme); print("custom scheme: " + scheme);
return null;
} }
@override @override
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt(String origin) async { Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt(String origin) async {
print("request Geolocation permission API"); print("request Geolocation permission API");
return null;
} }
@override @override
@ -89,18 +91,18 @@ class MyInappBrowser extends InAppBrowser {
@override @override
Future<JsConfirmResponse> onJsConfirm(String message) { Future<JsConfirmResponse> onJsConfirm(String message) {
return null;
} }
@override @override
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) { Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
return null;
} }
} }
class WebviewExampleScreen extends StatefulWidget { class WebviewExampleScreen extends StatefulWidget {
final MyInappBrowser browser = new MyInappBrowser(); final MyInAppBrowser browser = new MyInAppBrowser();
static BuildContext context = null; static BuildContext context;
@override @override
_WebviewExampleScreenState createState() => new _WebviewExampleScreenState(); _WebviewExampleScreenState createState() => new _WebviewExampleScreenState();
@ -119,7 +121,7 @@ class _WebviewExampleScreenState extends State<WebviewExampleScreen> {
child: new RaisedButton( child: new RaisedButton(
onPressed: () { onPressed: () {
widget.browser.openFile( widget.browser.openFile(
"assets/index.html", assetFilePath: "assets/index.html",
//url: "https://www.google.com/", //url: "https://www.google.com/",
options: InAppBrowserClassOptions( options: InAppBrowserClassOptions(
inAppWebViewWidgetOptions: InAppWebViewWidgetOptions( inAppWebViewWidgetOptions: InAppWebViewWidgetOptions(

View File

@ -82,8 +82,6 @@ window.\(JAVASCRIPT_BRIDGE_NAME).callHandler = function() {
} }
""" """
let platformReadyJS = "window.dispatchEvent(new Event('flutterInAppBrowserPlatformReady'));";
let findTextHighlightJS = """ let findTextHighlightJS = """
var wkwebview_SearchResultCount = 0; var wkwebview_SearchResultCount = 0;
var wkwebview_CurrentHighlight = 0; var wkwebview_CurrentHighlight = 0;
@ -266,6 +264,29 @@ let interceptAjaxRequestsJS = """
ajax.prototype._flutter_inappbrowser_password = null; ajax.prototype._flutter_inappbrowser_password = null;
ajax.prototype._flutter_inappbrowser_already_onreadystatechange_wrapped = false; ajax.prototype._flutter_inappbrowser_already_onreadystatechange_wrapped = false;
ajax.prototype._flutter_inappbrowser_request_headers = {}; ajax.prototype._flutter_inappbrowser_request_headers = {};
function convertRequestResponse(request, callback) {
if (request.response != null && request.responseType != null) {
switch (request.responseType) {
case 'arraybuffer':
callback(new Uint8Array(request.response));
return;
case 'blob':
const reader = new FileReader();
reader.addEventListener('loadend', function() {
callback(new Uint8Array(reader.result));
});
reader.readAsArrayBuffer(blob);
return;
case 'document':
callback(request.response.documentElement.outerHTML);
return;
case 'json':
callback(request.response);
return;
};
}
callback(null);
};
ajax.prototype.open = function(method, url, isAsync, user, password) { ajax.prototype.open = function(method, url, isAsync, user, password) {
isAsync = (isAsync != null) ? isAsync : true; isAsync = (isAsync != null) ? isAsync : true;
this._flutter_inappbrowser_url = url; this._flutter_inappbrowser_url = url;
@ -293,35 +314,40 @@ let interceptAjaxRequestsJS = """
responseHeaders[header] = value; responseHeaders[header] = value;
}); });
} }
var ajaxRequest = { convertRequestResponse(this, function(response) {
method: this._flutter_inappbrowser_method, var ajaxRequest = {
url: this._flutter_inappbrowser_url, method: self._flutter_inappbrowser_method,
isAsync: this._flutter_inappbrowser_isAsync, url: self._flutter_inappbrowser_url,
user: this._flutter_inappbrowser_user, isAsync: self._flutter_inappbrowser_isAsync,
password: this._flutter_inappbrowser_password, user: self._flutter_inappbrowser_user,
withCredentials: this.withCredentials, password: self._flutter_inappbrowser_password,
headers: this._flutter_inappbrowser_request_headers, withCredentials: self.withCredentials,
readyState: this.readyState, headers: self._flutter_inappbrowser_request_headers,
status: this.status, readyState: self.readyState,
responseURL: this.responseURL, status: self.status,
responseType: this.responseType, responseURL: self.responseURL,
responseText: this.responseText, responseType: self.responseType,
statusText: this.statusText, response: response,
responseHeaders, responseHeaders, responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null,
event: { responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null,
type: e.type, statusText: self.statusText,
loaded: e.loaded, responseHeaders, responseHeaders,
lengthComputable: e.lengthComputable event: {
} type: e.type,
}; loaded: e.loaded,
window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('onAjaxProgress', ajaxRequest).then(function(result) { lengthComputable: e.lengthComputable,
if (result != null) { total: e.total
switch (result) { }
case 0: };
self.abort(); window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('onAjaxProgress', ajaxRequest).then(function(result) {
return; if (result != null) {
}; switch (result) {
} case 0:
self.abort();
return;
};
}
});
}); });
} }
}; };
@ -344,33 +370,37 @@ let interceptAjaxRequestsJS = """
responseHeaders[header] = value; responseHeaders[header] = value;
}); });
} }
var ajaxRequest = { convertRequestResponse(this, function(response) {
method: this._flutter_inappbrowser_method, var ajaxRequest = {
url: this._flutter_inappbrowser_url, method: self._flutter_inappbrowser_method,
isAsync: this._flutter_inappbrowser_isAsync, url: self._flutter_inappbrowser_url,
user: this._flutter_inappbrowser_user, isAsync: self._flutter_inappbrowser_isAsync,
password: this._flutter_inappbrowser_password, user: self._flutter_inappbrowser_user,
withCredentials: this.withCredentials, password: self._flutter_inappbrowser_password,
headers: this._flutter_inappbrowser_request_headers, withCredentials: self.withCredentials,
readyState: this.readyState, headers: self._flutter_inappbrowser_request_headers,
status: this.status, readyState: self.readyState,
responseURL: this.responseURL, status: self.status,
responseType: this.responseType, responseURL: self.responseURL,
responseText: this.responseText, responseType: self.responseType,
statusText: this.statusText, response: response,
responseHeaders: responseHeaders responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null,
}; responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null,
window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) { statusText: self.statusText,
if (result != null) { responseHeaders: responseHeaders
switch (result) { };
case 0: window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) {
self.abort(); if (result != null) {
return; switch (result) {
}; case 0:
} self.abort();
if (onreadystatechange != null) { return;
onreadystatechange(); };
} }
if (onreadystatechange != null) {
onreadystatechange();
}
});
}); });
} else if (onreadystatechange != null) { } else if (onreadystatechange != null) {
onreadystatechange(); onreadystatechange();
@ -383,6 +413,7 @@ let interceptAjaxRequestsJS = """
this.addEventListener('progress', handleEvent); this.addEventListener('progress', handleEvent);
this.addEventListener('error', handleEvent); this.addEventListener('error', handleEvent);
this.addEventListener('abort', handleEvent); this.addEventListener('abort', handleEvent);
this.addEventListener('timeout', handleEvent);
var ajaxRequest = { var ajaxRequest = {
data: data, data: data,
method: this._flutter_inappbrowser_method, method: this._flutter_inappbrowser_method,
@ -391,7 +422,8 @@ let interceptAjaxRequestsJS = """
user: this._flutter_inappbrowser_user, user: this._flutter_inappbrowser_user,
password: this._flutter_inappbrowser_password, password: this._flutter_inappbrowser_password,
withCredentials: this.withCredentials, withCredentials: this.withCredentials,
headers: this._flutter_inappbrowser_request_headers headers: this._flutter_inappbrowser_request_headers,
responseType: this.responseType
}; };
window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) { window.\(JAVASCRIPT_BRIDGE_NAME).callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) {
if (result != null) { if (result != null) {
@ -402,6 +434,9 @@ let interceptAjaxRequestsJS = """
}; };
data = result.data; data = result.data;
self.withCredentials = result.withCredentials; self.withCredentials = result.withCredentials;
if (result.responseType != null) {
self.responseType = result.responseType;
};
for (var header in result.headers) { for (var header in result.headers) {
var value = result.headers[header]; var value = result.headers[header];
self.setRequestHeader(header, value); self.setRequestHeader(header, value);
@ -557,7 +592,7 @@ let interceptFetchRequestsJS = """
controller.abort(); controller.abort();
break; break;
} }
var resultResource = (result.resource != null) ? result.resource : resource; var resultResource = (result.url != null) ? result.url : resource;
var resultInit = init; var resultInit = init;
if (result.init != null) { if (result.init != null) {
resultInit.method = result.method; resultInit.method = result.method;
@ -1308,7 +1343,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
currentURL = url currentURL = url
InAppWebView.credentialsProposed = [] InAppWebView.credentialsProposed = []
onLoadStop(url: (currentURL?.absoluteString)!) onLoadStop(url: (currentURL?.absoluteString)!)
evaluateJavaScript(platformReadyJS, completionHandler: nil)
if IABController != nil { if IABController != nil {
IABController!.updateUrlTextField(url: (currentURL?.absoluteString)!) IABController!.updateUrlTextField(url: (currentURL?.absoluteString)!)

View File

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'types.dart'; import 'types.dart';
@ -12,16 +13,16 @@ import 'in_app_browser.dart';
///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android ///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android
///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. ///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
/// ///
///[browserFallback] represents the [InAppBrowser] instance fallback in case [Chrome Custom Tabs]/[SFSafariViewController] is not available. ///[browserFallback] represents the [InAppBrowser] instance fallback in case `Chrome Custom Tabs`/`SFSafariViewController` is not available.
class ChromeSafariBrowser { class ChromeSafariBrowser {
String uuid; String uuid;
InAppBrowser browserFallback; InAppBrowser browserFallback;
bool _isOpened = false; bool _isOpened = false;
///Initialize the [ChromeSafariBrowser] instance with an [InAppBrowser] fallback instance or `null`. ///Initialize the [ChromeSafariBrowser] instance with an [InAppBrowser] fallback instance or `null`.
ChromeSafariBrowser (bf) { ChromeSafariBrowser ({bFallback}) {
uuid = uuidGenerator.v4(); uuid = uuidGenerator.v4();
browserFallback = bf; browserFallback = bFallback;
ChannelManager.addListener(uuid, handleMethod); ChannelManager.addListener(uuid, handleMethod);
_isOpened = false; _isOpened = false;
} }
@ -45,32 +46,14 @@ class ChromeSafariBrowser {
///Opens an [url] in a new [ChromeSafariBrowser] instance. ///Opens an [url] in a new [ChromeSafariBrowser] instance.
/// ///
///- [url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters. ///[url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters.
/// ///
///- [options]: Options for the [ChromeSafariBrowser]. ///[options]: Options for the [ChromeSafariBrowser].
/// ///
///- [headersFallback]: The additional header of the [InAppBrowser] instance fallback to be used in the HTTP request for this URL, specified as a map from name to value. ///[headersFallback]: The additional header of the [InAppBrowser] instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
/// ///
///- [optionsFallback]: Options used by the [InAppBrowser] instance fallback. ///[optionsFallback]: Options used by the [InAppBrowser] instance fallback.
/// Future<void> open({@required String url, ChromeSafariBrowserClassOptions options, Map<String, String> headersFallback = const {}, InAppBrowserClassOptions optionsFallback}) async {
///**Android** supports these options:
///
///- __addShareButton__: Set to `false` if you don't want the default share button. The default value is `true`.
///- __showTitle__: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
///- __toolbarBackgroundColor__: Set the custom background color of the toolbar.
///- __enableUrlBarHiding__: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
///- __instantAppsEnabled__: Set to `true` to enable Instant Apps. The default value is `false`.
///
///**iOS** supports these options:
///
///- __entersReaderIfAvailable__: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
///- __barCollapsingEnabled__: Set to `true` to enable bar collapsing. The default value is `false`.
///- __dismissButtonStyle__: Set the custom style for the dismiss button. The default value is `0 //done`. See [SFSafariViewController.DismissButtonStyle](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/dismissbuttonstyle) for all the available styles.
///- __preferredBarTintColor__: Set the custom background color of the navigation bar and the toolbar.
///- __preferredControlTintColor__: Set the custom color of the control buttons on the navigation bar and the toolbar.
///- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
///- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
Future<void> open(String url, {ChromeSafariBrowserClassOptions options, Map<String, String> headersFallback = const {}, InAppBrowserClassOptions optionsFallback}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $url!'); this.throwIsAlreadyOpened(message: 'Cannot open $url!');

View File

@ -1,8 +1,19 @@
import 'package:flutter/foundation.dart';
///ContentBlocker class represents a set of rules to use block content in the browser window.
///
///On iOS, it uses [WKContentRuleListStore](https://developer.apple.com/documentation/webkit/wkcontentruleliststore).
///On Android, it uses a custom implementation because such functionality doesn't exist.
///
///In general, this [article](https://developer.apple.com/documentation/safariservices/creating_a_content_blocker) can be used to get an overview about this functionality
///but on Android there are two types of [action] that are unavailable: `block-cookies` and `ignore-previous-rules`.
class ContentBlocker { class ContentBlocker {
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
ContentBlockerTrigger trigger; ContentBlockerTrigger trigger;
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
ContentBlockerAction action; ContentBlockerAction action;
ContentBlocker(this.trigger, this.action); ContentBlocker({@required this.trigger,@required this.action});
Map<String, Map<String, dynamic>> toMap() { Map<String, Map<String, dynamic>> toMap() {
return { return {
@ -13,21 +24,22 @@ class ContentBlocker {
static ContentBlocker fromMap(Map<dynamic, Map<dynamic, dynamic>> map) { static ContentBlocker fromMap(Map<dynamic, Map<dynamic, dynamic>> map) {
return ContentBlocker( return ContentBlocker(
ContentBlockerTrigger.fromMap( trigger: ContentBlockerTrigger.fromMap(
Map<String, dynamic>.from(map["trigger"]) Map<String, dynamic>.from(map["trigger"])
), ),
ContentBlockerAction.fromMap( action: ContentBlockerAction.fromMap(
Map<String, dynamic>.from(map["action"]) Map<String, dynamic>.from(map["action"])
) )
); );
} }
} }
///ContentBlockerTriggerResourceType class represents the possible resource type defined for a [ContentBlockerTrigger].
class ContentBlockerTriggerResourceType { class ContentBlockerTriggerResourceType {
final String _value; final String _value;
const ContentBlockerTriggerResourceType._internal(this._value); const ContentBlockerTriggerResourceType._internal(this._value);
static ContentBlockerTriggerResourceType fromValue(String value) { static ContentBlockerTriggerResourceType fromValue(String value) {
return (["document", "image", "LINK", "style-sheet", "script", "font", return (["document", "image", "style-sheet", "script", "font",
"media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null; "media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null;
} }
toValue() => _value; toValue() => _value;
@ -39,9 +51,11 @@ class ContentBlockerTriggerResourceType {
static const FONT = const ContentBlockerTriggerResourceType._internal('font'); static const FONT = const ContentBlockerTriggerResourceType._internal('font');
static const MEDIA = const ContentBlockerTriggerResourceType._internal('media'); static const MEDIA = const ContentBlockerTriggerResourceType._internal('media');
static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document'); static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document');
///Any untyped load
static const RAW = const ContentBlockerTriggerResourceType._internal('raw'); static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
} }
///ContentBlockerTriggerLoadType class represents the possible load type for a [ContentBlockerTrigger].
class ContentBlockerTriggerLoadType { class ContentBlockerTriggerLoadType {
final String _value; final String _value;
const ContentBlockerTriggerLoadType._internal(this._value); const ContentBlockerTriggerLoadType._internal(this._value);
@ -50,24 +64,44 @@ class ContentBlockerTriggerLoadType {
} }
toValue() => _value; toValue() => _value;
///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource.
static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party'); static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party');
///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource.
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party'); static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
} }
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
///A trigger dictionary must include an [ContentBlockerTrigger.urlFilter], which specifies a pattern to match the URL against.
///The remaining properties are optional and modify the behavior of the trigger.
///For example, you can limit the trigger to specific domains or have it not apply when a match is found on a specific domain.
class ContentBlockerTrigger { class ContentBlockerTrigger {
///A regular expression pattern to match the URL against.
String urlFilter; String urlFilter;
///Used only by iOS. A Boolean value. The default value is false.
bool urlFilterIsCaseSensitive; bool urlFilterIsCaseSensitive;
///A list of [ContentBlockerTriggerResourceType] representing the resource types (how the browser intends to use the resource) that the rule should match.
///If not specified, the rule matches all resource types.
List<ContentBlockerTriggerResourceType> resourceType; List<ContentBlockerTriggerResourceType> resourceType;
///A list of strings matched to a URL's domain; limits action to a list of specific domains.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.unlessDomain].
List<String> ifDomain; List<String> ifDomain;
///A list of strings matched to a URL's domain; acts on any site except domains in a provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.ifDomain].
List<String> unlessDomain; List<String> unlessDomain;
///A list of [ContentBlockerTriggerLoadType] that can include one of two mutually exclusive values. If not specified, the rule matches all load types.
List<ContentBlockerTriggerLoadType> loadType; List<ContentBlockerTriggerLoadType> loadType;
///A list of strings matched to the entire main document URL; limits the action to a specific list of URL patterns.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.unlessTopUrl].
List<String> ifTopUrl; List<String> ifTopUrl;
///An array of strings matched to the entire main document URL; acts on any site except URL patterns in provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.ifTopUrl].
List<String> unlessTopUrl; List<String> unlessTopUrl;
ContentBlockerTrigger(String urlFilter, {bool urlFilterIsCaseSensitive = false, List<ContentBlockerTriggerResourceType> resourceType = const [], ContentBlockerTrigger({@required String urlFilter, bool urlFilterIsCaseSensitive = false, List<ContentBlockerTriggerResourceType> resourceType = const [],
List<String> ifDomain = const [], List<String> unlessDomain = const [], List<ContentBlockerTriggerLoadType> loadType = const [], List<String> ifDomain = const [], List<String> unlessDomain = const [], List<ContentBlockerTriggerLoadType> loadType = const [],
List<String> ifTopUrl = const [], List<String> unlessTopUrl = const []}) { List<String> ifTopUrl = const [], List<String> unlessTopUrl = const []}) {
this.urlFilter = urlFilter; this.urlFilter = urlFilter;
assert(this.urlFilter != null);
this.resourceType = resourceType; this.resourceType = resourceType;
this.urlFilterIsCaseSensitive = urlFilterIsCaseSensitive; this.urlFilterIsCaseSensitive = urlFilterIsCaseSensitive;
this.ifDomain = ifDomain; this.ifDomain = ifDomain;
@ -124,7 +158,7 @@ class ContentBlockerTrigger {
}); });
return ContentBlockerTrigger( return ContentBlockerTrigger(
map["url-filter"], urlFilter: map["url-filter"],
urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"], urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"],
ifDomain: List<String>.from(map["if-domain"] ?? []), ifDomain: List<String>.from(map["if-domain"] ?? []),
unlessDomain: List<String>.from(map["unless-domain"] ?? []), unlessDomain: List<String>.from(map["unless-domain"] ?? []),
@ -136,6 +170,7 @@ class ContentBlockerTrigger {
} }
} }
///ContentBlockerActionType class represents the kind of action that can be used with a [ContentBlockerTrigger].
class ContentBlockerActionType { class ContentBlockerActionType {
final String _value; final String _value;
const ContentBlockerActionType._internal(this._value); const ContentBlockerActionType._internal(this._value);
@ -144,17 +179,31 @@ class ContentBlockerActionType {
} }
toValue() => _value; toValue() => _value;
///Stops loading of the resource. If the resource was cached, the cache is ignored.
static const BLOCK = const ContentBlockerActionType._internal('block'); static const BLOCK = const ContentBlockerActionType._internal('block');
///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it.
///
///**NOTE**: on Android, JavaScript must be enabled.
static const CSS_DISPLAY_NONE = const ContentBlockerActionType._internal('css-display-none'); static const CSS_DISPLAY_NONE = const ContentBlockerActionType._internal('css-display-none');
///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected.
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https'); static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
} }
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
///When a trigger matches a resource, the browser queues the associated action for execution.
///The WebView evaluates all the triggers, it executes the actions in order.
///When a domain matches a trigger, all rules after the triggered rule that specify the same action are skipped.
///Group the rules with similar actions together to improve performance.
class ContentBlockerAction { class ContentBlockerAction {
///Type of the action.
ContentBlockerActionType type; ContentBlockerActionType type;
///If the action type is [ContentBlockerActionType.CSS_DISPLAY_NONE], then also the [selector] property is required, otherwise it is ignored.
///It specify a string that defines a selector list. Use CSS identifiers as the individual selector values, separated by commas.
String selector; String selector;
ContentBlockerAction(ContentBlockerActionType type, {String selector}) { ContentBlockerAction({@required ContentBlockerActionType type, String selector}) {
this.type = type; this.type = type;
assert(this.type != null);
if (this.type == ContentBlockerActionType.CSS_DISPLAY_NONE) { if (this.type == ContentBlockerActionType.CSS_DISPLAY_NONE) {
assert(selector != null); assert(selector != null);
} }
@ -177,7 +226,7 @@ class ContentBlockerAction {
static ContentBlockerAction fromMap(Map<String, dynamic> map) { static ContentBlockerAction fromMap(Map<String, dynamic> map) {
return ContentBlockerAction( return ContentBlockerAction(
ContentBlockerActionType.fromValue(map["type"]), type: ContentBlockerActionType.fromValue(map["type"]),
selector: map["selector"] selector: map["selector"]
); );
} }

View File

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
///Manages the cookies used by WebView instances. ///Manages the cookies used by WebView instances.
@ -26,8 +27,8 @@ class CookieManager {
/// ///
///The default value of [path] is `"/"`. ///The default value of [path] is `"/"`.
///If [domain] is `null`, its default value will be the domain name of [url]. ///If [domain] is `null`, its default value will be the domain name of [url].
Future<void> setCookie(String url, String name, String value, Future<void> setCookie({@required String url, @required String name, @required String value,
{ String domain, String domain,
String path = "/", String path = "/",
int expiresDate, int expiresDate,
int maxAge, int maxAge,
@ -55,7 +56,7 @@ class CookieManager {
} }
///Gets all the cookies for the given [url]. ///Gets all the cookies for the given [url].
Future<List<Map<String, dynamic>>> getCookies(String url) async { Future<List<Map<String, dynamic>>> getCookies({@required String url}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -70,7 +71,7 @@ class CookieManager {
} }
///Gets a cookie by its [name] for the given [url]. ///Gets a cookie by its [name] for the given [url].
Future<Map<String, dynamic>> getCookie(String url, String name) async { Future<Map<String, dynamic>> getCookie({@required String url, @required String name}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
assert(name != null && name.isNotEmpty); assert(name != null && name.isNotEmpty);
@ -90,7 +91,7 @@ class CookieManager {
/// ///
///The default value of [path] is `"/"`. ///The default value of [path] is `"/"`.
///If [domain] is `null` or empty, its default value will be the domain name of [url]. ///If [domain] is `null` or empty, its default value will be the domain name of [url].
Future<void> deleteCookie(String url, String name, {String domain = "", String path = "/"}) async { Future<void> deleteCookie({@required String url, @required String name, String domain = "", String path = "/"}) async {
if (domain == null || domain.isEmpty) if (domain == null || domain.isEmpty)
domain = _getDomainName(url); domain = _getDomainName(url);
@ -111,7 +112,7 @@ class CookieManager {
/// ///
///The default value of [path] is `"/"`. ///The default value of [path] is `"/"`.
///If [domain] is `null` or empty, its default value will be the domain name of [url]. ///If [domain] is `null` or empty, its default value will be the domain name of [url].
Future<void> deleteCookies(String url, {String domain = "", String path = "/"}) async { Future<void> deleteCookies({@required String url, String domain = "", String path = "/"}) async {
if (domain == null || domain.isEmpty) if (domain == null || domain.isEmpty)
domain = _getDomainName(url); domain = _getDomainName(url);

View File

@ -1,14 +1,19 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart';
import 'types.dart'; import 'types.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
/// ///HttpAuthCredentialDatabase class implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.
///On iOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.
///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase)
///doesn't offer the same functionalities as iOS `URLCredentialStorage`.
class HttpAuthCredentialDatabase { class HttpAuthCredentialDatabase {
static HttpAuthCredentialDatabase _instance; static HttpAuthCredentialDatabase _instance;
static const MethodChannel _channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser_credential_database'); static const MethodChannel _channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser_credential_database');
/// ///Gets the database shared instance.
static HttpAuthCredentialDatabase instance() { static HttpAuthCredentialDatabase instance() {
return (_instance != null) ? _instance : _init(); return (_instance != null) ? _instance : _init();
} }
@ -22,7 +27,9 @@ class HttpAuthCredentialDatabase {
static Future<dynamic> _handleMethod(MethodCall call) async { static Future<dynamic> _handleMethod(MethodCall call) async {
} }
/// ///Gets a map list of all HTTP auth credentials saved.
///Each map contains the key `protectionSpace` of type [ProtectionSpace]
///and the key `credentials` of type `List<HttpAuthCredential>` that contains all the HTTP auth credentials saved for that `protectionSpace`.
Future<List<Map<String, dynamic>>> getAllAuthCredentials() async { Future<List<Map<String, dynamic>>> getAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> allCredentials = await _channel.invokeMethod('getAllAuthCredentials', args); List<dynamic> allCredentials = await _channel.invokeMethod('getAllAuthCredentials', args);
@ -38,8 +45,8 @@ class HttpAuthCredentialDatabase {
return result; return result;
} }
/// ///Gets all the HTTP auth credentials saved for that [protectionSpace].
Future<List<HttpAuthCredential>> getHttpAuthCredentials(ProtectionSpace protectionSpace) async { Future<List<HttpAuthCredential>> getHttpAuthCredentials({@required ProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host); args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol); args.putIfAbsent("protocol", () => protectionSpace.protocol);
@ -53,8 +60,8 @@ class HttpAuthCredentialDatabase {
return credentials; return credentials;
} }
/// ///Saves an HTTP auth [credential] for that [protectionSpace].
Future<void> setHttpAuthCredential(ProtectionSpace protectionSpace, HttpAuthCredential credential) async { Future<void> setHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host); args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol); args.putIfAbsent("protocol", () => protectionSpace.protocol);
@ -65,8 +72,8 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('setHttpAuthCredential', args); await _channel.invokeMethod('setHttpAuthCredential', args);
} }
/// ///Removes an HTTP auth [credential] for that [protectionSpace].
Future<void> removeHttpAuthCredential(ProtectionSpace protectionSpace, HttpAuthCredential credential) async { Future<void> removeHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host); args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol); args.putIfAbsent("protocol", () => protectionSpace.protocol);
@ -77,8 +84,8 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('removeHttpAuthCredential', args); await _channel.invokeMethod('removeHttpAuthCredential', args);
} }
/// ///Removes all the HTTP auth credentials saved for that [protectionSpace].
Future<void> removeHttpAuthCredentials(ProtectionSpace protectionSpace) async { Future<void> removeHttpAuthCredentials({@required ProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host); args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol); args.putIfAbsent("protocol", () => protectionSpace.protocol);
@ -87,7 +94,7 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('removeHttpAuthCredentials', args); await _channel.invokeMethod('removeHttpAuthCredentials', args);
} }
/// ///Removes all the HTTP auth credentials saved in the database.
Future<void> clearAllAuthCredentials() async { Future<void> clearAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('clearAllAuthCredentials', args); await _channel.invokeMethod('clearAllAuthCredentials', args);

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_inappbrowser/src/webview_options.dart'; import 'package:flutter_inappbrowser/src/webview_options.dart';
@ -45,64 +46,11 @@ class InAppBrowser {
///Opens an [url] in a new [InAppBrowser] instance. ///Opens an [url] in a new [InAppBrowser] instance.
/// ///
///- [url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters. The default value is `about:blank`. ///[url]: The [url] to load. Call `encodeUriComponent()` on this if the [url] contains Unicode characters. The default value is `about:blank`.
/// ///
///- [headers]: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value. ///[headers]: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value.
/// ///
///- [options]: Options for the [InAppBrowser]. ///[options]: Options for the [InAppBrowser].
///
/// - All platforms support:
/// - __useShouldOverrideUrlLoading__: Set to `true` to be able to listen at the [shouldOverrideUrlLoading()] event. The default value is `false`.
/// - __useOnLoadResource__: Set to `true` to be able to listen at the [onLoadResource()] event. The default value is `false`.
/// - __useOnDownloadStart__: Set to `true` to be able to listen at the [onDownloadStart()] event. The default value is `false`.
/// - __useOnTargetBlank__: Set to `true` to be able to listen at the [onTargetBlank()] event. The default value is `false`.
/// - __clearCache__: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
/// - __userAgent__: Set the custom WebView's user-agent.
/// - __javaScriptEnabled__: Set to `true` to enable JavaScript. The default value is `true`.
/// - __javaScriptCanOpenWindowsAutomatically__: Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
/// - __hidden__: Set to `true` to create the browser and load the page, but not show it. The `onLoadStop` event fires when loading is complete. Omit or set to `false` (default) to have the browser open and load normally.
/// - __toolbarTop__: Set to `false` to hide the toolbar at the top of the WebView. The default value is `true`.
/// - __toolbarTopBackgroundColor__: Set the custom background color of the toolbar at the top.
/// - __hideUrlBar__: Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
/// - __mediaPlaybackRequiresUserGesture__: Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
/// - __transparentBackground__: Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
/// - __resourceCustomSchemes__: List of custom schemes that [InAppBrowser] must handle. Use the [onLoadResourceCustomScheme()] event to intercept resource requests with custom scheme.
///
/// - **Android** supports these additional options:
///
/// - __hideTitleBar__: Set to `true` if you want the title should be displayed. The default value is `false`.
/// - __closeOnCannotGoBack__: Set to `false` to not close the InAppBrowser when the user click on the back button and the WebView cannot go back to the history. The default value is `true`.
/// - __clearSessionCache__: Set to `true` to have the session cookie cache cleared before the new window is opened.
/// - __builtInZoomControls__: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
/// - __displayZoomControls__: Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
/// - __supportZoom__: Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
/// - __databaseEnabled__: Set to `true` if you want the database storage API is enabled. The default value is `false`.
/// - __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
/// - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
/// - __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
/// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
/// - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
///
/// - **iOS** supports these additional options:
///
/// - __disallowOverScroll__: Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
/// - __toolbarBottom__: Set to `false` to hide the toolbar at the bottom of the WebView. The default value is `true`.
/// - __toolbarBottomBackgroundColor__: Set the custom background color of the toolbar at the bottom.
/// - __toolbarBottomTranslucent__: Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
/// - __closeButtonCaption__: Set the custom text for the close button.
/// - __closeButtonColor__: Set the custom color for the close button.
/// - __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
/// - __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
/// - __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
/// - __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
/// - __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
/// - __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
/// - __allowsLinkPreview__: Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
/// - __ignoresViewportScaleLimits__: Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent. The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
/// - __allowsInlineMediaPlayback__: Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
/// - __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
/// - __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
Future<void> open({String url = "about:blank", Map<String, String> headers = const {}, InAppBrowserClassOptions options}) async { Future<void> open({String url = "about:blank", Map<String, String> headers = const {}, InAppBrowserClassOptions options}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $url!'); this.throwIsAlreadyOpened(message: 'Cannot open $url!');
@ -132,7 +80,7 @@ class InAppBrowser {
await ChannelManager.channel.invokeMethod('open', args); await ChannelManager.channel.invokeMethod('open', args);
} }
///Opens the given [assetFilePath] file in a new [InAppBrowser] instance. The other arguments are the same of [InAppBrowser.open()]. ///Opens the given [assetFilePath] file in a new [InAppBrowser] instance. The other arguments are the same of [InAppBrowser.open].
/// ///
///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found!
/// ///
@ -161,7 +109,11 @@ class InAppBrowser {
///inAppBrowser.openFile("assets/t-rex.html"); ///inAppBrowser.openFile("assets/t-rex.html");
///... ///...
///``` ///```
Future<void> openFile(String assetFilePath, {Map<String, String> headers = const {}, InAppBrowserClassOptions options}) async { ///
///[headers]: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value.
///
///[options]: Options for the [InAppBrowser].
Future<void> openFile({@required String assetFilePath, Map<String, String> headers = const {}, InAppBrowserClassOptions options}) async {
assert(assetFilePath != null && assetFilePath.isNotEmpty); assert(assetFilePath != null && assetFilePath.isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $assetFilePath!'); this.throwIsAlreadyOpened(message: 'Cannot open $assetFilePath!');
@ -191,9 +143,13 @@ class InAppBrowser {
} }
///Opens a new [InAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it. ///Opens a new [InAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it.
///
///The [mimeType] parameter specifies the format of the data. ///The [mimeType] parameter specifies the format of the data.
///
///The [encoding] parameter specifies the encoding of the data. ///The [encoding] parameter specifies the encoding of the data.
Future<void> openData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", InAppBrowserClassOptions options}) async { ///
///The [options] parameter specifies the options for the [InAppBrowser].
Future<void> openData({@required String data, String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", InAppBrowserClassOptions options}) async {
assert(data != null); assert(data != null);
Map<String, dynamic> optionsMap = {}; Map<String, dynamic> optionsMap = {};
@ -224,7 +180,7 @@ class InAppBrowser {
} }
///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here! ///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here!
static Future<void> openWithSystemBrowser(String url) async { static Future<void> openWithSystemBrowser({@required String url}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('uuid', () => ""); args.putIfAbsent('uuid', () => "");
@ -271,7 +227,7 @@ class InAppBrowser {
} }
///Sets the [InAppBrowser] options with the new [options] and evaluates them. ///Sets the [InAppBrowser] options with the new [options] and evaluates them.
Future<void> setOptions(InAppBrowserClassOptions options) async { Future<void> setOptions({@required InAppBrowserClassOptions options}) async {
this.throwIsNotOpened(); this.throwIsNotOpened();
Map<String, dynamic> optionsMap = {}; Map<String, dynamic> optionsMap = {};
@ -362,14 +318,14 @@ class InAppBrowser {
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. ///Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
/// ///
///**NOTE**: In order to be able to listen this event, you need to set `useShouldOverrideUrlLoading` option to `true`. ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldOverrideUrlLoading] option to `true`.
void shouldOverrideUrlLoading(String url) { void shouldOverrideUrlLoading(String url) {
} }
///Event fires when the [InAppBrowser] webview loads a resource. ///Event fires when the [InAppBrowser] webview loads a resource.
/// ///
///**NOTE**: In order to be able to listen this event, you need to set `useOnLoadResource` option to `true`. ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnLoadResource] and [InAppWebViewOptions.javaScriptEnabled] options to `true`.
void onLoadResource(LoadedResource resource) { void onLoadResource(LoadedResource resource) {
} }
@ -386,6 +342,8 @@ class InAppBrowser {
///Event fires when [InAppBrowser] recognizes and starts a downloadable file. ///Event fires when [InAppBrowser] recognizes and starts a downloadable file.
/// ///
///[url] represents the url of the file. ///[url] represents the url of the file.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnDownloadStart] option to `true`.
void onDownloadStart(String url) { void onDownloadStart(String url) {
} }
@ -395,6 +353,7 @@ class InAppBrowser {
///[scheme] represents the scheme of the url. ///[scheme] represents the scheme of the url.
/// ///
///[url] represents the url of the request. ///[url] represents the url of the request.
// ignore: missing_return
Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) { Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) {
} }
@ -402,6 +361,8 @@ class InAppBrowser {
///Event fires when the [InAppBrowser] webview tries to open a link with `target="_blank"`. ///Event fires when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
/// ///
///[url] represents the url of the link. ///[url] represents the url of the link.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnTargetBlank] option to `true`.
void onTargetBlank(String url) { void onTargetBlank(String url) {
} }
@ -413,6 +374,7 @@ class InAppBrowser {
///[origin] represents the origin of the web content attempting to use the Geolocation API. ///[origin] represents the origin of the web content attempting to use the Geolocation API.
/// ///
///**NOTE**: available only for Android. ///**NOTE**: available only for Android.
// ignore: missing_return
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) { Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) {
} }
@ -421,6 +383,7 @@ class InAppBrowser {
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog. ///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
/// ///
///[message] represents the message to be displayed in the alert dialog. ///[message] represents the message to be displayed in the alert dialog.
// ignore: missing_return
Future<JsAlertResponse> onJsAlert(String message) { Future<JsAlertResponse> onJsAlert(String message) {
} }
@ -429,6 +392,7 @@ class InAppBrowser {
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog. ///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
/// ///
///[message] represents the message to be displayed in the alert dialog. ///[message] represents the message to be displayed in the alert dialog.
// ignore: missing_return
Future<JsConfirmResponse> onJsConfirm(String message) { Future<JsConfirmResponse> onJsConfirm(String message) {
} }
@ -438,6 +402,7 @@ class InAppBrowser {
/// ///
///[message] represents the message to be displayed in the alert dialog. ///[message] represents the message to be displayed in the alert dialog.
///[defaultValue] represents the default value displayed in the prompt dialog. ///[defaultValue] represents the default value displayed in the prompt dialog.
// ignore: missing_return
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) { Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
} }
@ -450,23 +415,35 @@ class InAppBrowser {
///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat]. ///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat].
/// ///
///**NOTE**: available only for Android. ///**NOTE**: available only for Android.
// ignore: missing_return
Future<SafeBrowsingResponse> onSafeBrowsingHit(String url, SafeBrowsingThreat threatType) { Future<SafeBrowsingResponse> onSafeBrowsingHit(String url, SafeBrowsingThreat threatType) {
} }
///Event fires when a WebView received an HTTP authentication request. The default behavior is to cancel the request. ///Event fires when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the auth challenge. ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [HttpAuthChallenge].
// ignore: missing_return
Future<HttpAuthResponse> onReceivedHttpAuthRequest(HttpAuthChallenge challenge) { Future<HttpAuthResponse> onReceivedHttpAuthRequest(HttpAuthChallenge challenge) {
} }
///Event fires when the WebView need to perform server trust authentication (certificate validation).
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
// ignore: missing_return
Future<ServerTrustAuthResponse> onReceivedServerTrustAuthRequest(ServerTrustChallenge challenge) { Future<ServerTrustAuthResponse> onReceivedServerTrustAuthRequest(ServerTrustChallenge challenge) {
} }
///Notify the host application to handle a SSL client certificate request.
///Webview stores the response in memory (for the life of the application) if [ClientCertResponseAction.PROCEED] or [ClientCertResponseAction.CANCEL]
///is called and does not call [onReceivedClientCertRequest] again for the same host and port pair.
///Note that, multiple layers in chromium network stack might be caching the responses.
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge].
// ignore: missing_return
Future<ClientCertResponse> onReceivedClientCertRequest(ClientCertChallenge challenge) { Future<ClientCertResponse> onReceivedClientCertRequest(ClientCertChallenge challenge) {
} }
@ -483,22 +460,46 @@ class InAppBrowser {
} }
///Event fired when an `XMLHttpRequest` is sent to a server.
///It gives the host application a chance to take control over the request before sending it.
/// ///
///[ajaxRequest] represents the `XMLHttpRequest`.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
// ignore: missing_return
Future<AjaxRequest> shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) { Future<AjaxRequest> shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) {
} }
///Event fired whenever the `readyState` attribute of an `XMLHttpRequest` changes.
///It gives the host application a chance to abort the request.
/// ///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
// ignore: missing_return
Future<AjaxRequestAction> onAjaxReadyStateChange(AjaxRequest ajaxRequest) { Future<AjaxRequestAction> onAjaxReadyStateChange(AjaxRequest ajaxRequest) {
} }
///Event fired as an `XMLHttpRequest` progress.
///It gives the host application a chance to abort the request.
/// ///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
// ignore: missing_return
Future<AjaxRequestAction> onAjaxProgress(AjaxRequest ajaxRequest) { Future<AjaxRequestAction> onAjaxProgress(AjaxRequest ajaxRequest) {
} }
///Event fired when an request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///It gives the host application a chance to take control over the request before sending it.
/// ///
///[fetchRequest] represents a resource request.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptFetchRequest] option to `true`.
// ignore: missing_return
Future<FetchRequest> shouldInterceptFetchRequest(FetchRequest fetchRequest) { Future<FetchRequest> shouldInterceptFetchRequest(FetchRequest fetchRequest) {
} }

View File

@ -21,44 +21,6 @@ const javaScriptHandlerForbiddenNames = ["onLoadResource", "shouldInterceptAjaxR
///InAppWebView Widget class. ///InAppWebView Widget class.
/// ///
///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. ///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree.
///
///All platforms support these options:
/// - __useShouldOverrideUrlLoading__: Set to `true` to be able to listen at the [InAppWebView.shouldOverrideUrlLoading()] event. The default value is `false`.
/// - __useOnLoadResource__: Set to `true` to be able to listen at the [InAppWebView.onLoadResource()] event. The default value is `false`.
/// - __useOnDownloadStart__: Set to `true` to be able to listen at the [InAppWebView.onDownloadStart()] event. The default value is `false`.
/// - __useOnTargetBlank__: Set to `true` to be able to listen at the [InAppWebView.onTargetBlank()] event. The default value is `false`.
/// - __clearCache__: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
/// - __userAgent___: Set the custom WebView's user-agent.
/// - __javaScriptEnabled__: Set to `true` to enable JavaScript. The default value is `true`.
/// - __javaScriptCanOpenWindowsAutomatically__: Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
/// - __mediaPlaybackRequiresUserGesture__: Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
/// - __transparentBackground__: Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
/// - __resourceCustomSchemes__: List of custom schemes that [InAppWebView] must handle. Use the [InAppWebView.onLoadResourceCustomScheme()] event to intercept resource requests with custom scheme.
///
/// **Android** supports these additional options:
///
/// - __clearSessionCache__: Set to `true` to have the session cookie cache cleared before the new window is opened.
/// - __builtInZoomControls__: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
/// - __displayZoomControls__: Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
/// - __supportZoom__: Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
/// - __databaseEnabled__: Set to `true` if you want injectScriptFilethe database storage API is enabled. The default value is `false`.
/// - __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
/// - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
/// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
/// - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
///
/// **iOS** supports these additional options:
///
/// - __disallowOverScroll__: Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
/// - __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
/// - __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
/// - __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
/// - __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
/// - __allowsLinkPreview__: Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
/// - __ignoresViewportScaleLimits__: Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent. The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
/// - __allowsInlineMediaPlayback__: Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
/// - __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
class InAppWebView extends StatefulWidget { class InAppWebView extends StatefulWidget {
///Event fires when the [InAppWebView] is created. ///Event fires when the [InAppWebView] is created.
@ -81,14 +43,12 @@ class InAppWebView extends StatefulWidget {
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. ///Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
/// ///
///**NOTE**: In order to be able to listen this event, you need to set `useShouldOverrideUrlLoading` option to `true`. ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldOverrideUrlLoading] option to `true`.
final void Function(InAppWebViewController controller, String url) shouldOverrideUrlLoading; final void Function(InAppWebViewController controller, String url) shouldOverrideUrlLoading;
///Event fires when the [InAppWebView] loads a resource. ///Event fires when the [InAppWebView] loads a resource.
/// ///
///**NOTE**: In order to be able to listen this event, you need to set `useOnLoadResource` option to `true`. ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnLoadResource] and [InAppWebViewOptions.javaScriptEnabled] options to `true`.
///
///**NOTE only for Android**: to be able to listen this event, you need also the enable javascript.
final void Function(InAppWebViewController controller, LoadedResource resource) onLoadResource; final void Function(InAppWebViewController controller, LoadedResource resource) onLoadResource;
///Event fires when the [InAppWebView] scrolls. ///Event fires when the [InAppWebView] scrolls.
@ -101,6 +61,8 @@ class InAppWebView extends StatefulWidget {
///Event fires when [InAppWebView] recognizes and starts a downloadable file. ///Event fires when [InAppWebView] recognizes and starts a downloadable file.
/// ///
///[url] represents the url of the file. ///[url] represents the url of the file.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnDownloadStart] option to `true`.
final void Function(InAppWebViewController controller, String url) onDownloadStart; final void Function(InAppWebViewController controller, String url) onDownloadStart;
///Event fires when the [InAppWebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`. ///Event fires when the [InAppWebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
@ -113,6 +75,8 @@ class InAppWebView extends StatefulWidget {
///Event fires when the [InAppWebView] tries to open a link with `target="_blank"`. ///Event fires when the [InAppWebView] tries to open a link with `target="_blank"`.
/// ///
///[url] represents the url of the link. ///[url] represents the url of the link.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnTargetBlank] option to `true`.
final void Function(InAppWebViewController controller, String url) onTargetBlank; final void Function(InAppWebViewController controller, String url) onTargetBlank;
///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin. ///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin.
@ -154,15 +118,23 @@ class InAppWebView extends StatefulWidget {
///**NOTE**: available only for Android. ///**NOTE**: available only for Android.
final Future<SafeBrowsingResponse> Function(InAppWebViewController controller, String url, SafeBrowsingThreat threatType) onSafeBrowsingHit; final Future<SafeBrowsingResponse> Function(InAppWebViewController controller, String url, SafeBrowsingThreat threatType) onSafeBrowsingHit;
///Event fires when a WebView received an HTTP authentication request. The default behavior is to cancel the request. ///Event fires when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the auth challenge. ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [HttpAuthChallenge].
final Future<HttpAuthResponse> Function(InAppWebViewController controller, HttpAuthChallenge challenge) onReceivedHttpAuthRequest; final Future<HttpAuthResponse> Function(InAppWebViewController controller, HttpAuthChallenge challenge) onReceivedHttpAuthRequest;
///Event fires when the WebView need to perform server trust authentication (certificate validation).
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
final Future<ServerTrustAuthResponse> Function(InAppWebViewController controller, ServerTrustChallenge challenge) onReceivedServerTrustAuthRequest; final Future<ServerTrustAuthResponse> Function(InAppWebViewController controller, ServerTrustChallenge challenge) onReceivedServerTrustAuthRequest;
///Notify the host application to handle a SSL client certificate request.
///Webview stores the response in memory (for the life of the application) if [ClientCertResponseAction.PROCEED] or [ClientCertResponseAction.CANCEL]
///is called and does not call [onReceivedClientCertRequest] again for the same host and port pair.
///Note that, multiple layers in chromium network stack might be caching the responses.
/// ///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge].
final Future<ClientCertResponse> Function(InAppWebViewController controller, ClientCertChallenge challenge) onReceivedClientCertRequest; final Future<ClientCertResponse> Function(InAppWebViewController controller, ClientCertChallenge challenge) onReceivedClientCertRequest;
///Event fired as find-on-page operations progress. ///Event fired as find-on-page operations progress.
@ -175,16 +147,36 @@ class InAppWebView extends StatefulWidget {
///[isDoneCounting] whether the find operation has actually completed. ///[isDoneCounting] whether the find operation has actually completed.
final void Function(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) onFindResultReceived; final void Function(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) onFindResultReceived;
///Event fired when an `XMLHttpRequest` is sent to a server.
///It gives the host application a chance to take control over the request before sending it.
/// ///
///[ajaxRequest] represents the `XMLHttpRequest`.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
final Future<AjaxRequest> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) shouldInterceptAjaxRequest; final Future<AjaxRequest> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) shouldInterceptAjaxRequest;
///Event fired whenever the `readyState` attribute of an `XMLHttpRequest` changes.
///It gives the host application a chance to abort the request.
/// ///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
final Future<AjaxRequestAction> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) onAjaxReadyStateChange; final Future<AjaxRequestAction> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) onAjaxReadyStateChange;
///Event fired as an `XMLHttpRequest` progress.
///It gives the host application a chance to abort the request.
/// ///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptAjaxRequest] option to `true`.
final Future<AjaxRequestAction> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) onAjaxProgress; final Future<AjaxRequestAction> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) onAjaxProgress;
///Event fired when an request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///It gives the host application a chance to take control over the request before sending it.
/// ///
///[fetchRequest] represents a resource request.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptFetchRequest] option to `true`.
final Future<FetchRequest> Function(InAppWebViewController controller, FetchRequest fetchRequest) shouldInterceptFetchRequest; final Future<FetchRequest> Function(InAppWebViewController controller, FetchRequest fetchRequest) shouldInterceptFetchRequest;
///Event fired when the navigation state of the [InAppWebView] changes throught the usage of ///Event fired when the navigation state of the [InAppWebView] changes throught the usage of
@ -349,6 +341,7 @@ class InAppWebViewController {
InAppWebView _widget; InAppWebView _widget;
MethodChannel _channel; MethodChannel _channel;
Map<String, JavaScriptHandlerCallback> javaScriptHandlersMap = HashMap<String, JavaScriptHandlerCallback>(); Map<String, JavaScriptHandlerCallback> javaScriptHandlersMap = HashMap<String, JavaScriptHandlerCallback>();
// ignore: unused_field
bool _isOpened = false; bool _isOpened = false;
// ignore: unused_field // ignore: unused_field
int _id; int _id;
@ -413,10 +406,11 @@ class InAppWebViewController {
int lineNumber = call.arguments["lineNumber"]; int lineNumber = call.arguments["lineNumber"];
String message = call.arguments["message"]; String message = call.arguments["message"];
ConsoleMessageLevel messageLevel = ConsoleMessageLevel.fromValue(call.arguments["messageLevel"]); ConsoleMessageLevel messageLevel = ConsoleMessageLevel.fromValue(call.arguments["messageLevel"]);
ConsoleMessage consoleMessage = ConsoleMessage(sourceURL: sourceURL, lineNumber: lineNumber, message: message, messageLevel: messageLevel);
if (_widget != null && _widget.onConsoleMessage != null) if (_widget != null && _widget.onConsoleMessage != null)
_widget.onConsoleMessage(this, ConsoleMessage(sourceURL, lineNumber, message, messageLevel)); _widget.onConsoleMessage(this, consoleMessage);
else if (_inAppBrowser != null) else if (_inAppBrowser != null)
_inAppBrowser.onConsoleMessage(ConsoleMessage(sourceURL, lineNumber, message, messageLevel)); _inAppBrowser.onConsoleMessage(consoleMessage);
break; break;
case "onScrollChanged": case "onScrollChanged":
int x = call.arguments["x"]; int x = call.arguments["x"];
@ -567,7 +561,7 @@ class InAppWebViewController {
double startTime = argMap["startTime"] is int ? argMap["startTime"].toDouble() : argMap["startTime"]; double startTime = argMap["startTime"] is int ? argMap["startTime"].toDouble() : argMap["startTime"];
double duration = argMap["duration"] is int ? argMap["duration"].toDouble() : argMap["duration"]; double duration = argMap["duration"] is int ? argMap["duration"].toDouble() : argMap["duration"];
var response = new LoadedResource(initiatorType, url, startTime, duration); var response = new LoadedResource(initiatorType: initiatorType, url: url, startTime: startTime, duration: duration);
if (_widget != null && _widget.onLoadResource != null) if (_widget != null && _widget.onLoadResource != null)
_widget.onLoadResource(this, response); _widget.onLoadResource(this, response);
@ -584,8 +578,9 @@ class InAppWebViewController {
String password = argMap["password"]; String password = argMap["password"];
bool withCredentials = argMap["withCredentials"]; bool withCredentials = argMap["withCredentials"];
Map<dynamic, dynamic> headers = argMap["headers"]; Map<dynamic, dynamic> headers = argMap["headers"];
String responseType = argMap["responseType"];
var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password, withCredentials: withCredentials, headers: headers); var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password, withCredentials: withCredentials, headers: headers, responseType: responseType);
if (_widget != null && _widget.shouldInterceptAjaxRequest != null) if (_widget != null && _widget.shouldInterceptAjaxRequest != null)
return jsonEncode(await _widget.shouldInterceptAjaxRequest(this, request)); return jsonEncode(await _widget.shouldInterceptAjaxRequest(this, request));
@ -606,13 +601,15 @@ class InAppWebViewController {
int status = argMap["status"]; int status = argMap["status"];
String responseURL = argMap["responseURL"]; String responseURL = argMap["responseURL"];
String responseType = argMap["responseType"]; String responseType = argMap["responseType"];
dynamic response = argMap["response"];
String responseText = argMap["responseText"]; String responseText = argMap["responseText"];
String responseXML = argMap["responseXML"];
String statusText = argMap["statusText"]; String statusText = argMap["statusText"];
Map<dynamic, dynamic> responseHeaders = argMap["responseHeaders"]; Map<dynamic, dynamic> responseHeaders = argMap["responseHeaders"];
var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password, var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password,
withCredentials: withCredentials, headers: headers, readyState: AjaxRequestReadyState.fromValue(readyState), status: status, responseURL: responseURL, withCredentials: withCredentials, headers: headers, readyState: AjaxRequestReadyState.fromValue(readyState), status: status, responseURL: responseURL,
responseType: responseType, responseText: responseText, statusText: statusText, responseHeaders: responseHeaders); responseType: responseType, response: response, responseText: responseText, responseXML: responseXML, statusText: statusText, responseHeaders: responseHeaders);
if (_widget != null && _widget.onAjaxReadyStateChange != null) if (_widget != null && _widget.onAjaxReadyStateChange != null)
return jsonEncode(await _widget.onAjaxReadyStateChange(this, request)); return jsonEncode(await _widget.onAjaxReadyStateChange(this, request));
@ -633,16 +630,18 @@ class InAppWebViewController {
int status = argMap["status"]; int status = argMap["status"];
String responseURL = argMap["responseURL"]; String responseURL = argMap["responseURL"];
String responseType = argMap["responseType"]; String responseType = argMap["responseType"];
dynamic response = argMap["response"];
String responseText = argMap["responseText"]; String responseText = argMap["responseText"];
String responseXML = argMap["responseXML"];
String statusText = argMap["statusText"]; String statusText = argMap["statusText"];
Map<dynamic, dynamic> responseHeaders = argMap["responseHeaders"]; Map<dynamic, dynamic> responseHeaders = argMap["responseHeaders"];
Map<dynamic, dynamic> eventMap = argMap["event"]; Map<dynamic, dynamic> eventMap = argMap["event"];
AjaxRequestEvent event = AjaxRequestEvent(lengthComputable: eventMap["lengthComputable"], loaded: eventMap["loaded"], type: AjaxRequestEventType.fromValue(eventMap["type"])); AjaxRequestEvent event = AjaxRequestEvent(lengthComputable: eventMap["lengthComputable"], loaded: eventMap["loaded"], total: eventMap["total"], type: AjaxRequestEventType.fromValue(eventMap["type"]));
var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password, var request = new AjaxRequest(data: data, method: method, url: url, isAsync: isAsync, user: user, password: password,
withCredentials: withCredentials, headers: headers, readyState: AjaxRequestReadyState.fromValue(readyState), status: status, responseURL: responseURL, withCredentials: withCredentials, headers: headers, readyState: AjaxRequestReadyState.fromValue(readyState), status: status, responseURL: responseURL,
responseType: responseType, responseText: responseText, statusText: statusText, responseHeaders: responseHeaders, event: event); responseType: responseType, response: response, responseText: responseText, responseXML: responseXML, statusText: statusText, responseHeaders: responseHeaders, event: event);
if (_widget != null && _widget.onAjaxProgress != null) if (_widget != null && _widget.onAjaxProgress != null)
return jsonEncode(await _widget.onAjaxProgress(this, request)); return jsonEncode(await _widget.onAjaxProgress(this, request));
@ -728,7 +727,7 @@ class InAppWebViewController {
var html = ""; var html = "";
InAppWebViewWidgetOptions options = await getOptions(); InAppWebViewWidgetOptions options = await getOptions();
if (options != null && options.inAppWebViewOptions.javaScriptEnabled == true) { if (options != null && options.inAppWebViewOptions.javaScriptEnabled == true) {
html = await evaluateJavascript("window.document.getElementsByTagName('html')[0].outerHTML;"); html = await evaluateJavascript(source: "window.document.getElementsByTagName('html')[0].outerHTML;");
if (html.isNotEmpty) if (html.isNotEmpty)
return html; return html;
} }
@ -863,7 +862,7 @@ class InAppWebViewController {
} }
///Loads the given [url] with optional [headers] specified as a map from name to value. ///Loads the given [url] with optional [headers] specified as a map from name to value.
Future<void> loadUrl(String url, {Map<String, String> headers = const {}}) async { Future<void> loadUrl({@required String url, Map<String, String> headers = const {}}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -876,7 +875,7 @@ class InAppWebViewController {
} }
///Loads the given [url] with [postData] using `POST` method into this WebView. ///Loads the given [url] with [postData] using `POST` method into this WebView.
Future<void> postUrl(String url, Uint8List postData) async { Future<void> postUrl({@required String url, @required Uint8List postData}) async {
assert(url != null && url.isNotEmpty); assert(url != null && url.isNotEmpty);
assert(postData != null); assert(postData != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -892,7 +891,7 @@ class InAppWebViewController {
///Loads the given [data] into this WebView, using [baseUrl] as the base URL for the content. ///Loads the given [data] into this WebView, using [baseUrl] as the base URL for the content.
///The [mimeType] parameter specifies the format of the data. ///The [mimeType] parameter specifies the format of the data.
///The [encoding] parameter specifies the encoding of the data. ///The [encoding] parameter specifies the encoding of the data.
Future<void> loadData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"}) async { Future<void> loadData({@required String data, String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"}) async {
assert(data != null); assert(data != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -935,7 +934,7 @@ class InAppWebViewController {
///inAppBrowser.loadFile("assets/t-rex.html"); ///inAppBrowser.loadFile("assets/t-rex.html");
///... ///...
///``` ///```
Future<void> loadFile(String assetFilePath, {Map<String, String> headers = const {}}) async { Future<void> loadFile({@required String assetFilePath, Map<String, String> headers = const {}}) async {
assert(assetFilePath != null && assetFilePath.isNotEmpty); assert(assetFilePath != null && assetFilePath.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -998,7 +997,7 @@ class InAppWebViewController {
} }
///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward. ///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
Future<void> goBackOrForward(int steps) async { Future<void> goBackOrForward({@required int steps}) async {
assert(steps != null); assert(steps != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -1010,8 +1009,8 @@ class InAppWebViewController {
await _channel.invokeMethod('goBackOrForward', args); await _channel.invokeMethod('goBackOrForward', args);
} }
///Returns a boolean value indicating whether the [InAppWebView] can go back or forward the given number of steps. Steps is negative if backward and positive if forward. ///Returns a boolean value indicating whether the WebView can go back or forward the given number of steps. Steps is negative if backward and positive if forward.
Future<bool> canGoBackOrForward(int steps) async { Future<bool> canGoBackOrForward({@required int steps}) async {
assert(steps != null); assert(steps != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -1024,11 +1023,11 @@ class InAppWebViewController {
} }
///Navigates to a [WebHistoryItem] from the back-forward [WebHistory.list] and sets it as the current item. ///Navigates to a [WebHistoryItem] from the back-forward [WebHistory.list] and sets it as the current item.
Future<void> goTo(WebHistoryItem historyItem) async { Future<void> goTo({@required WebHistoryItem historyItem}) async {
await goBackOrForward(historyItem.offset); await goBackOrForward(steps: historyItem.offset);
} }
///Check if the Web View of the [InAppWebView] instance is in a loading state. ///Check if the WebView instance is in a loading state.
Future<bool> isLoading() async { Future<bool> isLoading() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -1038,7 +1037,7 @@ class InAppWebViewController {
return await _channel.invokeMethod('isLoading', args); return await _channel.invokeMethod('isLoading', args);
} }
///Stops the Web View of the [InAppWebView] instance from loading. ///Stops the WebView from loading.
Future<void> stopLoading() async { Future<void> stopLoading() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -1048,8 +1047,8 @@ class InAppWebViewController {
await _channel.invokeMethod('stopLoading', args); await _channel.invokeMethod('stopLoading', args);
} }
///Evaluates JavaScript code into the [InAppWebView] and returns the result of the evaluation. ///Evaluates JavaScript code into the WebView and returns the result of the evaluation.
Future<String> evaluateJavascript(String source) async { Future<String> evaluateJavascript({@required String source}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
_inAppBrowser.throwIsNotOpened(); _inAppBrowser.throwIsNotOpened();
@ -1059,8 +1058,8 @@ class InAppWebViewController {
return await _channel.invokeMethod('evaluateJavascript', args); return await _channel.invokeMethod('evaluateJavascript', args);
} }
///Injects an external JavaScript file into the [InAppWebView] from a defined url. ///Injects an external JavaScript file into the WebView from a defined url.
Future<void> injectJavascriptFileFromUrl(String urlFile) async { Future<void> injectJavascriptFileFromUrl({@required String urlFile}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
_inAppBrowser.throwIsNotOpened(); _inAppBrowser.throwIsNotOpened();
@ -1070,14 +1069,14 @@ class InAppWebViewController {
await _channel.invokeMethod('injectJavascriptFileFromUrl', args); await _channel.invokeMethod('injectJavascriptFileFromUrl', args);
} }
///Injects a JavaScript file into the [InAppWebView] from the flutter assets directory. ///Injects a JavaScript file into the WebView from the flutter assets directory.
Future<void> injectJavascriptFileFromAsset(String assetFilePath) async { Future<void> injectJavascriptFileFromAsset({@required String assetFilePath}) async {
String source = await rootBundle.loadString(assetFilePath); String source = await rootBundle.loadString(assetFilePath);
await evaluateJavascript(source); await evaluateJavascript(source: source);
} }
///Injects CSS into the [InAppWebView]. ///Injects CSS into the WebView.
Future<void> injectCSSCode(String source) async { Future<void> injectCSSCode({@required String source}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
_inAppBrowser.throwIsNotOpened(); _inAppBrowser.throwIsNotOpened();
@ -1087,8 +1086,8 @@ class InAppWebViewController {
await _channel.invokeMethod('injectCSSCode', args); await _channel.invokeMethod('injectCSSCode', args);
} }
///Injects an external CSS file into the [InAppWebView] from a defined url. ///Injects an external CSS file into the WebView from a defined url.
Future<void> injectCSSFileFromUrl(String urlFile) async { Future<void> injectCSSFileFromUrl({@required String urlFile}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
_inAppBrowser.throwIsNotOpened(); _inAppBrowser.throwIsNotOpened();
@ -1098,10 +1097,10 @@ class InAppWebViewController {
await _channel.invokeMethod('injectStyleFile', args); await _channel.invokeMethod('injectStyleFile', args);
} }
///Injects a CSS file into the [InAppWebView] from the flutter assets directory. ///Injects a CSS file into the WebView from the flutter assets directory.
Future<void> injectCSSFileFromAsset(String assetFilePath) async { Future<void> injectCSSFileFromAsset({@required String assetFilePath}) async {
String source = await rootBundle.loadString(assetFilePath); String source = await rootBundle.loadString(assetFilePath);
await injectCSSCode(source); await injectCSSCode(source: source);
} }
///Adds a JavaScript message handler [callback] ([JavaScriptHandlerCallback]) that listen to post messages sent from JavaScript by the handler with name [handlerName]. ///Adds a JavaScript message handler [callback] ([JavaScriptHandlerCallback]) that listen to post messages sent from JavaScript by the handler with name [handlerName].
@ -1112,14 +1111,6 @@ class InAppWebViewController {
///The JavaScript function that can be used to call the handler is `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)`, where `args` are [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). ///The JavaScript function that can be used to call the handler is `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)`, where `args` are [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
///The `args` will be stringified automatically using `JSON.stringify(args)` method and then they will be decoded on the Dart side. ///The `args` will be stringified automatically using `JSON.stringify(args)` method and then they will be decoded on the Dart side.
/// ///
///In order to call `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)` properly, you need to wait and listen the JavaScript event `flutterInAppBrowserPlatformReady`.
///This event will be dispatch as soon as the platform (Android or iOS) is ready to handle the `callHandler` method.
///```javascript
/// window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
/// console.log("ready");
/// });
///```
///
///`window.flutter_inappbrowser.callHandler` returns a JavaScript [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) ///`window.flutter_inappbrowser.callHandler` returns a JavaScript [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
///that can be used to get the json result returned by [JavaScriptHandlerCallback]. ///that can be used to get the json result returned by [JavaScriptHandlerCallback].
///In this case, simply return data that you want to send and it will be automatically json encoded using [jsonEncode] from the `dart:convert` library. ///In this case, simply return data that you want to send and it will be automatically json encoded using [jsonEncode] from the `dart:convert` library.
@ -1127,7 +1118,6 @@ class InAppWebViewController {
///So, on the JavaScript side, to get data coming from the Dart side, you will use: ///So, on the JavaScript side, to get data coming from the Dart side, you will use:
///```html ///```html
///<script> ///<script>
/// window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
/// window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) { /// window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
/// console.log(result, typeof result); /// console.log(result, typeof result);
/// console.log(JSON.stringify(result)); /// console.log(JSON.stringify(result));
@ -1137,20 +1127,9 @@ class InAppWebViewController {
/// console.log(result, typeof result); /// console.log(result, typeof result);
/// console.log(JSON.stringify(result)); /// console.log(JSON.stringify(result));
/// }); /// });
/// });
///</script> ///</script>
///``` ///```
/// void addJavaScriptHandler({@required String handlerName, @required JavaScriptHandlerCallback callback}) {
///Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
///```dart
/// // Inject JavaScript that will receive data back from Flutter
/// inAppWebViewController.injectScriptCode("""
/// window.flutter_inappbrowser.callHandler('test', 'Text from Javascript').then(function(result) {
/// console.log(result);
/// });
/// """);
///```
void addJavaScriptHandler(String handlerName, JavaScriptHandlerCallback callback) {
assert(!javaScriptHandlerForbiddenNames.contains(handlerName)); assert(!javaScriptHandlerForbiddenNames.contains(handlerName));
this.javaScriptHandlersMap[handlerName] = (callback); this.javaScriptHandlersMap[handlerName] = (callback);
} }
@ -1158,7 +1137,7 @@ class InAppWebViewController {
///Removes a JavaScript message handler previously added with the [addJavaScriptHandler()] associated to [handlerName] key. ///Removes a JavaScript message handler previously added with the [addJavaScriptHandler()] associated to [handlerName] key.
///Returns the value associated with [handlerName] before it was removed. ///Returns the value associated with [handlerName] before it was removed.
///Returns `null` if [handlerName] was not found. ///Returns `null` if [handlerName] was not found.
JavaScriptHandlerCallback removeJavaScriptHandler(String handlerName) { JavaScriptHandlerCallback removeJavaScriptHandler({@required String handlerName}) {
return this.javaScriptHandlersMap.remove(handlerName); return this.javaScriptHandlersMap.remove(handlerName);
} }
@ -1174,8 +1153,8 @@ class InAppWebViewController {
return await _channel.invokeMethod('takeScreenshot', args); return await _channel.invokeMethod('takeScreenshot', args);
} }
///Sets the [InAppWebView] options with the new [options] and evaluates them. ///Sets the WebView options with the new [options] and evaluates them.
Future<void> setOptions(InAppWebViewWidgetOptions options) async { Future<void> setOptions({@required InAppWebViewWidgetOptions options}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
_inAppBrowser.throwIsNotOpened(); _inAppBrowser.throwIsNotOpened();
@ -1193,7 +1172,7 @@ class InAppWebViewController {
await _channel.invokeMethod('setOptions', args); await _channel.invokeMethod('setOptions', args);
} }
///Gets the current [InAppWebView] options. Returns the options with `null` value if they are not set yet. ///Gets the current WebView options. Returns the options with `null` value if they are not set yet.
Future<InAppWebViewWidgetOptions> getOptions() async { Future<InAppWebViewWidgetOptions> getOptions() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -1236,9 +1215,9 @@ class InAppWebViewController {
List<WebHistoryItem> historyList = List(); List<WebHistoryItem> historyList = List();
for(var i = 0; i < historyListMap.length; i++) { for(var i = 0; i < historyListMap.length; i++) {
LinkedHashMap<dynamic, dynamic> historyItem = historyListMap[i]; LinkedHashMap<dynamic, dynamic> historyItem = historyListMap[i];
historyList.add(WebHistoryItem(historyItem["originalUrl"], historyItem["title"], historyItem["url"], i, i - currentIndex)); historyList.add(WebHistoryItem(originalUrl: historyItem["originalUrl"], title: historyItem["title"], url: historyItem["url"], index: i, offset: i - currentIndex));
} }
return WebHistory(historyList, currentIndex); return WebHistory(list: historyList, currentIndex: currentIndex);
} }
///Starts Safe Browsing initialization. ///Starts Safe Browsing initialization.
@ -1274,7 +1253,7 @@ class InAppWebViewController {
///[hosts] represents the list of hosts. This value must never be null. ///[hosts] represents the list of hosts. This value must never be null.
/// ///
///**NOTE**: available only for Android. ///**NOTE**: available only for Android.
Future<bool> setSafeBrowsingWhitelist(List<String> hosts) async { Future<bool> setSafeBrowsingWhitelist({@required List<String> hosts}) async {
assert(hosts != null); assert(hosts != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -1342,7 +1321,7 @@ class InAppWebViewController {
///**NOTE**: on Android, it finds all instances asynchronously. Successive calls to this will cancel any pending searches. ///**NOTE**: on Android, it finds all instances asynchronously. Successive calls to this will cancel any pending searches.
/// ///
///**NOTE**: on iOS, this is implemented using CSS and Javascript. ///**NOTE**: on iOS, this is implemented using CSS and Javascript.
Future<void> findAllAsync(String find) async { Future<void> findAllAsync({@required String find}) async {
assert(find != null); assert(find != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {
@ -1358,7 +1337,7 @@ class InAppWebViewController {
///[forward] represents the direction to search. ///[forward] represents the direction to search.
/// ///
///**NOTE**: on iOS, this is implemented using CSS and Javascript. ///**NOTE**: on iOS, this is implemented using CSS and Javascript.
Future<void> findNext(bool forward) async { Future<void> findNext({@required bool forward}) async {
assert(forward != null); assert(forward != null);
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) { if (_inAppBrowserUuid != null && _inAppBrowser != null) {

View File

@ -3,7 +3,7 @@ import 'dart:typed_data';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart';
import 'webview_options.dart'; import 'webview_options.dart';
@ -54,7 +54,7 @@ class LoadedResource {
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource. ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource.
double duration; double duration;
LoadedResource(this.initiatorType, this.url, this.startTime, this.duration); LoadedResource({this.initiatorType, this.url, this.startTime, this.duration});
} }
@ -67,7 +67,7 @@ class InAppWebViewInitialData {
String encoding; String encoding;
String baseUrl; String baseUrl;
InAppWebViewInitialData(this.data, {this.mimeType = "text/html", this.encoding = "utf8", this.baseUrl = "about:blank"}); InAppWebViewInitialData({@required this.data, this.mimeType = "text/html", this.encoding = "utf8", this.baseUrl = "about:blank"});
Map<String, String> toMap() { Map<String, String> toMap() {
return { return {
@ -120,7 +120,7 @@ class CustomSchemeResponse {
///Content-Enconding of the data, such as `utf-8`. ///Content-Enconding of the data, such as `utf-8`.
String contentEnconding; String contentEnconding;
CustomSchemeResponse(this.data, this.contentType, {this.contentEnconding = 'utf-8'}); CustomSchemeResponse({@required this.data, @required this.contentType, this.contentEnconding = 'utf-8'});
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {
@ -134,28 +134,27 @@ class CustomSchemeResponse {
///Public class representing a JavaScript console message from WebCore. ///Public class representing a JavaScript console message from WebCore.
///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page. ///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page.
/// ///
///To receive notifications of these messages, override the [InAppBrowser.onConsoleMessage()] function. ///To receive notifications of these messages, use the [onConsoleMessage] event.
class ConsoleMessage { class ConsoleMessage {
String sourceURL = ""; String sourceURL;
int lineNumber = 1; int lineNumber;
String message = ""; String message;
ConsoleMessageLevel messageLevel = ConsoleMessageLevel.LOG; ConsoleMessageLevel messageLevel;
ConsoleMessage(this.sourceURL, this.lineNumber, this.message, this.messageLevel); ConsoleMessage({this.sourceURL = "", this.lineNumber = 1, this.message = "", this.messageLevel = ConsoleMessageLevel.LOG});
} }
///WebHistory class. ///WebHistory class.
/// ///
///This class contains a snapshot of the current back/forward list for a WebView. ///This class contains a snapshot of the current back/forward list for a WebView.
class WebHistory { class WebHistory {
List<WebHistoryItem> _list;
///List of all [WebHistoryItem]s. ///List of all [WebHistoryItem]s.
List<WebHistoryItem> get list => _list; List<WebHistoryItem> list;
///Index of the current [WebHistoryItem]. ///Index of the current [WebHistoryItem].
int currentIndex; int currentIndex;
WebHistory(this._list, this.currentIndex); WebHistory({this.list, this.currentIndex});
} }
///WebHistoryItem class. ///WebHistoryItem class.
@ -173,7 +172,7 @@ class WebHistoryItem {
///Position offset respect to the currentIndex of the back-forward [WebHistory.list]. ///Position offset respect to the currentIndex of the back-forward [WebHistory.list].
int offset; int offset;
WebHistoryItem(this.originalUrl, this.title, this.url, this.index, this.offset); WebHistoryItem({this.originalUrl, this.title, this.url, this.index, this.offset});
} }
///GeolocationPermissionPromptResponse class. ///GeolocationPermissionPromptResponse class.
@ -187,7 +186,7 @@ class GeolocationPermissionShowPromptResponse {
///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView ///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView
bool retain; bool retain;
GeolocationPermissionShowPromptResponse(this.origin, this.allow, this.retain); GeolocationPermissionShowPromptResponse({this.origin, this.allow, this.retain});
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
@ -198,7 +197,7 @@ class GeolocationPermissionShowPromptResponse {
} }
} }
/// ///JsAlertResponseAction class used by [JsAlertResponse] class.
class JsAlertResponseAction { class JsAlertResponseAction {
final int _value; final int _value;
const JsAlertResponseAction._internal(this._value); const JsAlertResponseAction._internal(this._value);
@ -207,11 +206,15 @@ class JsAlertResponseAction {
static const CONFIRM = const JsAlertResponseAction._internal(0); static const CONFIRM = const JsAlertResponseAction._internal(0);
} }
/// ///JsAlertResponse class represents the response used by the [onJsAlert] event to control a JavaScript alert dialog.
class JsAlertResponse { class JsAlertResponse {
///Message to be displayed in the window.
String message; String message;
///Title of the confirm button.
String confirmButtonTitle; String confirmButtonTitle;
///Whether the client will handle the alert dialog.
bool handledByClient; bool handledByClient;
///Action used to confirm that the user hit confirm button.
JsAlertResponseAction action; JsAlertResponseAction action;
JsAlertResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.action = JsAlertResponseAction.CONFIRM}); JsAlertResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.action = JsAlertResponseAction.CONFIRM});
@ -226,7 +229,7 @@ class JsAlertResponse {
} }
} }
/// ///JsConfirmResponseAction class used by [JsConfirmResponse] class.
class JsConfirmResponseAction { class JsConfirmResponseAction {
final int _value; final int _value;
const JsConfirmResponseAction._internal(this._value); const JsConfirmResponseAction._internal(this._value);
@ -236,12 +239,17 @@ class JsConfirmResponseAction {
static const CANCEL = const JsConfirmResponseAction._internal(1); static const CANCEL = const JsConfirmResponseAction._internal(1);
} }
/// ///JsConfirmResponse class represents the response used by the [onJsConfirm] event to control a JavaScript confirm dialog.
class JsConfirmResponse { class JsConfirmResponse {
///Message to be displayed in the window.
String message; String message;
///Title of the confirm button.
String confirmButtonTitle; String confirmButtonTitle;
///Title of the cancel button.
String cancelButtonTitle; String cancelButtonTitle;
///Whether the client will handle the confirm dialog.
bool handledByClient; bool handledByClient;
///Action used to confirm that the user hit confirm or cancel button.
JsConfirmResponseAction action; JsConfirmResponseAction action;
JsConfirmResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.action = JsConfirmResponseAction.CANCEL}); JsConfirmResponse({this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.action = JsConfirmResponseAction.CANCEL});
@ -257,7 +265,7 @@ class JsConfirmResponse {
} }
} }
/// ///JsPromptResponseAction class used by [JsPromptResponse] class.
class JsPromptResponseAction { class JsPromptResponseAction {
final int _value; final int _value;
const JsPromptResponseAction._internal(this._value); const JsPromptResponseAction._internal(this._value);
@ -267,14 +275,21 @@ class JsPromptResponseAction {
static const CANCEL = const JsPromptResponseAction._internal(1); static const CANCEL = const JsPromptResponseAction._internal(1);
} }
/// ///JsPromptResponse class represents the response used by the [onJsPrompt] event to control a JavaScript prompt dialog.
class JsPromptResponse { class JsPromptResponse {
///Message to be displayed in the window.
String message; String message;
///The default value displayed in the prompt dialog.
String defaultValue; String defaultValue;
///Title of the confirm button.
String confirmButtonTitle; String confirmButtonTitle;
///Title of the cancel button.
String cancelButtonTitle; String cancelButtonTitle;
///Whether the client will handle the prompt dialog.
bool handledByClient; bool handledByClient;
///Value of the prompt dialog.
String value; String value;
///Action used to confirm that the user hit confirm or cancel button.
JsPromptResponseAction action; JsPromptResponseAction action;
JsPromptResponse({this.message = "", this.defaultValue = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.value, this.action = JsPromptResponseAction.CANCEL}); JsPromptResponse({this.message = "", this.defaultValue = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.value, this.action = JsPromptResponseAction.CANCEL});
@ -292,7 +307,7 @@ class JsPromptResponse {
} }
} }
/// ///SafeBrowsingThreat class represents the reason the resource was caught by Safe Browsing.
class SafeBrowsingThreat { class SafeBrowsingThreat {
final int _value; final int _value;
const SafeBrowsingThreat._internal(this._value); const SafeBrowsingThreat._internal(this._value);
@ -310,20 +325,26 @@ class SafeBrowsingThreat {
static const SAFE_BROWSING_THREAT_BILLING = const SafeBrowsingThreat._internal(4); static const SAFE_BROWSING_THREAT_BILLING = const SafeBrowsingThreat._internal(4);
} }
/// ///SafeBrowsingResponseAction class used by [SafeBrowsingResponse] class.
class SafeBrowsingResponseAction { class SafeBrowsingResponseAction {
final int _value; final int _value;
const SafeBrowsingResponseAction._internal(this._value); const SafeBrowsingResponseAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Act as if the user clicked the "back to safety" button.
static const BACK_TO_SAFETY = const SafeBrowsingResponseAction._internal(0); static const BACK_TO_SAFETY = const SafeBrowsingResponseAction._internal(0);
///Act as if the user clicked the "visit this unsafe site" button.
static const PROCEED = const SafeBrowsingResponseAction._internal(1); static const PROCEED = const SafeBrowsingResponseAction._internal(1);
///Display the default interstitial.
static const SHOW_INTERSTITIAL = const SafeBrowsingResponseAction._internal(2); static const SHOW_INTERSTITIAL = const SafeBrowsingResponseAction._internal(2);
} }
/// ///SafeBrowsingResponse class represents the response used by the [onSafeBrowsingHit] event.
///It is used to indicate an action to take when hitting a malicious URL.
class SafeBrowsingResponse { class SafeBrowsingResponse {
///If reporting is enabled, all reports will be sent according to the privacy policy referenced by [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl].
bool report; bool report;
///Indicate the [SafeBrowsingResponseAction] to take when hitting a malicious URL.
SafeBrowsingResponseAction action; SafeBrowsingResponseAction action;
SafeBrowsingResponse({this.report = true, this.action = SafeBrowsingResponseAction.SHOW_INTERSTITIAL}); SafeBrowsingResponse({this.report = true, this.action = SafeBrowsingResponseAction.SHOW_INTERSTITIAL});
@ -336,22 +357,29 @@ class SafeBrowsingResponse {
} }
} }
/// ///HttpAuthResponseAction class used by [HttpAuthResponse] class.
class HttpAuthResponseAction { class HttpAuthResponseAction {
final int _value; final int _value;
const HttpAuthResponseAction._internal(this._value); const HttpAuthResponseAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Instructs the WebView to cancel the authentication request.
static const CANCEL = const HttpAuthResponseAction._internal(0); static const CANCEL = const HttpAuthResponseAction._internal(0);
///Instructs the WebView to proceed with the authentication with the given credentials.
static const PROCEED = const HttpAuthResponseAction._internal(1); static const PROCEED = const HttpAuthResponseAction._internal(1);
///Uses the credentials stored for the current host.
static const USE_SAVED_HTTP_AUTH_CREDENTIALS = const HttpAuthResponseAction._internal(2); static const USE_SAVED_HTTP_AUTH_CREDENTIALS = const HttpAuthResponseAction._internal(2);
} }
/// ///HttpAuthResponse class represents the response used by the [onReceivedHttpAuthRequest] event.
class HttpAuthResponse { class HttpAuthResponse {
///Represents the username used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED]
String username; String username;
///Represents the password used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED]
String password; String password;
///Indicate if the given credentials need to be saved permanently.
bool permanentPersistence; bool permanentPersistence;
///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge.
HttpAuthResponseAction action; HttpAuthResponseAction action;
HttpAuthResponse({this.username = "", this.password = "", this.permanentPersistence = false, this.action = HttpAuthResponseAction.CANCEL}); HttpAuthResponse({this.username = "", this.password = "", this.permanentPersistence = false, this.action = HttpAuthResponseAction.CANCEL});
@ -366,44 +394,59 @@ class HttpAuthResponse {
} }
} }
/// ///HttpAuthChallenge class represents the challenge of the [onReceivedHttpAuthRequest] event.
///It provides all the information about the challenge.
class HttpAuthChallenge { class HttpAuthChallenge {
///A count of previous failed authentication attempts.
int previousFailureCount; int previousFailureCount;
///The protection space requiring authentication.
ProtectionSpace protectionSpace; ProtectionSpace protectionSpace;
HttpAuthChallenge({@required this.previousFailureCount, @required this.protectionSpace}): assert(previousFailureCount != null && protectionSpace != null); HttpAuthChallenge({@required this.previousFailureCount, @required this.protectionSpace}): assert(previousFailureCount != null && protectionSpace != null);
} }
/// ///ProtectionSpace class represents a protection space requiring authentication.
class ProtectionSpace { class ProtectionSpace {
///The hostname of the server.
String host; String host;
///The protocol of the server - e.g. "http", "ftp", "https".
String protocol; String protocol;
///A string indicating a protocol-specific subdivision of a single host.
///For http and https, this maps to the realm string in http authentication challenges.
///For many other protocols it is unused.
String realm; String realm;
///The port of the server.
int port; int port;
ProtectionSpace({@required this.host, @required this.protocol, this.realm, this.port}): assert(host != null && protocol != null); ProtectionSpace({@required this.host, @required this.protocol, this.realm, this.port}): assert(host != null && protocol != null);
} }
/// ///HttpAuthCredential represents the credentials of an http authentication.
///It is used by the [HttpAuthCredentialDatabase] class.
class HttpAuthCredential { class HttpAuthCredential {
///Represents the username.
String username; String username;
///Represents the password.
String password; String password;
HttpAuthCredential({@required this.username, @required this.password}): assert(username != null && password != null); HttpAuthCredential({@required this.username, @required this.password}): assert(username != null && password != null);
} }
/// ///ServerTrustAuthResponseAction class used by [ServerTrustAuthResponse] class.
class ServerTrustAuthResponseAction { class ServerTrustAuthResponseAction {
final int _value; final int _value;
const ServerTrustAuthResponseAction._internal(this._value); const ServerTrustAuthResponseAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Instructs the WebView to cancel the authentication challenge.
static const CANCEL = const ServerTrustAuthResponseAction._internal(0); static const CANCEL = const ServerTrustAuthResponseAction._internal(0);
///Instructs the WebView to proceed with the authentication challenge.
static const PROCEED = const ServerTrustAuthResponseAction._internal(1); static const PROCEED = const ServerTrustAuthResponseAction._internal(1);
} }
/// ///ServerTrustAuthResponse class represents the response used by the [onReceivedServerTrustAuthRequest] event.
class ServerTrustAuthResponse { class ServerTrustAuthResponse {
///Indicate the [ServerTrustAuthResponseAction] to take in response of the server trust authentication challenge.
ServerTrustAuthResponseAction action; ServerTrustAuthResponseAction action;
ServerTrustAuthResponse({this.action = ServerTrustAuthResponseAction.CANCEL}); ServerTrustAuthResponse({this.action = ServerTrustAuthResponseAction.CANCEL});
@ -415,32 +458,48 @@ class ServerTrustAuthResponse {
} }
} }
/// ///ServerTrustChallenge class represents the challenge of the [onReceivedServerTrustAuthRequest] event.
///It provides all the information about the challenge.
class ServerTrustChallenge { class ServerTrustChallenge {
///The protection space requiring authentication.
ProtectionSpace protectionSpace; ProtectionSpace protectionSpace;
///The primary error associated to the server SSL certificate.
///
///**NOTE**: on iOS this value is always -1.
int error; int error;
///The message associated to the [error].
///
///**NOTE**: on iOS this value is always an empty string.
String message; String message;
///The `X509Certificate` used to create the server SSL certificate.
Uint8List serverCertificate; Uint8List serverCertificate;
ServerTrustChallenge({@required this.protectionSpace, @required this.error, this.message, this.serverCertificate}): assert(protectionSpace != null && error != null); ServerTrustChallenge({@required this.protectionSpace, @required this.error, this.message, this.serverCertificate}): assert(protectionSpace != null && error != null);
} }
/// ///ClientCertResponseAction class used by [ClientCertResponse] class.
class ClientCertResponseAction { class ClientCertResponseAction {
final int _value; final int _value;
const ClientCertResponseAction._internal(this._value); const ClientCertResponseAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Cancel this request.
static const CANCEL = const ClientCertResponseAction._internal(0); static const CANCEL = const ClientCertResponseAction._internal(0);
///Proceed with the specified certificate.
static const PROCEED = const ClientCertResponseAction._internal(1); static const PROCEED = const ClientCertResponseAction._internal(1);
///Ignore the request for now.
static const IGNORE = const ClientCertResponseAction._internal(2); static const IGNORE = const ClientCertResponseAction._internal(2);
} }
/// ///ClientCertResponse class represents the response used by the [onReceivedClientCertRequest] event.
class ClientCertResponse { class ClientCertResponse {
///The file path of the certificate to use.
String certificatePath; String certificatePath;
///The certificate password.
String certificatePassword; String certificatePassword;
///An Android-specific property used by Java [KeyStore](https://developer.android.com/reference/java/security/KeyStore) class to get the instance.
String androidKeyStoreType; String androidKeyStoreType;
///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge.
ClientCertResponseAction action; ClientCertResponseAction action;
ClientCertResponse({this.certificatePath, this.certificatePassword = "", this.androidKeyStoreType = "PKCS12", this.action = ClientCertResponseAction.CANCEL}) { ClientCertResponse({this.certificatePath, this.certificatePassword = "", this.androidKeyStoreType = "PKCS12", this.action = ClientCertResponseAction.CANCEL}) {
@ -458,18 +517,24 @@ class ClientCertResponse {
} }
} }
/// ///ClientCertChallenge class represents the challenge of the [onReceivedClientCertRequest] event.
///It provides all the information about the challenge.
class ClientCertChallenge { class ClientCertChallenge {
///The protection space requiring authentication.
ProtectionSpace protectionSpace; ProtectionSpace protectionSpace;
ClientCertChallenge({@required this.protectionSpace}): assert(protectionSpace != null); ClientCertChallenge({@required this.protectionSpace}): assert(protectionSpace != null);
} }
/// ///Favicon class represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method.
class Favicon { class Favicon {
///The url of the favicon image.
String url; String url;
///The relationship between the current web page and the favicon image.
String rel; String rel;
///The width of the favicon image.
int width; int width;
///The height of the favicon image.
int height; int height;
Favicon({@required this.url, this.rel, this.width, this.height}): assert(url != null); Favicon({@required this.url, this.rel, this.width, this.height}): assert(url != null);
@ -479,7 +544,7 @@ class Favicon {
} }
} }
/// ///AndroidInAppWebViewCacheMode class represents an Android-specific class used to override the way the cache is used.
class AndroidInAppWebViewCacheMode { class AndroidInAppWebViewCacheMode {
final int _value; final int _value;
const AndroidInAppWebViewCacheMode._internal(this._value); const AndroidInAppWebViewCacheMode._internal(this._value);
@ -490,30 +555,43 @@ class AndroidInAppWebViewCacheMode {
} }
toValue() => _value; toValue() => _value;
///Default cache usage mode. If the navigation type doesn't impose any specific behavior,
///use cached resources when they are available and not expired, otherwise load resources from the network.
static const LOAD_DEFAULT = const AndroidInAppWebViewCacheMode._internal(-1); static const LOAD_DEFAULT = const AndroidInAppWebViewCacheMode._internal(-1);
///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network.
static const LOAD_CACHE_ELSE_NETWORK = const AndroidInAppWebViewCacheMode._internal(1); static const LOAD_CACHE_ELSE_NETWORK = const AndroidInAppWebViewCacheMode._internal(1);
///Don't use the cache, load from the network.
static const LOAD_NO_CACHE = const AndroidInAppWebViewCacheMode._internal(2); static const LOAD_NO_CACHE = const AndroidInAppWebViewCacheMode._internal(2);
///Don't use the network, load from the cache.
static const LOAD_CACHE_ONLY = const AndroidInAppWebViewCacheMode._internal(3); static const LOAD_CACHE_ONLY = const AndroidInAppWebViewCacheMode._internal(3);
} }
///AndroidInAppWebViewModeMenuItem class represents an Android-specific class used to disable the action mode menu items.
/// ///
///**NOTE**: available on Android 24+.
class AndroidInAppWebViewModeMenuItem { class AndroidInAppWebViewModeMenuItem {
final int _value; final int _value;
const AndroidInAppWebViewModeMenuItem._internal(this._value); const AndroidInAppWebViewModeMenuItem._internal(this._value);
static AndroidInAppWebViewModeMenuItem fromValue(int value) { static AndroidInAppWebViewModeMenuItem fromValue(int value) {
if (value != null && value >= 0 && value <= 4) if (value != null && value != 3 && value >= 0 && value <= 4)
return AndroidInAppWebViewModeMenuItem._internal(value); return AndroidInAppWebViewModeMenuItem._internal(value);
return null; return null;
} }
toValue() => _value; toValue() => _value;
///No menu items should be disabled.
static const MENU_ITEM_NONE = const AndroidInAppWebViewModeMenuItem._internal(0); static const MENU_ITEM_NONE = const AndroidInAppWebViewModeMenuItem._internal(0);
///Disable menu item "Share".
static const MENU_ITEM_SHARE = const AndroidInAppWebViewModeMenuItem._internal(1); static const MENU_ITEM_SHARE = const AndroidInAppWebViewModeMenuItem._internal(1);
///Disable menu item "Web Search".
static const MENU_ITEM_WEB_SEARCH = const AndroidInAppWebViewModeMenuItem._internal(2); static const MENU_ITEM_WEB_SEARCH = const AndroidInAppWebViewModeMenuItem._internal(2);
///Disable all the action mode menu items for text processing.
static const MENU_ITEM_PROCESS_TEXT = const AndroidInAppWebViewModeMenuItem._internal(4); static const MENU_ITEM_PROCESS_TEXT = const AndroidInAppWebViewModeMenuItem._internal(4);
} }
///AndroidInAppWebViewForceDark class represents an Android-specific class used to indicate the force dark mode.
/// ///
///**NOTE**: available on Android 29+.
class AndroidInAppWebViewForceDark { class AndroidInAppWebViewForceDark {
final int _value; final int _value;
const AndroidInAppWebViewForceDark._internal(this._value); const AndroidInAppWebViewForceDark._internal(this._value);
@ -524,12 +602,16 @@ class AndroidInAppWebViewForceDark {
} }
toValue() => _value; toValue() => _value;
///Disable force dark, irrespective of the force dark mode of the WebView parent.
///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened.
static const FORCE_DARK_OFF = const AndroidInAppWebViewForceDark._internal(0); static const FORCE_DARK_OFF = const AndroidInAppWebViewForceDark._internal(0);
///Enable force dark dependent on the state of the WebView parent view.
static const FORCE_DARK_AUTO = const AndroidInAppWebViewForceDark._internal(1); static const FORCE_DARK_AUTO = const AndroidInAppWebViewForceDark._internal(1);
///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme.
static const FORCE_DARK_ON = const AndroidInAppWebViewForceDark._internal(2); static const FORCE_DARK_ON = const AndroidInAppWebViewForceDark._internal(2);
} }
/// ///AndroidInAppWebViewLayoutAlgorithm class represents an Android-specific class used to set the underlying layout algorithm.
class AndroidInAppWebViewLayoutAlgorithm { class AndroidInAppWebViewLayoutAlgorithm {
final String _value; final String _value;
const AndroidInAppWebViewLayoutAlgorithm._internal(this._value); const AndroidInAppWebViewLayoutAlgorithm._internal(this._value);
@ -538,11 +620,18 @@ class AndroidInAppWebViewLayoutAlgorithm {
} }
toValue() => _value; toValue() => _value;
///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions.
static const NORMAL = const AndroidInAppWebViewLayoutAlgorithm._internal("NORMAL"); static const NORMAL = const AndroidInAppWebViewLayoutAlgorithm._internal("NORMAL");
///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode.
///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode.
///
///**NOTE**: available on Android 19+.
static const TEXT_AUTOSIZING = const AndroidInAppWebViewLayoutAlgorithm._internal("TEXT_AUTOSIZING"); static const TEXT_AUTOSIZING = const AndroidInAppWebViewLayoutAlgorithm._internal("TEXT_AUTOSIZING");
} }
///AndroidInAppWebViewMixedContentMode class represents an Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
/// ///
///**NOTE**: available on Android 21+.
class AndroidInAppWebViewMixedContentMode { class AndroidInAppWebViewMixedContentMode {
final int _value; final int _value;
const AndroidInAppWebViewMixedContentMode._internal(this._value); const AndroidInAppWebViewMixedContentMode._internal(this._value);
@ -553,12 +642,21 @@ class AndroidInAppWebViewMixedContentMode {
} }
toValue() => _value; toValue() => _value;
///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode.
static const MIXED_CONTENT_ALWAYS_ALLOW = const AndroidInAppWebViewMixedContentMode._internal(0); static const MIXED_CONTENT_ALWAYS_ALLOW = const AndroidInAppWebViewMixedContentMode._internal(0);
///In this mode, the WebView will not allow a secure origin to load content from an insecure origin.
///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode.
static const MIXED_CONTENT_NEVER_ALLOW = const AndroidInAppWebViewMixedContentMode._internal(1); static const MIXED_CONTENT_NEVER_ALLOW = const AndroidInAppWebViewMixedContentMode._internal(1);
///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked.
///The types of content are allowed or blocked may change release to release and are not explicitly defined.
///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment.
///For highest security, apps are recommended to use [AndroidInAppWebViewMixedContentMode.MIXED_CONTENT_NEVER_ALLOW].
static const MIXED_CONTENT_COMPATIBILITY_MODE = const AndroidInAppWebViewMixedContentMode._internal(2); static const MIXED_CONTENT_COMPATIBILITY_MODE = const AndroidInAppWebViewMixedContentMode._internal(2);
} }
/// ///IosInAppWebViewSelectionGranularity class represents an iOS-specific class used to set the level of granularity with which the user can interactively select content in the web view.
class IosInAppWebViewSelectionGranularity { class IosInAppWebViewSelectionGranularity {
final int _value; final int _value;
const IosInAppWebViewSelectionGranularity._internal(this._value); const IosInAppWebViewSelectionGranularity._internal(this._value);
@ -569,11 +667,15 @@ class IosInAppWebViewSelectionGranularity {
} }
toValue() => _value; toValue() => _value;
static const CHARACTER = const IosInAppWebViewSelectionGranularity._internal(0); ///Selection granularity varies automatically based on the selection.
static const DYNAMIC = const IosInAppWebViewSelectionGranularity._internal(1); static const DYNAMIC = const IosInAppWebViewSelectionGranularity._internal(0);
///Selection endpoints can be placed at any character boundary.
static const CHARACTER = const IosInAppWebViewSelectionGranularity._internal(1);
} }
///IosInAppWebViewDataDetectorTypes class represents an iOS-specific class used to specify a dataDetectoryTypes value that adds interactivity to web content that matches the value.
/// ///
///**NOTE**: available on iOS 10.0+.
class IosInAppWebViewDataDetectorTypes { class IosInAppWebViewDataDetectorTypes {
final String _value; final String _value;
const IosInAppWebViewDataDetectorTypes._internal(this._value); const IosInAppWebViewDataDetectorTypes._internal(this._value);
@ -583,19 +685,29 @@ class IosInAppWebViewDataDetectorTypes {
} }
toValue() => _value; toValue() => _value;
///No detection is performed.
static const NONE = const IosInAppWebViewDataDetectorTypes._internal("NONE"); static const NONE = const IosInAppWebViewDataDetectorTypes._internal("NONE");
///Phone numbers are detected and turned into links.
static const PHONE_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("PHONE_NUMBER"); static const PHONE_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("PHONE_NUMBER");
///URLs in text are detected and turned into links.
static const LINK = const IosInAppWebViewDataDetectorTypes._internal("LINK"); static const LINK = const IosInAppWebViewDataDetectorTypes._internal("LINK");
///Addresses are detected and turned into links.
static const ADDRESS = const IosInAppWebViewDataDetectorTypes._internal("ADDRESS"); static const ADDRESS = const IosInAppWebViewDataDetectorTypes._internal("ADDRESS");
///Dates and times that are in the future are detected and turned into links.
static const CALENDAR_EVENT = const IosInAppWebViewDataDetectorTypes._internal("CALENDAR_EVENT"); static const CALENDAR_EVENT = const IosInAppWebViewDataDetectorTypes._internal("CALENDAR_EVENT");
///Tracking numbers are detected and turned into links.
static const TRACKING_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("TRACKING_NUMBER"); static const TRACKING_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("TRACKING_NUMBER");
///Flight numbers are detected and turned into links.
static const FLIGHT_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("FLIGHT_NUMBER"); static const FLIGHT_NUMBER = const IosInAppWebViewDataDetectorTypes._internal("FLIGHT_NUMBER");
///Lookup suggestions are detected and turned into links.
static const LOOKUP_SUGGESTION = const IosInAppWebViewDataDetectorTypes._internal("LOOKUP_SUGGESTION"); static const LOOKUP_SUGGESTION = const IosInAppWebViewDataDetectorTypes._internal("LOOKUP_SUGGESTION");
///Spotlight suggestions are detected and turned into links.
static const SPOTLIGHT_SUGGESTION = const IosInAppWebViewDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); static const SPOTLIGHT_SUGGESTION = const IosInAppWebViewDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION");
///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added.
static const ALL = const IosInAppWebViewDataDetectorTypes._internal("ALL"); static const ALL = const IosInAppWebViewDataDetectorTypes._internal("ALL");
} }
/// ///InAppWebViewUserPreferredContentMode class represents the content mode to prefer when loading and rendering a webpage.
class InAppWebViewUserPreferredContentMode { class InAppWebViewUserPreferredContentMode {
final int _value; final int _value;
const InAppWebViewUserPreferredContentMode._internal(this._value); const InAppWebViewUserPreferredContentMode._internal(this._value);
@ -606,12 +718,15 @@ class InAppWebViewUserPreferredContentMode {
} }
toValue() => _value; toValue() => _value;
///The recommended content mode for the current platform.
static const RECOMMENDED = const InAppWebViewUserPreferredContentMode._internal(0); static const RECOMMENDED = const InAppWebViewUserPreferredContentMode._internal(0);
///Represents content targeting mobile browsers.
static const MOBILE = const InAppWebViewUserPreferredContentMode._internal(1); static const MOBILE = const InAppWebViewUserPreferredContentMode._internal(1);
///Represents content targeting desktop browsers.
static const DESKTOP = const InAppWebViewUserPreferredContentMode._internal(2); static const DESKTOP = const InAppWebViewUserPreferredContentMode._internal(2);
} }
/// ///IosWebViewOptionsPresentationStyle class represents an iOS-specific class used to specify the modal presentation style when presenting a view controller.
class IosWebViewOptionsPresentationStyle { class IosWebViewOptionsPresentationStyle {
final int _value; final int _value;
const IosWebViewOptionsPresentationStyle._internal(this._value); const IosWebViewOptionsPresentationStyle._internal(this._value);
@ -622,19 +737,31 @@ class IosWebViewOptionsPresentationStyle {
} }
toValue() => _value; toValue() => _value;
///A presentation style in which the presented view covers the screen.
static const FULL_SCREEN = const IosWebViewOptionsPresentationStyle._internal(0); static const FULL_SCREEN = const IosWebViewOptionsPresentationStyle._internal(0);
///A presentation style that partially covers the underlying content.
static const PAGE_SHEET = const IosWebViewOptionsPresentationStyle._internal(1); static const PAGE_SHEET = const IosWebViewOptionsPresentationStyle._internal(1);
///A presentation style that displays the content centered in the screen.
static const FORM_SHEET = const IosWebViewOptionsPresentationStyle._internal(2); static const FORM_SHEET = const IosWebViewOptionsPresentationStyle._internal(2);
///A presentation style where the content is displayed over another view controllers content.
static const CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle._internal(3); static const CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle._internal(3);
///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects.
static const CUSTOM = const IosWebViewOptionsPresentationStyle._internal(4); static const CUSTOM = const IosWebViewOptionsPresentationStyle._internal(4);
///A view presentation style in which the presented view covers the screen.
static const OVER_FULL_SCREEN = const IosWebViewOptionsPresentationStyle._internal(5); static const OVER_FULL_SCREEN = const IosWebViewOptionsPresentationStyle._internal(5);
///A presentation style where the content is displayed over another view controllers content.
static const OVER_CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle._internal(6); static const OVER_CURRENT_CONTEXT = const IosWebViewOptionsPresentationStyle._internal(6);
///A presentation style where the content is displayed in a popover view.
static const POPOVER = const IosWebViewOptionsPresentationStyle._internal(7); static const POPOVER = const IosWebViewOptionsPresentationStyle._internal(7);
///A presentation style that indicates no adaptations should be made.
static const NONE = const IosWebViewOptionsPresentationStyle._internal(8); static const NONE = const IosWebViewOptionsPresentationStyle._internal(8);
///The default presentation style chosen by the system.
///
///**NOTE**: available on iOS 13.0+.
static const AUTOMATIC = const IosWebViewOptionsPresentationStyle._internal(9); static const AUTOMATIC = const IosWebViewOptionsPresentationStyle._internal(9);
} }
/// ///IosWebViewOptionsTransitionStyle class represents an iOS-specific class used to specify the transition style when presenting a view controller.
class IosWebViewOptionsTransitionStyle { class IosWebViewOptionsTransitionStyle {
final int _value; final int _value;
const IosWebViewOptionsTransitionStyle._internal(this._value); const IosWebViewOptionsTransitionStyle._internal(this._value);
@ -645,13 +772,25 @@ class IosWebViewOptionsTransitionStyle {
} }
toValue() => _value; toValue() => _value;
///When the view controller is presented, its view slides up from the bottom of the screen.
///On dismissal, the view slides back down. This is the default transition style.
static const COVER_VERTICAL = const IosWebViewOptionsTransitionStyle._internal(0); static const COVER_VERTICAL = const IosWebViewOptionsTransitionStyle._internal(0);
///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left,
///resulting in the revealing of the new view as if it were on the back of the previous view.
///On dismissal, the flip occurs from left-to-right, returning to the original view.
static const FLIP_HORIZONTAL = const IosWebViewOptionsTransitionStyle._internal(1); static const FLIP_HORIZONTAL = const IosWebViewOptionsTransitionStyle._internal(1);
///When the view controller is presented, the current view fades out while the new view fades in at the same time.
///On dismissal, a similar type of cross-fade is used to return to the original view.
static const CROSS_DISSOLVE = const IosWebViewOptionsTransitionStyle._internal(2); static const CROSS_DISSOLVE = const IosWebViewOptionsTransitionStyle._internal(2);
///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath.
///On dismissal, the curled up page unfurls itself back on top of the presented view.
///A view controller presented using this transition is itself prevented from presenting any additional view controllers.
static const PARTIAL_CURL = const IosWebViewOptionsTransitionStyle._internal(3); static const PARTIAL_CURL = const IosWebViewOptionsTransitionStyle._internal(3);
} }
///IosWebViewOptionsTransitionStyle class represents an iOS-specific class used to set the custom style for the dismiss button.
/// ///
///**NOTE**: available on iOS 11.0+.
class IosSafariOptionsDismissButtonStyle { class IosSafariOptionsDismissButtonStyle {
final int _value; final int _value;
const IosSafariOptionsDismissButtonStyle._internal(this._value); const IosSafariOptionsDismissButtonStyle._internal(this._value);
@ -662,45 +801,59 @@ class IosSafariOptionsDismissButtonStyle {
} }
toValue() => _value; toValue() => _value;
///Makes the button title the localized string "Done".
static const DONE = const IosSafariOptionsDismissButtonStyle._internal(0); static const DONE = const IosSafariOptionsDismissButtonStyle._internal(0);
///Makes the button title the localized string "Close".
static const CLOSE = const IosSafariOptionsDismissButtonStyle._internal(1); static const CLOSE = const IosSafariOptionsDismissButtonStyle._internal(1);
///Makes the button title the localized string "Cancel".
static const CANCEL = const IosSafariOptionsDismissButtonStyle._internal(2); static const CANCEL = const IosSafariOptionsDismissButtonStyle._internal(2);
} }
/// ///InAppWebViewWidgetOptions class represents the options that can be used for an [InAppWebView].
class InAppWebViewWidgetOptions { class InAppWebViewWidgetOptions {
///Cross-platform options.
InAppWebViewOptions inAppWebViewOptions; InAppWebViewOptions inAppWebViewOptions;
///Android-specific options.
AndroidInAppWebViewOptions androidInAppWebViewOptions; AndroidInAppWebViewOptions androidInAppWebViewOptions;
///iOS-specific options.
IosInAppWebViewOptions iosInAppWebViewOptions; IosInAppWebViewOptions iosInAppWebViewOptions;
InAppWebViewWidgetOptions({this.inAppWebViewOptions, this.androidInAppWebViewOptions, this.iosInAppWebViewOptions}); InAppWebViewWidgetOptions({this.inAppWebViewOptions, this.androidInAppWebViewOptions, this.iosInAppWebViewOptions});
} }
/// ///InAppBrowserClassOptions class represents the options that can be used for an [InAppBrowser] WebView.
class InAppBrowserClassOptions { class InAppBrowserClassOptions {
///Cross-platform options.
InAppBrowserOptions inAppBrowserOptions; InAppBrowserOptions inAppBrowserOptions;
///Android-specific options.
AndroidInAppBrowserOptions androidInAppBrowserOptions; AndroidInAppBrowserOptions androidInAppBrowserOptions;
///iOS-specific options.
IosInAppBrowserOptions iosInAppBrowserOptions; IosInAppBrowserOptions iosInAppBrowserOptions;
///WebView options.
InAppWebViewWidgetOptions inAppWebViewWidgetOptions; InAppWebViewWidgetOptions inAppWebViewWidgetOptions;
InAppBrowserClassOptions({this.inAppBrowserOptions, this.androidInAppBrowserOptions, this.iosInAppBrowserOptions, this.inAppWebViewWidgetOptions}); InAppBrowserClassOptions({this.inAppBrowserOptions, this.androidInAppBrowserOptions, this.iosInAppBrowserOptions, this.inAppWebViewWidgetOptions});
} }
/// ///ChromeSafariBrowserClassOptions class represents the options that can be used for an [ChromeSafariBrowser] window.
class ChromeSafariBrowserClassOptions { class ChromeSafariBrowserClassOptions {
///Android-specific options.
AndroidChromeCustomTabsOptions androidChromeCustomTabsOptions; AndroidChromeCustomTabsOptions androidChromeCustomTabsOptions;
///iOS-specific options.
IosSafariOptions iosSafariOptions; IosSafariOptions iosSafariOptions;
ChromeSafariBrowserClassOptions({this.androidChromeCustomTabsOptions, this.iosSafariOptions}); ChromeSafariBrowserClassOptions({this.androidChromeCustomTabsOptions, this.iosSafariOptions});
} }
/// ///AjaxRequestAction class used by [AjaxRequest] class.
class AjaxRequestAction { class AjaxRequestAction {
final int _value; final int _value;
const AjaxRequestAction._internal(this._value); const AjaxRequestAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Aborts the current [AjaxRequest].
static const ABORT = const AjaxRequestAction._internal(0); static const ABORT = const AjaxRequestAction._internal(0);
///Proceeds with the current [AjaxRequest].
static const PROCEED = const AjaxRequestAction._internal(1); static const PROCEED = const AjaxRequestAction._internal(1);
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -714,7 +867,7 @@ class AjaxRequestAction {
} }
} }
/// ///AjaxRequestEventType class used by [AjaxRequestEvent] class.
class AjaxRequestEventType { class AjaxRequestEventType {
final String _value; final String _value;
const AjaxRequestEventType._internal(this._value); const AjaxRequestEventType._internal(this._value);
@ -724,24 +877,42 @@ class AjaxRequestEventType {
toValue() => _value; toValue() => _value;
String toString() => _value; String toString() => _value;
///The LOADSTART event is fired when a request has started to load data.
static const LOADSTART = const AjaxRequestEventType._internal("loadstart"); static const LOADSTART = const AjaxRequestEventType._internal("loadstart");
///The LOAD event is fired when an `XMLHttpRequest` transaction completes successfully.
static const LOAD = const AjaxRequestEventType._internal("load"); static const LOAD = const AjaxRequestEventType._internal("load");
///The LOADEND event is fired when a request has completed, whether successfully (after [AjaxRequestEventType.LOAD]) or
///unsuccessfully (after [AjaxRequestEventType.ABORT] or [AjaxRequestEventType.ERROR]).
static const LOADEND = const AjaxRequestEventType._internal("loadend"); static const LOADEND = const AjaxRequestEventType._internal("loadend");
///The PROGRESS event is fired periodically when a request receives more data.
static const PROGRESS = const AjaxRequestEventType._internal("progress"); static const PROGRESS = const AjaxRequestEventType._internal("progress");
///The ERROR event is fired when the request encountered an error.
static const ERROR = const AjaxRequestEventType._internal("error"); static const ERROR = const AjaxRequestEventType._internal("error");
///The ABORT event is fired when a request has been aborted.
static const ABORT = const AjaxRequestEventType._internal("abort"); static const ABORT = const AjaxRequestEventType._internal("abort");
///The TIMEOUT event is fired when progression is terminated due to preset time expiring.
static const TIMEOUT = const AjaxRequestEventType._internal("timeout");
} }
/// ///AjaxRequestEvent class used by [AjaxRequest] class. It represents events measuring progress of an [AjaxRequest].
class AjaxRequestEvent { class AjaxRequestEvent {
///Event type.
AjaxRequestEventType type; AjaxRequestEventType type;
int loaded; ///Is a Boolean flag indicating if the total work to be done, and the amount of work already done, by the underlying process is calculable.
///In other words, it tells if the progress is measurable or not.
bool lengthComputable; bool lengthComputable;
///Is an integer representing the amount of work already performed by the underlying process.
///The ratio of work done can be calculated with the property and [AjaxRequestEvent.total].
///When downloading a resource using HTTP, this only represent the part of the content itself, not headers and other overhead.
int loaded;
///Is an integer representing the total amount of work that the underlying process is in the progress of performing.
///When downloading a resource using HTTP, this only represent the content itself, not headers and other overhead.
int total;
AjaxRequestEvent({this.type, this.loaded, this.lengthComputable}); AjaxRequestEvent({this.type, this.lengthComputable, this.loaded, this.total});
} }
/// ///AjaxRequestReadyState class used by [AjaxRequest] class. It represents the state of an [AjaxRequest].
class AjaxRequestReadyState { class AjaxRequestReadyState {
final int _value; final int _value;
const AjaxRequestReadyState._internal(this._value); const AjaxRequestReadyState._internal(this._value);
@ -753,36 +924,72 @@ class AjaxRequestReadyState {
toValue() => _value; toValue() => _value;
String toString() => _value.toString(); String toString() => _value.toString();
///Client has been created. `XMLHttpRequest.open()` not called yet.
static const UNSENT = const AjaxRequestReadyState._internal(0); static const UNSENT = const AjaxRequestReadyState._internal(0);
///`XMLHttpRequest.open()` has been called.
static const OPENED = const AjaxRequestReadyState._internal(1); static const OPENED = const AjaxRequestReadyState._internal(1);
///`XMLHttpRequest.send()` has been called, and [AjaxRequest.headers] and [AjaxRequest.status] are available.
static const HEADERS_RECEIVED = const AjaxRequestReadyState._internal(2); static const HEADERS_RECEIVED = const AjaxRequestReadyState._internal(2);
///Downloading; [AjaxRequest.responseText] holds partial data.
static const LOADING = const AjaxRequestReadyState._internal(3); static const LOADING = const AjaxRequestReadyState._internal(3);
///The operation is complete.
static const DONE = const AjaxRequestReadyState._internal(4); static const DONE = const AjaxRequestReadyState._internal(4);
} }
/// ///AjaxRequest class represents a JavaScript [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object.
class AjaxRequest { class AjaxRequest {
///Data passed as a parameter to the `XMLHttpRequest.send()` method.
dynamic data; dynamic data;
///The HTTP request method of the `XMLHttpRequest` request.
String method; String method;
///The URL of the `XMLHttpRequest` request.
String url; String url;
///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously.
bool isAsync; bool isAsync;
///The optional user name to use for authentication purposes; by default, this is the null value.
String user; String user;
///The optional password to use for authentication purposes; by default, this is the null value.
String password; String password;
///The XMLHttpRequest.withCredentials property is a Boolean that indicates whether or not cross-site Access-Control requests
///should be made using credentials such as cookies, authorization headers or TLS client certificates.
///Setting withCredentials has no effect on same-site requests.
///In addition, this flag is also used to indicate when cookies are to be ignored in the response. The default is false.
bool withCredentials; bool withCredentials;
///The HTTP request headers.
Map<dynamic, dynamic> headers; Map<dynamic, dynamic> headers;
///The state of the `XMLHttpRequest` request.
AjaxRequestReadyState readyState; AjaxRequestReadyState readyState;
///The numerical HTTP [status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) of the `XMLHttpRequest`'s response.
int status; int status;
///The serialized URL of the response or the empty string if the URL is null.
///If the URL is returned, any URL fragment present in the URL will be stripped away.
///The value of responseURL will be the final URL obtained after any redirects.
String responseURL; String responseURL;
///It is an enumerated string value specifying the type of data contained in the response.
///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).
///If an empty string is set as the value of responseType, the default value of text is used.
String responseType; String responseType;
///The response's body content. The content-type depends on the [AjaxRequest.reponseType].
dynamic response;
///The text received from a server following a request being sent.
String responseText; String responseText;
///The HTML or XML string retrieved by the request or null if the request was unsuccessful, has not yet been sent, or if the data can't be parsed as XML or HTML.
String responseXML;
///A String containing the response's status message as returned by the HTTP server.
///Unlike [AjaxRequest.status] which indicates a numerical status code, this property contains the text of the response status, such as "OK" or "Not Found".
///If the request's readyState is in [AjaxRequestReadyState.UNSENT] or [AjaxRequestReadyState.OPENED] state, the value of statusText will be an empty string.
///If the server response doesn't explicitly specify a status text, statusText will assume the default value "OK".
String statusText; String statusText;
///All the response headers or returns null if no response has been received. If a network error happened, an empty string is returned.
Map<dynamic, dynamic> responseHeaders; Map<dynamic, dynamic> responseHeaders;
///Event type of the `XMLHttpRequest` request.
AjaxRequestEvent event; AjaxRequestEvent event;
///Indicates the [AjaxRequestAction] that can be used to control the `XMLHttpRequest` request.
AjaxRequestAction action; AjaxRequestAction action;
AjaxRequest({this.data, this.method, this.url, this.isAsync, this.user, this.password, AjaxRequest({this.data, this.method, this.url, this.isAsync, this.user, this.password,
this.withCredentials, this.headers, this.readyState, this.status, this.responseURL, this.responseType, this.withCredentials, this.headers, this.readyState, this.status, this.responseURL, this.responseType,
this.responseText, this.statusText, this.responseHeaders, this.event, this.action = AjaxRequestAction.PROCEED}); this.response, this.responseText, this.responseXML, this.statusText, this.responseHeaders, this.event, this.action = AjaxRequestAction.PROCEED});
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
@ -798,7 +1005,9 @@ class AjaxRequest {
"status": status, "status": status,
"responseURL": responseURL, "responseURL": responseURL,
"responseType": responseType, "responseType": responseType,
"response": response,
"responseText": responseText, "responseText": responseText,
"responseXML": responseXML,
"statusText": statusText, "statusText": statusText,
"responseHeaders": responseHeaders, "responseHeaders": responseHeaders,
"action": action?.toValue() "action": action?.toValue()
@ -810,18 +1019,21 @@ class AjaxRequest {
} }
} }
/// ///FetchRequestAction class used by [FetchRequest] class.
class FetchRequestAction { class FetchRequestAction {
final int _value; final int _value;
const FetchRequestAction._internal(this._value); const FetchRequestAction._internal(this._value);
toValue() => _value; toValue() => _value;
///Aborts the fetch request.
static const ABORT = const FetchRequestAction._internal(0); static const ABORT = const FetchRequestAction._internal(0);
///Proceeds with the fetch request.
static const PROCEED = const FetchRequestAction._internal(1); static const PROCEED = const FetchRequestAction._internal(1);
} }
/// ///FetchRequestCredential class is an interface for [FetchRequestCredentialDefault], [FetchRequestFederatedCredential] and [FetchRequestPasswordCredential] classes.
class FetchRequestCredential { class FetchRequestCredential {
///Type of credentials.
String type; String type;
FetchRequestCredential({this.type}); FetchRequestCredential({this.type});
@ -833,8 +1045,9 @@ class FetchRequestCredential {
} }
} }
/// ///FetchRequestCredentialDefault class represents the default credentials used by an [FetchRequest].
class FetchRequestCredentialDefault extends FetchRequestCredential { class FetchRequestCredentialDefault extends FetchRequestCredential {
///The value of the credentials.
String value; String value;
FetchRequestCredentialDefault({type, this.value}): super(type: type); FetchRequestCredentialDefault({type, this.value}): super(type: type);
@ -847,12 +1060,17 @@ class FetchRequestCredentialDefault extends FetchRequestCredential {
} }
} }
/// ///FetchRequestFederatedCredential class represents a [FederatedCredential](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredential) type of credentials.
class FetchRequestFederatedCredential extends FetchRequestCredential { class FetchRequestFederatedCredential extends FetchRequestCredential {
///Credential's identifier.
dynamic id; dynamic id;
///The name associated with a credential. It should be a human-readable, public name.
String name; String name;
///Credential's federated identity protocol.
String protocol; String protocol;
///Credential's federated identity provider.
String provider; String provider;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
String iconURL; String iconURL;
FetchRequestFederatedCredential({type, this.id, this.name, this.protocol, this.provider, this.iconURL}): super(type: type); FetchRequestFederatedCredential({type, this.id, this.name, this.protocol, this.provider, this.iconURL}): super(type: type);
@ -869,11 +1087,15 @@ class FetchRequestFederatedCredential extends FetchRequestCredential {
} }
} }
/// ///FetchRequestPasswordCredential class represents a [PasswordCredential](https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential) type of credentials.
class FetchRequestPasswordCredential extends FetchRequestCredential { class FetchRequestPasswordCredential extends FetchRequestCredential {
///Credential's identifier.
dynamic id; dynamic id;
///The name associated with a credential. It should be a human-readable, public name.
String name; String name;
///The password of the credential.
String password; String password;
///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
String iconURL; String iconURL;
FetchRequestPasswordCredential({type, this.id, this.name, this.password, this.iconURL}): super(type: type); FetchRequestPasswordCredential({type, this.id, this.name, this.password, this.iconURL}): super(type: type);
@ -889,20 +1111,33 @@ class FetchRequestPasswordCredential extends FetchRequestCredential {
} }
} }
/// ///FetchRequest class represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).
class FetchRequest { class FetchRequest {
///The URL of the request.
String url; String url;
///The HTTP request method used of the request.
String method; String method;
///The HTTP request headers.
Map<String, dynamic> headers; Map<String, dynamic> headers;
///Body of the request.
Uint8List body; Uint8List body;
///The mode used by the request.
String mode; String mode;
///The request credentials used by the request.
FetchRequestCredential credentials; FetchRequestCredential credentials;
///The cache mode used by the request.
String cache; String cache;
///The redirect mode used by the request.
String redirect; String redirect;
///A String specifying no-referrer, client, or a URL.
String referrer; String referrer;
///The value of the referer HTTP header.
String referrerPolicy; String referrerPolicy;
///Contains the subresource integrity value of the request.
String integrity; String integrity;
///The keepalive option used to allow the request to outlive the page.
bool keepalive; bool keepalive;
///Indicates the [FetchRequestAction] that can be used to control the request.
FetchRequestAction action; FetchRequestAction action;
FetchRequest({this.url, this.method, this.headers, this.body, this.mode, this.credentials, FetchRequest({this.url, this.method, this.headers, this.body, this.mode, this.credentials,

View File

@ -36,34 +36,75 @@ class ChromeSafariBrowserOptions {
} }
} }
///This class represents all the cross-platform WebView options available.
class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions { class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions {
///Set to `true` to be able to listen at the [shouldOverrideUrlLoading] event. The default value is `false`.
bool useShouldOverrideUrlLoading; bool useShouldOverrideUrlLoading;
///Set to `true` to be able to listen at the [onLoadResource] event. The default value is `false`.
bool useOnLoadResource; bool useOnLoadResource;
///Set to `true` to be able to listen at the [onDownloadStart] event. The default value is `false`.
bool useOnDownloadStart; bool useOnDownloadStart;
///Set to `true` to be able to listen at the [onTargetBlank] event. The default value is `false`.
bool useOnTargetBlank; bool useOnTargetBlank;
///Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
bool clearCache; bool clearCache;
///Sets the user-agent for the WebView.
///
///**NOTE**: available on iOS 9.0+.
String userAgent; String userAgent;
///Append to the existing user-agent. Setting userAgent will override this.
///
///**NOTE**: available on Android 17+ and on iOS 9.0+.
String applicationNameForUserAgent; String applicationNameForUserAgent;
///Set to `true` to enable JavaScript. The default value is `true`.
bool javaScriptEnabled; bool javaScriptEnabled;
///Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
///This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. The default is `false`.
///
///**NOTE**: on iOS the debugging mode is always enabled.
bool debuggingEnabled; bool debuggingEnabled;
///Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
bool javaScriptCanOpenWindowsAutomatically; bool javaScriptCanOpenWindowsAutomatically;
///Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
///
///**NOTE**: available on iOS 10.0+.
bool mediaPlaybackRequiresUserGesture; bool mediaPlaybackRequiresUserGesture;
int textZoom; ///Sets the minimum font size. The default value is `8` for Android, `0` for iOS.
int minimumFontSize; int minimumFontSize;
///Define whether the vertical scrollbar should be drawn or not. The default value is `true`.
bool verticalScrollBarEnabled; bool verticalScrollBarEnabled;
///Define whether the horizontal scrollbar should be drawn or not. The default value is `true`.
bool horizontalScrollBarEnabled; bool horizontalScrollBarEnabled;
///List of custom schemes that the WebView must handle. Use the [onLoadResourceCustomScheme] event to intercept resource requests with custom scheme.
///
///**NOTE**: available on iOS 11.0+.
List<String> resourceCustomSchemes; List<String> resourceCustomSchemes;
///List of [ContentBlocker] that are a set of rules used to block content in the browser window.
///
///**NOTE**: available on iOS 11.0+.
List<ContentBlocker> contentBlockers; List<ContentBlocker> contentBlockers;
///Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is [InAppWebViewUserPreferredContentMode.RECOMMENDED].
///
///**NOTE**: available on iOS 13.0+.
InAppWebViewUserPreferredContentMode preferredContentMode; InAppWebViewUserPreferredContentMode preferredContentMode;
///Set to `true` to be able to listen at the [shouldInterceptAjaxRequest] event. The default value is `false`.
bool useShouldInterceptAjaxRequest; bool useShouldInterceptAjaxRequest;
///Set to `true` to be able to listen at the [shouldInterceptFetchRequest] event. The default value is `false`.
bool useShouldInterceptFetchRequest; bool useShouldInterceptFetchRequest;
///Set to `true` to open a browser window with incognito mode. The default value is `false`.
///
///**NOTE**: available on iOS 9.0+.
bool incognito; bool incognito;
///Sets whether WebView should use browser caching. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
bool cacheEnabled; bool cacheEnabled;
///Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
bool transparentBackground; bool transparentBackground;
InAppWebViewOptions({this.useShouldOverrideUrlLoading = false, this.useOnLoadResource = false, this.useOnDownloadStart = false, this.useOnTargetBlank = false, InAppWebViewOptions({this.useShouldOverrideUrlLoading = false, this.useOnLoadResource = false, this.useOnDownloadStart = false, this.useOnTargetBlank = false,
this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", this.javaScriptEnabled = true, this.debuggingEnabled = false, this.javaScriptCanOpenWindowsAutomatically = false, this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", this.javaScriptEnabled = true, this.debuggingEnabled = false, this.javaScriptCanOpenWindowsAutomatically = false,
this.mediaPlaybackRequiresUserGesture = true, this.textZoom = 100, this.minimumFontSize, this.verticalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true, this.mediaPlaybackRequiresUserGesture = true, this.minimumFontSize, this.verticalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true,
this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = InAppWebViewUserPreferredContentMode.RECOMMENDED, this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = InAppWebViewUserPreferredContentMode.RECOMMENDED,
this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptFetchRequest = false, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false}) { this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptFetchRequest = false, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false}) {
if (this.minimumFontSize == null) if (this.minimumFontSize == null)
@ -90,7 +131,6 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
"debuggingEnabled": debuggingEnabled, "debuggingEnabled": debuggingEnabled,
"javaScriptCanOpenWindowsAutomatically": javaScriptCanOpenWindowsAutomatically, "javaScriptCanOpenWindowsAutomatically": javaScriptCanOpenWindowsAutomatically,
"mediaPlaybackRequiresUserGesture": mediaPlaybackRequiresUserGesture, "mediaPlaybackRequiresUserGesture": mediaPlaybackRequiresUserGesture,
"textZoom": textZoom,
"verticalScrollBarEnabled": verticalScrollBarEnabled, "verticalScrollBarEnabled": verticalScrollBarEnabled,
"horizontalScrollBarEnabled": horizontalScrollBarEnabled, "horizontalScrollBarEnabled": horizontalScrollBarEnabled,
"resourceCustomSchemes": resourceCustomSchemes, "resourceCustomSchemes": resourceCustomSchemes,
@ -128,7 +168,6 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
options.debuggingEnabled = map["debuggingEnabled"]; options.debuggingEnabled = map["debuggingEnabled"];
options.javaScriptCanOpenWindowsAutomatically = map["javaScriptCanOpenWindowsAutomatically"]; options.javaScriptCanOpenWindowsAutomatically = map["javaScriptCanOpenWindowsAutomatically"];
options.mediaPlaybackRequiresUserGesture = map["mediaPlaybackRequiresUserGesture"]; options.mediaPlaybackRequiresUserGesture = map["mediaPlaybackRequiresUserGesture"];
options.textZoom = map["textZoom"];
options.verticalScrollBarEnabled = map["verticalScrollBarEnabled"]; options.verticalScrollBarEnabled = map["verticalScrollBarEnabled"];
options.horizontalScrollBarEnabled = map["horizontalScrollBarEnabled"]; options.horizontalScrollBarEnabled = map["horizontalScrollBarEnabled"];
options.resourceCustomSchemes = List<String>.from(map["resourceCustomSchemes"] ?? []); options.resourceCustomSchemes = List<String>.from(map["resourceCustomSchemes"] ?? []);
@ -143,61 +182,142 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
} }
} }
///This class represents all the Android-only WebView options available.
class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions { class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions {
///Sets the text zoom of the page in percent. The default is `100`.
int textZoom;
///Set to `true` to have the session cookie cache cleared before the new window is opened.
bool clearSessionCache; bool clearSessionCache;
///Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
bool builtInZoomControls; bool builtInZoomControls;
///Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
bool displayZoomControls; bool displayZoomControls;
///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
bool supportZoom; bool supportZoom;
///Set to `true` if you want the database storage API is enabled. The default value is `false`.
bool databaseEnabled; bool databaseEnabled;
///Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
bool domStorageEnabled; bool domStorageEnabled;
///Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport.
///When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels.
///When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used.
///If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
bool useWideViewPort; bool useWideViewPort;
///Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links.
///Safe Browsing is enabled by default for devices which support it.
///
///**NOTE**: available on Android 26+.
bool safeBrowsingEnabled; bool safeBrowsingEnabled;
///Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
///
///**NOTE**: available on Android 21+.
AndroidInAppWebViewMixedContentMode mixedContentMode; AndroidInAppWebViewMixedContentMode mixedContentMode;
///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`.
bool allowContentAccess; bool allowContentAccess;
///Enables or disables file access within WebView. Note that this enables or disables file system access only.
///Assets and resources are still accessible using \file:///android_asset` and `file:///android_res`. The default value is `true`.
bool allowFileAccess; bool allowFileAccess;
///Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs.
///Note that the value of this setting is ignored if the value of [allowFileAccessFromFileURLs] is `true`.
///Note too, that this setting affects only JavaScript access to file scheme resources. The default value is `false`.
bool allowFileAccessFromFileURLs; bool allowFileAccessFromFileURLs;
///Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin.
///Note that this setting affects only JavaScript access to file scheme resources.
///This includes access to content from other file scheme URLs. The default value is `false`.
bool allowUniversalAccessFromFileURLs; bool allowUniversalAccessFromFileURLs;
///Sets the path to the Application Caches files. In order for the Application Caches API to be enabled, this option must be set a path to which the application can write.
///This option is used one time: repeated calls are ignored.
String appCachePath; String appCachePath;
///Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes). The default value is `false`.
bool blockNetworkImage; bool blockNetworkImage;
///Sets whether the WebView should not load resources from the network. The default value is `false`.
bool blockNetworkLoads; bool blockNetworkLoads;
///Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed.
///When navigating back, content is not revalidated, instead the content is just retrieved from the cache. The default value is [AndroidInAppWebViewCacheMode.LOAD_DEFAULT].
AndroidInAppWebViewCacheMode cacheMode; AndroidInAppWebViewCacheMode cacheMode;
///Sets the cursive font family name. The default value is `"cursive"`.
String cursiveFontFamily; String cursiveFontFamily;
///Sets the default fixed font size. The default value is `16`.
int defaultFixedFontSize; int defaultFixedFontSize;
///Sets the default font size. The default value is `16`.
int defaultFontSize; int defaultFontSize;
///Sets the default text encoding name to use when decoding html pages. The default value is `"UTF-8"`.
String defaultTextEncodingName; String defaultTextEncodingName;
///Disables the action mode menu items according to menuItems flag.
///
///**NOTE**: available on Android 24+.
AndroidInAppWebViewModeMenuItem disabledActionModeMenuItems; AndroidInAppWebViewModeMenuItem disabledActionModeMenuItems;
///Sets the fantasy font family name. The default value is `"fantasy"`.
String fantasyFontFamily; String fantasyFontFamily;
///Sets the fixed font family name. The default value is `"monospace"`.
String fixedFontFamily; String fixedFontFamily;
///Set the force dark mode for this WebView. The default value is [AndroidInAppWebViewForceDark.FORCE_DARK_OFF].
///
///**NOTE**: available on Android 29+.
AndroidInAppWebViewForceDark forceDark; AndroidInAppWebViewForceDark forceDark;
///Sets whether Geolocation API is enabled. The default value is `true`.
bool geolocationEnabled; bool geolocationEnabled;
///Sets the underlying layout algorithm. This will cause a re-layout of the WebView.
AndroidInAppWebViewLayoutAlgorithm layoutAlgorithm; AndroidInAppWebViewLayoutAlgorithm layoutAlgorithm;
///Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width.
///This setting is taken into account when the content width is greater than the width of the WebView control, for example, when [useWideViewPort] is enabled.
///The default value is `false`.
bool loadWithOverviewMode; bool loadWithOverviewMode;
///Sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme.
///Note that if the value of this setting is changed from false to true, all images resources referenced by content currently displayed by the WebView are loaded automatically.
///The default value is `true`.
bool loadsImagesAutomatically; bool loadsImagesAutomatically;
///Sets the minimum logical font size. The default is `8`.
int minimumLogicalFontSize; int minimumLogicalFontSize;
///Sets the initial scale for this WebView. 0 means default.The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
///If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of [loadWithOverviewMode].
///If its value is true, the content will be zoomed out to be fit by width into the WebView control, otherwise not.
///If initial scale is greater than 0, WebView starts with this value as initial scale.
///Please note that unlike the scale properties in the viewport meta tag, this method doesn't take the screen density into account.
///The default is `0`.
int initialScale; int initialScale;
///Tells the WebView whether it needs to set a node. The default value is `true`.
bool needInitialFocus; bool needInitialFocus;
///Sets whether this WebView should raster tiles when it is offscreen but attached to a window.
///Turning this on can avoid rendering artifacts when animating an offscreen WebView on-screen.
///Offscreen WebViews in this mode use more memory. The default value is `false`.
///
///**NOTE**: available on Android 23+.
bool offscreenPreRaster; bool offscreenPreRaster;
///Sets the sans-serif font family name. The default value is `"sans-serif"`.
String sansSerifFontFamily; String sansSerifFontFamily;
///Sets the serif font family name. The default value is `"sans-serif"`.
String serifFontFamily; String serifFontFamily;
///Sets the standard font family name. The default value is `"sans-serif"`.
String standardFontFamily; String standardFontFamily;
///Sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data.
///Therefore, the Webview form data save feature is disabled. Note that the feature will continue to be supported on older versions of Android as before.
bool saveFormData; bool saveFormData;
///Boolean value to enable third party cookies in the WebView.
///Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS.
///The default value is `true`.
///
///**NOTE**: available on Android 21+.
bool thirdPartyCookiesEnabled; bool thirdPartyCookiesEnabled;
///Boolean value to enable Hardware Acceleration in the WebView.
///The default value is `true`.
bool hardwareAcceleration; bool hardwareAcceleration;
AndroidInAppWebViewOptions({this.clearSessionCache = false, this.builtInZoomControls = false, this.displayZoomControls = false, this.supportZoom = true, this.databaseEnabled = false, AndroidInAppWebViewOptions({this.textZoom = 100, this.clearSessionCache = false, this.builtInZoomControls = false, this.displayZoomControls = false, this.supportZoom = true, this.databaseEnabled = false,
this.domStorageEnabled = false, this.useWideViewPort = true, this.safeBrowsingEnabled = true, this.mixedContentMode, this.domStorageEnabled = false, this.useWideViewPort = true, this.safeBrowsingEnabled = true, this.mixedContentMode,
this.allowContentAccess = true, this.allowFileAccess = true, this.allowFileAccessFromFileURLs = true, this.allowUniversalAccessFromFileURLs = true, this.allowContentAccess = true, this.allowFileAccess = true, this.allowFileAccessFromFileURLs = false, this.allowUniversalAccessFromFileURLs = false,
this.appCachePath, this.blockNetworkImage = false, this.blockNetworkLoads = false, this.cacheMode = AndroidInAppWebViewCacheMode.LOAD_DEFAULT, this.appCachePath, this.blockNetworkImage = false, this.blockNetworkLoads = false, this.cacheMode = AndroidInAppWebViewCacheMode.LOAD_DEFAULT,
this.cursiveFontFamily = "cursive", this.defaultFixedFontSize = 16, this.defaultFontSize = 16, this.defaultTextEncodingName = "UTF-8", this.cursiveFontFamily = "cursive", this.defaultFixedFontSize = 16, this.defaultFontSize = 16, this.defaultTextEncodingName = "UTF-8",
this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", this.forceDark = AndroidInAppWebViewForceDark.FORCE_DARK_OFF, this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", this.forceDark = AndroidInAppWebViewForceDark.FORCE_DARK_OFF,
this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, this.loadsImagesAutomatically = true, this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, this.loadsImagesAutomatically = true,
this.minimumLogicalFontSize = 8, this.needInitialFocus = true, this.offscreenPreRaster = false, this.sansSerifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif", this.minimumLogicalFontSize = 8, this.needInitialFocus = true, this.offscreenPreRaster = false, this.sansSerifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif",
this.standardFontFamily = "sans-serif", this.saveFormData = true, this.thirdPartyCookiesEnabled = true, this.hardwareAcceleration = true, this.initialScale this.standardFontFamily = "sans-serif", this.saveFormData = true, this.thirdPartyCookiesEnabled = true, this.hardwareAcceleration = true, this.initialScale = 0
}); });
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
"textZoom": textZoom,
"clearSessionCache": clearSessionCache, "clearSessionCache": clearSessionCache,
"builtInZoomControls": builtInZoomControls, "builtInZoomControls": builtInZoomControls,
"displayZoomControls": displayZoomControls, "displayZoomControls": displayZoomControls,
@ -243,6 +363,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
@override @override
static AndroidInAppWebViewOptions fromMap(Map<String, dynamic> map) { static AndroidInAppWebViewOptions fromMap(Map<String, dynamic> map) {
AndroidInAppWebViewOptions options = new AndroidInAppWebViewOptions(); AndroidInAppWebViewOptions options = new AndroidInAppWebViewOptions();
options.textZoom = map["textZoom"];
options.clearSessionCache = map["clearSessionCache"]; options.clearSessionCache = map["clearSessionCache"];
options.builtInZoomControls = map["builtInZoomControls"]; options.builtInZoomControls = map["builtInZoomControls"];
options.displayZoomControls = map["displayZoomControls"]; options.displayZoomControls = map["displayZoomControls"];
@ -286,19 +407,51 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
} }
} }
///This class represents all the iOS-only WebView options available.
class IosInAppWebViewOptions implements WebViewOptions, BrowserOptions, IosOptions { class IosInAppWebViewOptions implements WebViewOptions, BrowserOptions, IosOptions {
///Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
bool disallowOverScroll; bool disallowOverScroll;
///Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
bool enableViewportScale; bool enableViewportScale;
///Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`.
bool suppressesIncrementalRendering; bool suppressesIncrementalRendering;
///Set to `true` to allow AirPlay. The default value is `true`.
bool allowsAirPlayForMediaPlayback; bool allowsAirPlayForMediaPlayback;
///Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
bool allowsBackForwardNavigationGestures; bool allowsBackForwardNavigationGestures;
///Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
bool allowsLinkPreview; bool allowsLinkPreview;
///Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent.
///The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
bool ignoresViewportScaleLimits; bool ignoresViewportScaleLimits;
///Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls.
///For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
bool allowsInlineMediaPlayback; bool allowsInlineMediaPlayback;
///Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
///
///**NOTE**: available on iOS 9.0+.
bool allowsPictureInPictureMediaPlayback; bool allowsPictureInPictureMediaPlayback;
///A Boolean value indicating whether warnings should be shown for suspected fraudulent content such as phishing or malware.
///According to the official documentation, this feature is currently available in the following region: China.
///The default value is `true`.
///
///**NOTE**: available on iOS 13.0+.
bool isFraudulentWebsiteWarningEnabled; bool isFraudulentWebsiteWarningEnabled;
///The level of granularity with which the user can interactively select content in the web view.
///The default value is [IosInAppWebViewSelectionGranularity.DYNAMIC]
IosInAppWebViewSelectionGranularity selectionGranularity; IosInAppWebViewSelectionGranularity selectionGranularity;
///Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value.
///For example, Safari adds a link to apple.com in the text Visit apple.com if the dataDetectorTypes property is set to [IosInAppWebViewDataDetectorTypes.LINK].
///The default value is [IosInAppWebViewDataDetectorTypes.NONE].
///
///**NOTE**: available on iOS 10.0+.
List<IosInAppWebViewDataDetectorTypes> dataDetectorTypes; List<IosInAppWebViewDataDetectorTypes> dataDetectorTypes;
///Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView.
///The default value is `false`.
///
///**NOTE**: available on iOS 11.0+.
bool sharedCookiesEnabled; bool sharedCookiesEnabled;
IosInAppWebViewOptions({this.disallowOverScroll = false, this.enableViewportScale = false, this.suppressesIncrementalRendering = false, this.allowsAirPlayForMediaPlayback = true, IosInAppWebViewOptions({this.disallowOverScroll = false, this.enableViewportScale = false, this.suppressesIncrementalRendering = false, this.allowsAirPlayForMediaPlayback = true,
@ -357,14 +510,19 @@ class IosInAppWebViewOptions implements WebViewOptions, BrowserOptions, IosOptio
} }
} }
///This class represents all the cross-platform [InAppBrowser] options available.
class InAppBrowserOptions implements BrowserOptions, AndroidOptions, IosOptions { class InAppBrowserOptions implements BrowserOptions, AndroidOptions, IosOptions {
///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally.
///The default value is `false`.
bool hidden; bool hidden;
///Set to `false` to hide the toolbar at the top of the WebView. The default value is `true`.
bool toolbarTop; bool toolbarTop;
///Set the custom background color of the toolbar at the top.
String toolbarTopBackgroundColor; String toolbarTopBackgroundColor;
String toolbarTopFixedTitle; ///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
bool hideUrlBar; bool hideUrlBar;
InAppBrowserOptions({this.hidden = false, this.toolbarTop = true, this.toolbarTopBackgroundColor = "", this.toolbarTopFixedTitle = "", this.hideUrlBar = false}); InAppBrowserOptions({this.hidden = false, this.toolbarTop = true, this.toolbarTopBackgroundColor = "", this.hideUrlBar = false});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -372,7 +530,6 @@ class InAppBrowserOptions implements BrowserOptions, AndroidOptions, IosOptions
"hidden": hidden, "hidden": hidden,
"toolbarTop": toolbarTop, "toolbarTop": toolbarTop,
"toolbarTopBackgroundColor": toolbarTopBackgroundColor, "toolbarTopBackgroundColor": toolbarTopBackgroundColor,
"toolbarTopFixedTitle": toolbarTopFixedTitle,
"hideUrlBar": hideUrlBar "hideUrlBar": hideUrlBar
}; };
} }
@ -383,23 +540,29 @@ class InAppBrowserOptions implements BrowserOptions, AndroidOptions, IosOptions
options.hidden = map["hidden"]; options.hidden = map["hidden"];
options.toolbarTop = map["toolbarTop"]; options.toolbarTop = map["toolbarTop"];
options.toolbarTopBackgroundColor = map["toolbarTopBackgroundColor"]; options.toolbarTopBackgroundColor = map["toolbarTopBackgroundColor"];
options.toolbarTopFixedTitle = map["toolbarTopFixedTitle"];
options.hideUrlBar = map["hideUrlBar"]; options.hideUrlBar = map["hideUrlBar"];
return options; return options;
} }
} }
///This class represents all the Android-only [InAppBrowser] options available.
class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions { class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions {
///Set to `true` if you want the title should be displayed. The default value is `false`.
bool hideTitleBar; bool hideTitleBar;
///Set the action bar's title.
String toolbarTopFixedTitle;
///Set to `false` to not close the InAppBrowser when the user click on the back button and the WebView cannot go back to the history. The default value is `true`.
bool closeOnCannotGoBack; bool closeOnCannotGoBack;
///Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
bool progressBar; bool progressBar;
AndroidInAppBrowserOptions({this.hideTitleBar = true, this.closeOnCannotGoBack = true, this.progressBar = true}); AndroidInAppBrowserOptions({this.hideTitleBar = true, this.toolbarTopFixedTitle = "", this.closeOnCannotGoBack = true, this.progressBar = true});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
"hideTitleBar": hideTitleBar, "hideTitleBar": hideTitleBar,
"toolbarTopFixedTitle": toolbarTopFixedTitle,
"closeOnCannotGoBack": closeOnCannotGoBack, "closeOnCannotGoBack": closeOnCannotGoBack,
"progressBar": progressBar, "progressBar": progressBar,
}; };
@ -409,20 +572,30 @@ class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions {
static AndroidInAppBrowserOptions fromMap(Map<String, dynamic> map) { static AndroidInAppBrowserOptions fromMap(Map<String, dynamic> map) {
AndroidInAppBrowserOptions options = new AndroidInAppBrowserOptions(); AndroidInAppBrowserOptions options = new AndroidInAppBrowserOptions();
options.hideTitleBar = map["hideTitleBar"]; options.hideTitleBar = map["hideTitleBar"];
options.toolbarTopFixedTitle = map["toolbarTopFixedTitle"];
options.closeOnCannotGoBack = map["closeOnCannotGoBack"]; options.closeOnCannotGoBack = map["closeOnCannotGoBack"];
options.progressBar = map["progressBar"]; options.progressBar = map["progressBar"];
return options; return options;
} }
} }
///This class represents all the iOS-only [InAppBrowser] options available.
class IosInAppBrowserOptions implements BrowserOptions, IosOptions { class IosInAppBrowserOptions implements BrowserOptions, IosOptions {
///Set to `false` to hide the toolbar at the bottom of the WebView. The default value is `true`.
bool toolbarBottom; bool toolbarBottom;
///Set the custom background color of the toolbar at the bottom.
String toolbarBottomBackgroundColor; String toolbarBottomBackgroundColor;
///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
bool toolbarBottomTranslucent; bool toolbarBottomTranslucent;
///Set the custom text for the close button.
String closeButtonCaption; String closeButtonCaption;
///Set the custom color for the close button.
String closeButtonColor; String closeButtonColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [IosWebViewOptionsPresentationStyle.FULL_SCREEN].
IosWebViewOptionsPresentationStyle presentationStyle; IosWebViewOptionsPresentationStyle presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [IosWebViewOptionsTransitionStyle.COVER_VERTICAL].
IosWebViewOptionsTransitionStyle transitionStyle; IosWebViewOptionsTransitionStyle transitionStyle;
///Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
bool spinner; bool spinner;
IosInAppBrowserOptions({this.toolbarBottom = true, this.toolbarBottomBackgroundColor = "", this.toolbarBottomTranslucent = true, this.closeButtonCaption = "", IosInAppBrowserOptions({this.toolbarBottom = true, this.toolbarBottomBackgroundColor = "", this.toolbarBottomTranslucent = true, this.closeButtonCaption = "",
@ -458,11 +631,17 @@ class IosInAppBrowserOptions implements BrowserOptions, IosOptions {
} }
} }
///This class represents all the Android-only [ChromeSafariBrowser] options available.
class AndroidChromeCustomTabsOptions implements ChromeSafariBrowserOptions, AndroidOptions { class AndroidChromeCustomTabsOptions implements ChromeSafariBrowserOptions, AndroidOptions {
///Set to `false` if you don't want the default share button. The default value is `true`.
bool addShareButton; bool addShareButton;
///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
bool showTitle; bool showTitle;
///Set the custom background color of the toolbar.
String toolbarBackgroundColor; String toolbarBackgroundColor;
///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
bool enableUrlBarHiding; bool enableUrlBarHiding;
///Set to `true` to enable Instant Apps. The default value is `false`.
bool instantAppsEnabled; bool instantAppsEnabled;
AndroidChromeCustomTabsOptions({this.addShareButton = true, this.showTitle = true, this.toolbarBackgroundColor = "", this.enableUrlBarHiding = false, this.instantAppsEnabled = false}); AndroidChromeCustomTabsOptions({this.addShareButton = true, this.showTitle = true, this.toolbarBackgroundColor = "", this.enableUrlBarHiding = false, this.instantAppsEnabled = false});
@ -490,13 +669,27 @@ class AndroidChromeCustomTabsOptions implements ChromeSafariBrowserOptions, Andr
} }
} }
///This class represents all the iOS-only [ChromeSafariBrowser] options available.
class IosSafariOptions implements ChromeSafariBrowserOptions, IosOptions { class IosSafariOptions implements ChromeSafariBrowserOptions, IosOptions {
///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
bool entersReaderIfAvailable; bool entersReaderIfAvailable;
///Set to `true` to enable bar collapsing. The default value is `false`.
bool barCollapsingEnabled; bool barCollapsingEnabled;
///Set the custom style for the dismiss button. The default value is [IosSafariOptionsDismissButtonStyle.DONE].
///
///**NOTE**: available on iOS 11.0+.
IosSafariOptionsDismissButtonStyle dismissButtonStyle; IosSafariOptionsDismissButtonStyle dismissButtonStyle;
///Set the custom background color of the navigation bar and the toolbar.
///
///**NOTE**: available on iOS 10.0+.
String preferredBarTintColor; String preferredBarTintColor;
///Set the custom color of the control buttons on the navigation bar and the toolbar.
///
///**NOTE**: available on iOS 10.0+.
String preferredControlTintColor; String preferredControlTintColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [IosWebViewOptionsPresentationStyle.FULL_SCREEN].
IosWebViewOptionsPresentationStyle presentationStyle; IosWebViewOptionsPresentationStyle presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [IosWebViewOptionsTransitionStyle.COVER_VERTICAL].
IosWebViewOptionsTransitionStyle transitionStyle; IosWebViewOptionsTransitionStyle transitionStyle;
IosSafariOptions({this.entersReaderIfAvailable = false, this.barCollapsingEnabled = false, this.dismissButtonStyle = IosSafariOptionsDismissButtonStyle.DONE, IosSafariOptions({this.entersReaderIfAvailable = false, this.barCollapsingEnabled = false, this.dismissButtonStyle = IosSafariOptionsDismissButtonStyle.DONE,