updated webview options, updated content blockers
This commit is contained in:
parent
3ffa1c0a43
commit
372b771211
|
@ -15,31 +15,22 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlocker.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerAction.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerActionType.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTrigger.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTriggerResourceType.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lib/src/content_blocker.dart" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lib/src/webview_options.dart" 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$/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/ContentBlocker/ContentBlocker.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlocker.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTrigger.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/ContentBlocker/ContentBlockerTrigger.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$/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/JavaScriptBridgeInterface.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/JavaScriptBridgeInterface.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/android/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/app/src/main/AndroidManifest.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.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/chrome_safari_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/chrome_safari_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$/example/lib/test.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/test.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/example/lib/webview_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/webview_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/InAppBrowserWebViewController.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.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/flutter_inappbrowser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/content_blocker.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/content_blocker.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/in_app_browser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_browser.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/types.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/types.dart" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/web_history.dart" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lib/src/webview_options.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/webview_options.dart" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.dart_tool/" />
|
||||
<ignored path="$PROJECT_DIR$/.idea/" />
|
||||
|
@ -59,15 +50,6 @@
|
|||
<component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_3_XL_API_24" />
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret line="14" column="16" selection-start-line="14" selection-start-column="16" selection-end-line="14" selection-end-column="16" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
|
@ -80,8 +62,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="210">
|
||||
<caret line="14" column="92" selection-start-line="14" selection-start-column="92" selection-end-line="14" selection-end-column="92" />
|
||||
<state relative-caret-position="165">
|
||||
<caret line="11" column="55" selection-start-line="11" selection-start-column="37" selection-end-line="11" selection-end-column="55" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -89,20 +71,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="412">
|
||||
<caret line="207" column="32" selection-start-line="207" selection-start-column="6" selection-end-line="207" selection-end-column="32" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="198">
|
||||
<caret line="51" column="52" selection-start-line="51" selection-start-column="52" selection-end-line="51" selection-end-column="52" />
|
||||
<folding>
|
||||
<element signature="e#0#25#0" expanded="true" />
|
||||
</folding>
|
||||
<state relative-caret-position="84">
|
||||
<caret line="93" column="70" selection-start-line="93" selection-start-column="56" selection-end-line="93" selection-end-column="70" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -110,8 +80,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2281">
|
||||
<caret line="331" column="27" selection-start-line="331" selection-start-column="22" selection-end-line="331" selection-end-column="27" />
|
||||
<state relative-caret-position="457">
|
||||
<caret line="139" column="27" selection-start-line="139" selection-start-column="13" selection-end-line="139" selection-end-column="27" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -119,11 +89,35 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</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="135">
|
||||
<caret line="244" column="66" selection-start-line="244" selection-start-column="66" selection-end-line="244" selection-end-column="66" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/chrome_safari_browser.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="94">
|
||||
<caret line="76" column="41" lean-forward="true" selection-start-line="76" selection-start-column="41" selection-end-line="76" selection-end-column="41" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="870">
|
||||
<caret line="58" column="26" selection-start-line="58" selection-start-column="6" selection-end-line="58" selection-end-column="26" />
|
||||
<state relative-caret-position="462">
|
||||
<caret line="124" column="12" selection-start-line="124" selection-start-column="12" selection-end-line="124" selection-end-column="12" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -131,8 +125,8 @@
|
|||
<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>
|
||||
<caret column="15" selection-start-column="15" selection-end-column="15" />
|
||||
<state relative-caret-position="360">
|
||||
<caret line="35" column="88" selection-start-line="35" selection-start-column="63" selection-end-line="35" selection-end-column="88" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -140,8 +134,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1016">
|
||||
<caret line="126" column="22" selection-start-line="126" selection-start-column="22" selection-end-line="126" selection-end-column="22" />
|
||||
<state relative-caret-position="335">
|
||||
<caret line="68" column="19" selection-start-line="68" selection-start-column="19" selection-end-line="68" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#0#22#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -149,6 +143,18 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="357">
|
||||
<caret line="99" column="26" selection-start-line="99" selection-start-column="26" selection-end-line="99" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
|
@ -161,10 +167,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>test</find>
|
||||
<find>WebResourceResponse</find>
|
||||
<find>onCUstom</find>
|
||||
<find>CustomSchemeResponse</find>
|
||||
<find>initialUrl</find>
|
||||
<find>InAppBrowser</find>
|
||||
<find>onCustomScheme</find>
|
||||
|
@ -187,10 +189,14 @@
|
|||
<find>_hand</find>
|
||||
<find>_ChannelManager</find>
|
||||
<find>onDo</find>
|
||||
<find>options</find>
|
||||
<find>initialData</find>
|
||||
<find>assert</find>
|
||||
<find>Level</find>
|
||||
<find>options</find>
|
||||
<find>options = const {}</find>
|
||||
<find>List<WebViewOptions> options = const []</find>
|
||||
<find>options)</find>
|
||||
<find>WebViewOptions</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>activity.getPreferences(0)</replace>
|
||||
|
@ -233,7 +239,6 @@
|
|||
<option value="$PROJECT_DIR$/android/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/example/android/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/example/assets/page-3.html" />
|
||||
<option value="$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/example/assets/page-2.html" />
|
||||
<option value="$PROJECT_DIR$/example/assets/page-1.html" />
|
||||
<option value="$PROJECT_DIR$/example/assets/css/style.css" />
|
||||
|
@ -247,20 +252,21 @@
|
|||
<option value="$PROJECT_DIR$/lib/src/in_app_localhost_server.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/chrome_safari_browser.dart" />
|
||||
<option value="$PROJECT_DIR$/example/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/src/web_history.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$/lib/src/types.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/test.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/flutter_inappbrowser.dart" />
|
||||
<option value="$PROJECT_DIR$/example/assets/index.html" />
|
||||
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/example/assets/index.html" />
|
||||
<option value="$PROJECT_DIR$/example/lib/inline_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/webview_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -275,7 +281,35 @@
|
|||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="AndroidView">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="InAppWebView" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
|
@ -319,6 +353,7 @@
|
|||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope">
|
||||
<subPane subId="Project Files">
|
||||
<expand>
|
||||
|
@ -330,35 +365,6 @@
|
|||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="AndroidView">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="flutter_inappbrowser" type="1abcf292:AndroidViewProjectNode" />
|
||||
<item name="flutter_inappbrowser_android" type="e9137016:NonAndroidModuleNode" />
|
||||
<item name="java" type="f7eae187:NonAndroidSourceTypeNode" />
|
||||
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="InAppWebView" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
|
@ -509,10 +515,11 @@
|
|||
</todo-panel>
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1920" height="1057" extended-state="0" />
|
||||
<frame x="0" y="23" width="1920" height="1057" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.60902256" visible="true" weight="0.15867944" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.39097744" side_tool="true" visible="true" weight="0.15867944" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.6088957" visible="true" weight="0.15867944" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.39110428" side_tool="true" visible="true" weight="0.15867944" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info id="Build Variants" order="3" side_tool="true" />
|
||||
<window_info id="Captures" order="4" side_tool="true" weight="0.32936507" />
|
||||
|
@ -522,7 +529,7 @@
|
|||
<window_info id="Resources Explorer" order="8" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32642487" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49361023" weight="0.46424872" />
|
||||
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49361023" visible="true" weight="0.32435232" />
|
||||
<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="Inspection" order="5" weight="0.4" />
|
||||
|
@ -530,7 +537,7 @@
|
|||
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.5063898" side_tool="true" weight="0.373057" />
|
||||
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32953367" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" visible="true" weight="0.5865285" />
|
||||
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49533224" weight="0.19792746" />
|
||||
<window_info anchor="bottom" id="Logcat" order="11" weight="0.32953367" />
|
||||
<window_info anchor="bottom" id="Messages" order="12" weight="0.226943" />
|
||||
<window_info anchor="bottom" id="Dependency Viewer" order="13" weight="0.32800853" />
|
||||
|
@ -558,13 +565,6 @@
|
|||
</ignored-roots>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/android/gradle/wrapper/gradle-wrapper.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="75">
|
||||
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/ios/Flutter/App.framework/Info.plist">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
|
@ -726,16 +726,6 @@
|
|||
</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="405">
|
||||
<caret line="27" column="25" selection-start-line="27" selection-start-column="25" selection-end-line="27" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="299">
|
||||
|
@ -770,19 +760,7 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/web_history.dart">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="208">
|
||||
<caret line="49" column="49" selection-start-line="49" selection-start-column="49" selection-end-line="49" selection-end-column="49" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/web_history.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="405">
|
||||
|
@ -795,23 +773,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret line="14" column="16" selection-start-line="14" selection-start-column="16" selection-end-line="14" selection-end-column="16" />
|
||||
</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="277">
|
||||
<caret line="301" column="3" selection-start-line="301" selection-start-column="3" selection-end-line="301" selection-end-column="3" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-279">
|
||||
|
@ -819,10 +780,34 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart">
|
||||
<entry file="file://$USER_HOME$/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="435">
|
||||
<caret line="32" column="22" selection-start-line="32" selection-start-column="22" selection-end-line="32" selection-end-column="22" />
|
||||
<state relative-caret-position="249">
|
||||
<caret line="306" column="10" selection-start-line="306" selection-start-column="10" selection-end-line="306" selection-end-column="10" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="45">
|
||||
<caret line="51" column="52" selection-start-line="51" selection-start-column="52" selection-end-line="51" selection-end-column="52" />
|
||||
<folding>
|
||||
<element signature="e#0#25#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret line="14" column="16" selection-start-line="14" selection-start-column="16" selection-end-line="14" selection-end-column="16" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="165">
|
||||
<caret line="11" column="55" selection-start-line="11" selection-start-column="37" selection-end-line="11" selection-end-column="55" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -833,41 +818,34 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="210">
|
||||
<caret line="14" column="92" selection-start-line="14" selection-start-column="92" selection-end-line="14" selection-end-column="92" />
|
||||
<state relative-caret-position="417">
|
||||
<caret line="41" column="66" selection-start-line="41" selection-start-column="61" selection-end-line="41" selection-end-column="66" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<caret column="15" selection-start-column="15" selection-end-column="15" />
|
||||
<state relative-caret-position="360">
|
||||
<caret line="35" column="88" selection-start-line="35" selection-start-column="63" selection-end-line="35" selection-end-column="88" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/webview_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2281">
|
||||
<caret line="331" column="27" selection-start-line="331" selection-start-column="22" selection-end-line="331" selection-end-column="27" />
|
||||
<state relative-caret-position="357">
|
||||
<caret line="99" column="26" selection-start-line="99" selection-start-column="26" selection-end-line="99" selection-end-column="26" />
|
||||
<folding>
|
||||
<element signature="e#0#17#0" expanded="true" />
|
||||
<element signature="e#0#20#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="412">
|
||||
<caret line="207" column="32" selection-start-line="207" selection-start-column="6" selection-end-line="207" selection-end-column="32" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/lib/inline_example.screen.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1016">
|
||||
<caret line="126" column="22" selection-start-line="126" selection-start-column="22" selection-end-line="126" selection-end-column="22" />
|
||||
<state relative-caret-position="335">
|
||||
<caret line="68" column="19" selection-start-line="68" selection-start-column="19" selection-end-line="68" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#0#22#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -876,17 +854,44 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="870">
|
||||
<caret line="58" column="26" selection-start-line="58" selection-start-column="6" selection-end-line="58" selection-end-column="26" />
|
||||
<state relative-caret-position="462">
|
||||
<caret line="124" column="12" selection-start-line="124" selection-start-column="12" selection-end-line="124" selection-end-column="12" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/types.dart">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="198">
|
||||
<caret line="51" column="52" selection-start-line="51" selection-start-column="52" selection-end-line="51" selection-end-column="52" />
|
||||
<state relative-caret-position="457">
|
||||
<caret line="139" column="27" selection-start-line="139" selection-start-column="13" selection-end-line="139" selection-end-column="27" />
|
||||
<folding>
|
||||
<element signature="e#0#25#0" expanded="true" />
|
||||
<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="84">
|
||||
<caret line="93" column="70" selection-start-line="93" selection-start-column="56" selection-end-line="93" selection-end-column="70" />
|
||||
</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="135">
|
||||
<caret line="244" column="66" selection-start-line="244" selection-start-column="66" selection-end-line="244" selection-end-column="66" />
|
||||
<folding>
|
||||
<element signature="e#0#20#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="94">
|
||||
<caret line="76" column="41" lean-forward="true" selection-start-line="76" selection-start-column="41" selection-end-line="76" selection-end-column="41" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
@ -11,8 +11,11 @@ import com.pichillilorenzo.flutter_inappbrowser.InAppWebView.InAppWebView;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -22,10 +25,15 @@ import okhttp3.Response;
|
|||
public class ContentBlocker {
|
||||
protected static final String LOG_TAG = "ContentBlocker";
|
||||
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url, ContentBlockerTriggerResourceType responseResourceType) {
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url, ContentBlockerTriggerResourceType responseResourceType) throws URISyntaxException, InterruptedException {
|
||||
if (webView.options.contentBlockers == null)
|
||||
return null;
|
||||
|
||||
URI u = new URI(url);
|
||||
String host = u.getHost();
|
||||
int port = u.getPort();
|
||||
String scheme = u.getScheme();
|
||||
|
||||
for (Map<String, Map<String, Object>> contentBlocker : webView.options.contentBlockers) {
|
||||
ContentBlockerTrigger trigger = ContentBlockerTrigger.fromMap(contentBlocker.get("trigger"));
|
||||
List<ContentBlockerTriggerResourceType> resourceTypes = trigger.resourceType;
|
||||
|
@ -36,13 +44,68 @@ public class ContentBlocker {
|
|||
Matcher m = mPattern.matcher(url);
|
||||
|
||||
if (m.matches()) {
|
||||
Log.d(LOG_TAG, url);
|
||||
Log.d(LOG_TAG, responseResourceType.toString());
|
||||
Log.d(LOG_TAG, resourceTypes.toString());
|
||||
|
||||
if (resourceTypes != null && resourceTypes.size() > 0 && !resourceTypes.contains(responseResourceType)) {
|
||||
if (!resourceTypes.isEmpty() && !resourceTypes.contains(responseResourceType)) {
|
||||
return null;
|
||||
}
|
||||
if (!trigger.ifDomain.isEmpty()) {
|
||||
boolean matchFound = false;
|
||||
for (String domain : trigger.ifDomain) {
|
||||
if ((domain.startsWith("*") && host.endsWith(domain.replace("*", ""))) || domain.equals(host)) {
|
||||
matchFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matchFound)
|
||||
return null;
|
||||
}
|
||||
if (!trigger.unlessDomain.isEmpty()) {
|
||||
for (String domain : trigger.unlessDomain)
|
||||
if ((domain.startsWith("*") && host.endsWith(domain.replace("*", ""))) || domain.equals(host))
|
||||
return null;
|
||||
}
|
||||
|
||||
final String[] webViewUrl = new String[1];
|
||||
if (!trigger.loadType.isEmpty() || !trigger.ifTopUrl.isEmpty() || !trigger.unlessTopUrl.isEmpty()) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
webViewUrl[0] = webView.getUrl();
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
latch.await();
|
||||
}
|
||||
|
||||
if (!trigger.loadType.isEmpty()) {
|
||||
URI cUrl = new URI(webViewUrl[0]);
|
||||
String cHost = cUrl.getHost();
|
||||
int cPort = cUrl.getPort();
|
||||
String cScheme = cUrl.getScheme();
|
||||
|
||||
if ( (trigger.loadType.contains("first-party") && cHost != null && !(cScheme.equals(scheme) && cHost.equals(host) && cPort == port)) ||
|
||||
(trigger.loadType.contains("third-party") && cHost != null && cHost.equals(host)) )
|
||||
return null;
|
||||
}
|
||||
if (!trigger.ifTopUrl.isEmpty()) {
|
||||
boolean matchFound = false;
|
||||
for (String topUrl : trigger.ifTopUrl) {
|
||||
if (webViewUrl[0].equals(topUrl)) {
|
||||
matchFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matchFound)
|
||||
return null;
|
||||
}
|
||||
if (!trigger.unlessTopUrl.isEmpty()) {
|
||||
for (String topUrl : trigger.unlessTopUrl)
|
||||
if (webViewUrl[0].equals(topUrl))
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
|
||||
case BLOCK:
|
||||
|
@ -103,12 +166,12 @@ public class ContentBlocker {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url) {
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url) throws URISyntaxException, InterruptedException {
|
||||
ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromUrl(webView, url);
|
||||
return checkUrl(webView, url, responseResourceType);
|
||||
}
|
||||
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url, String contentType) {
|
||||
public static WebResourceResponse checkUrl(final InAppWebView webView, String url, String contentType) throws URISyntaxException, InterruptedException {
|
||||
ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromContentType(contentType);
|
||||
return checkUrl(webView, url, responseResourceType);
|
||||
}
|
||||
|
@ -141,6 +204,7 @@ public class ContentBlocker {
|
|||
response.close();
|
||||
}
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
return responseResourceType;
|
||||
|
|
|
@ -7,21 +7,45 @@ import java.util.Map;
|
|||
public class ContentBlockerTrigger {
|
||||
|
||||
public String urlFilter;
|
||||
List<ContentBlockerTriggerResourceType> resourceType = new ArrayList<>();
|
||||
public Boolean urlFilterIsCaseSensitive;
|
||||
public List<ContentBlockerTriggerResourceType> resourceType = new ArrayList<>();
|
||||
public List<String> ifDomain = new ArrayList<>();
|
||||
public List<String> unlessDomain = new ArrayList<>();
|
||||
public List<String> loadType = new ArrayList<>();
|
||||
public List<String> ifTopUrl = new ArrayList<>();
|
||||
public List<String> unlessTopUrl = new ArrayList<>();
|
||||
|
||||
public ContentBlockerTrigger(String urlFilter, List<ContentBlockerTriggerResourceType> resourceType) {
|
||||
public ContentBlockerTrigger(String urlFilter, Boolean urlFilterIsCaseSensitive, List<ContentBlockerTriggerResourceType> resourceType, List<String> ifDomain,
|
||||
List<String> unlessDomain, List<String> loadType, List<String> ifTopUrl, List<String> unlessTopUrl) {
|
||||
this.urlFilter = urlFilter;
|
||||
this.resourceType = resourceType != null ? resourceType : this.resourceType;
|
||||
this.urlFilterIsCaseSensitive = urlFilterIsCaseSensitive != null ? urlFilterIsCaseSensitive : false;
|
||||
this.ifDomain = ifDomain != null ? ifDomain : this.ifDomain;
|
||||
this.unlessDomain = unlessDomain != null ? unlessDomain : this.unlessDomain;
|
||||
if ((!(this.ifDomain.isEmpty() || this.unlessDomain.isEmpty()) != false))
|
||||
throw new AssertionError();
|
||||
this.loadType = loadType != null ? loadType : this.loadType;
|
||||
if ((this.loadType.size() > 2)) throw new AssertionError();
|
||||
this.ifTopUrl = ifTopUrl != null ? ifTopUrl : this.ifTopUrl;
|
||||
this.unlessTopUrl = unlessTopUrl != null ? unlessTopUrl : this.unlessTopUrl;
|
||||
if ((!(this.ifTopUrl.isEmpty() || this.unlessTopUrl.isEmpty()) != false))
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static ContentBlockerTrigger fromMap(Map<String, Object> map) {
|
||||
String urlFilter = (String) map.get("url-filter");
|
||||
Boolean urlFilterIsCaseSensitive = (Boolean) map.get("url-filter-is-case-sensitive");
|
||||
List<String> resourceTypeStringList = (List<String>) map.get("resource-type");
|
||||
List<ContentBlockerTriggerResourceType> resourceType = new ArrayList<>();
|
||||
for (String type : resourceTypeStringList) {
|
||||
resourceType.add(ContentBlockerTriggerResourceType.fromValue(type));
|
||||
}
|
||||
return new ContentBlockerTrigger(urlFilter, resourceType);
|
||||
List<String> ifDomain = (List<String>) map.get("if-domain");
|
||||
List<String> unlessDomain = (List<String>) map.get("unless-domain");
|
||||
List<String> loadType = (List<String>) map.get("load-type");
|
||||
List<String> ifTopUrl = (List<String>) map.get("if-top-url");
|
||||
List<String> unlessTopUrl = (List<String>) map.get("unless-top-url");
|
||||
return new ContentBlockerTrigger(urlFilter, urlFilterIsCaseSensitive, resourceType, ifDomain, unlessDomain, loadType, ifTopUrl, unlessTopUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import com.pichillilorenzo.flutter_inappbrowser.JavaScriptBridgeInterface;
|
|||
import com.pichillilorenzo.flutter_inappbrowser.Util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -317,14 +319,27 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
obj.put("url", url);
|
||||
obj.put("scheme", scheme);
|
||||
|
||||
Util.WaitFlutterResult flutterResult = Util.invokeMethodAndWait(getChannel(), "onLoadResourceCustomScheme", obj);
|
||||
Util.WaitFlutterResult flutterResult;
|
||||
try {
|
||||
flutterResult = Util.invokeMethodAndWait(getChannel(), "onLoadResourceCustomScheme", obj);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (flutterResult.error != null) {
|
||||
Log.d(LOG_TAG, flutterResult.error);
|
||||
Log.e(LOG_TAG, flutterResult.error);
|
||||
}
|
||||
else if (flutterResult.result != null) {
|
||||
Map<String, String> res = (Map<String, String>) flutterResult.result;
|
||||
WebResourceResponse response = ContentBlocker.checkUrl(webView, url, res.get("content-type"));
|
||||
WebResourceResponse response = null;
|
||||
try {
|
||||
response = ContentBlocker.checkUrl(webView, url, res.get("content-type"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
}
|
||||
if (response != null)
|
||||
return response;
|
||||
byte[] data = Base64.decode(res.get("base64data"), Base64.DEFAULT);
|
||||
|
@ -332,7 +347,13 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
}
|
||||
}
|
||||
|
||||
WebResourceResponse response = ContentBlocker.checkUrl(webView, url);
|
||||
WebResourceResponse response = null;
|
||||
try {
|
||||
response = ContentBlocker.checkUrl(webView, url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry;
|
||||
|
@ -44,11 +45,12 @@ public class Util {
|
|||
return ANDROID_ASSET_URL + key;
|
||||
}
|
||||
|
||||
public static WaitFlutterResult invokeMethodAndWait(final MethodChannel channel, final String method, final Object arguments) {
|
||||
public static WaitFlutterResult invokeMethodAndWait(final MethodChannel channel, final String method, final Object arguments) throws InterruptedException {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
final Map<String, Object> flutterResultMap = new HashMap<>();
|
||||
flutterResultMap.put("result", null);
|
||||
flutterResultMap.put("error", null);
|
||||
flutterResultMap.put("isBlocking", true);
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
|
@ -58,27 +60,25 @@ public class Util {
|
|||
@Override
|
||||
public void success(Object result) {
|
||||
flutterResultMap.put("result", result);
|
||||
flutterResultMap.put("isBlocking", false);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String s, String s1, Object o) {
|
||||
flutterResultMap.put("error", "ERROR: " + s + " " + s1);
|
||||
flutterResultMap.put("result", o);
|
||||
flutterResultMap.put("isBlocking", false);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notImplemented() {
|
||||
flutterResultMap.put("isBlocking", false);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
while((Boolean) flutterResultMap.get("isBlocking")) {
|
||||
// block until flutter side returns
|
||||
}
|
||||
latch.await();
|
||||
|
||||
return new WaitFlutterResult(flutterResultMap.get("result"), (String) flutterResultMap.get("error"));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
<h1 class="cover-heading">Inline WebView</h1>
|
||||
<img src="my-special-custom-scheme://images/flutter-logo.svg" alt="flutter logo">
|
||||
<p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.</p>
|
||||
<p class="lead">
|
||||
<a href="#" class="btn btn-lg btn-secondary">Learn more</a>
|
||||
<p>
|
||||
<img src="https://via.placeholder.com/100x50" alt="placeholder 100x50">
|
||||
</p>
|
||||
</main>
|
||||
|
||||
|
@ -54,6 +54,9 @@
|
|||
console.log(JSON.stringify(result));
|
||||
});
|
||||
});
|
||||
$(document).ready(function() {
|
||||
console.log("jQuery ready");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -38,7 +38,10 @@ class _ChromeSafariExampleScreenState extends State<ChromeSafariExampleScreen> {
|
|||
return new Center(
|
||||
child: new RaisedButton(
|
||||
onPressed: () async {
|
||||
await widget.browser.open("https://flutter.dev/");
|
||||
await widget.browser.open("https://flutter.dev/", options: [
|
||||
AndroidChromeCustomTabsOptions(addShareButton: false),
|
||||
iOSChromeCustomTabsOptions(barCollapsingEnabled: true)
|
||||
]);
|
||||
},
|
||||
child: Text("Open Chrome Safari Browser")),
|
||||
);
|
||||
|
|
|
@ -74,7 +74,9 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
|
|||
resourceCustomSchemes: ["my-special-custom-scheme"],
|
||||
contentBlockers: [
|
||||
ContentBlocker(
|
||||
ContentBlockerTrigger(".*", resourceType: [ContentBlockerTriggerResourceType.IMAGE]),
|
||||
ContentBlockerTrigger(".*",
|
||||
resourceType: [ContentBlockerTriggerResourceType.IMAGE, ContentBlockerTriggerResourceType.STYLE_SHEET],
|
||||
ifTopUrl: ["https://getbootstrap.com/"]),
|
||||
ContentBlockerAction(ContentBlockerActionType.BLOCK)
|
||||
)
|
||||
]
|
||||
|
|
|
@ -97,10 +97,12 @@ class _WebviewExampleScreenState extends State<WebviewExampleScreen> {
|
|||
onPressed: () {
|
||||
widget.browser.open(
|
||||
url: "https://www.google.com/",
|
||||
options: {
|
||||
"useShouldOverrideUrlLoading": true,
|
||||
"useOnLoadResource": true,
|
||||
}
|
||||
options: [
|
||||
InAppWebViewOptions(
|
||||
useShouldOverrideUrlLoading: true,
|
||||
useOnLoadResource: true,
|
||||
)
|
||||
]
|
||||
);
|
||||
},
|
||||
child: Text("Open Webview Browser")),
|
||||
|
|
|
@ -38,6 +38,39 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
|
|||
webView!.options = options
|
||||
webView!.prepare()
|
||||
|
||||
if #available(iOS 11.0, *) {
|
||||
if let contentBlockers = webView!.options?.contentBlockers {
|
||||
do {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
||||
WKContentRuleListStore.default().compileContentRuleList(
|
||||
forIdentifier: "ContentBlockingRules",
|
||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||
|
||||
if let error = error {
|
||||
print(error.localizedDescription)
|
||||
return
|
||||
}
|
||||
|
||||
let configuration = self.webView!.configuration
|
||||
configuration.userContentController.add(contentRuleList!)
|
||||
|
||||
self.load(initialUrl: initialUrl, initialFile: initialFile, initialData: initialData, initialHeaders: initialHeaders)
|
||||
}
|
||||
return
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
load(initialUrl: initialUrl, initialFile: initialFile, initialData: initialData, initialHeaders: initialHeaders)
|
||||
}
|
||||
|
||||
public func view() -> UIView {
|
||||
return webView!
|
||||
}
|
||||
|
||||
public func load(initialUrl: String, initialFile: String?, initialData: [String: String]?, initialHeaders: [String: String]) {
|
||||
if initialFile != nil {
|
||||
do {
|
||||
try webView!.loadFile(url: initialFile!, headers: initialHeaders)
|
||||
|
@ -60,10 +93,6 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
|
|||
}
|
||||
}
|
||||
|
||||
public func view() -> UIView {
|
||||
return webView!
|
||||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
let arguments = call.arguments as? NSDictionary
|
||||
switch call.method {
|
||||
|
|
|
@ -119,19 +119,50 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
|
|||
prepareConstraints()
|
||||
prepareWebView()
|
||||
|
||||
if self.initData == nil {
|
||||
loadUrl(url: self.initURL!, headers: self.initHeaders)
|
||||
}
|
||||
else {
|
||||
webView.loadData(data: initData!, mimeType: initMimeType!, encoding: initEncoding!, baseUrl: initBaseUrl!)
|
||||
if #available(iOS 11.0, *) {
|
||||
if let contentBlockers = webView!.options?.contentBlockers, contentBlockers.count > 0 {
|
||||
do {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
||||
WKContentRuleListStore.default().compileContentRuleList(
|
||||
forIdentifier: "ContentBlockingRules",
|
||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||
|
||||
if let error = error {
|
||||
print(error.localizedDescription)
|
||||
return
|
||||
}
|
||||
|
||||
let configuration = self.webView!.configuration
|
||||
configuration.userContentController.add(contentRuleList!)
|
||||
|
||||
self.initLoad(initURL: self.initURL, initData: self.initData, initMimeType: self.initMimeType, initEncoding: self.initEncoding, initBaseUrl: self.initBaseUrl, initHeaders: self.initHeaders)
|
||||
|
||||
self.navigationDelegate?.onBrowserCreated(uuid: self.uuid, webView: self.webView)
|
||||
}
|
||||
return
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initLoad(initURL: initURL, initData: initData, initMimeType: initMimeType, initEncoding: initEncoding, initBaseUrl: initBaseUrl, initHeaders: initHeaders)
|
||||
|
||||
navigationDelegate?.onBrowserCreated(uuid: uuid, webView: webView)
|
||||
}
|
||||
viewPrepared = true
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
func initLoad(initURL: URL?, initData: String?, initMimeType: String?, initEncoding: String?, initBaseUrl: String?, initHeaders: [String: String]?) {
|
||||
if self.initData == nil {
|
||||
loadUrl(url: self.initURL!, headers: self.initHeaders)
|
||||
}
|
||||
else {
|
||||
webView.loadData(data: initData!, mimeType: initMimeType!, encoding: initEncoding!, baseUrl: initBaseUrl!)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
|
|
@ -418,6 +418,28 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
|
|||
clearCache()
|
||||
}
|
||||
|
||||
if #available(iOS 11.0, *), newOptionsMap["contentBlockers"] != nil {
|
||||
let contentBlockers = newOptions.contentBlockers
|
||||
configuration.userContentController.removeAllContentRuleLists()
|
||||
if contentBlockers.count > 0 {
|
||||
do {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: contentBlockers, options: [])
|
||||
let blockRules = String(data: jsonData, encoding: String.Encoding.utf8)
|
||||
WKContentRuleListStore.default().compileContentRuleList(
|
||||
forIdentifier: "ContentBlockingRules",
|
||||
encodedContentRuleList: blockRules) { (contentRuleList, error) in
|
||||
if let error = error {
|
||||
print(error.localizedDescription)
|
||||
return
|
||||
}
|
||||
self.configuration.userContentController.add(contentRuleList!)
|
||||
}
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.options = newOptions
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_inappbrowser/src/webview_options.dart';
|
||||
|
||||
import 'types.dart';
|
||||
import 'channel_manager.dart';
|
||||
|
@ -69,16 +70,27 @@ class ChromeSafariBrowser {
|
|||
///- __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, {Map<String, dynamic> options = const {}, Map<String, String> headersFallback = const {}, Map<String, dynamic> optionsFallback = const {}}) async {
|
||||
Future<void> open(String url, {List<ChromeCustomTabsOptions> options = const [], Map<String, String> headersFallback = const {}, List<BrowserOptions> optionsFallback = const []}) async {
|
||||
assert(url != null && url.isNotEmpty);
|
||||
this.throwIsAlreadyOpened(message: 'Cannot open $url!');
|
||||
|
||||
Map<String, dynamic> optionsMap = {};
|
||||
options.forEach((webViewOption) {
|
||||
optionsMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> optionsFallbackMap = {};
|
||||
optionsFallback.forEach((webViewOption) {
|
||||
optionsFallbackMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
args.putIfAbsent('uuidFallback', () => (browserFallback != null) ? browserFallback.uuid : '');
|
||||
args.putIfAbsent('url', () => url);
|
||||
args.putIfAbsent('headers', () => headersFallback);
|
||||
args.putIfAbsent('options', () => options);
|
||||
args.putIfAbsent('optionsFallback', () => optionsFallback);
|
||||
args.putIfAbsent('options', () => optionsMap);
|
||||
args.putIfAbsent('optionsFallback', () => optionsFallbackMap);
|
||||
args.putIfAbsent('isData', () => false);
|
||||
args.putIfAbsent('useChromeSafariBrowser', () => true);
|
||||
await ChannelManager.channel.invokeMethod('open', args);
|
||||
|
|
|
@ -27,22 +27,68 @@ class ContentBlockerTriggerResourceType {
|
|||
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
|
||||
}
|
||||
|
||||
class ContentBlockerTriggerLoadType {
|
||||
final String _value;
|
||||
const ContentBlockerTriggerLoadType._internal(this._value);
|
||||
toString() => _value;
|
||||
|
||||
static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party');
|
||||
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
|
||||
}
|
||||
|
||||
class ContentBlockerTrigger {
|
||||
String urlFilter;
|
||||
bool urlFilterIsCaseSensitive;
|
||||
List<ContentBlockerTriggerResourceType> resourceType;
|
||||
List<String> ifDomain;
|
||||
List<String> unlessDomain;
|
||||
List<ContentBlockerTriggerLoadType> loadType;
|
||||
List<String> ifTopUrl;
|
||||
List<String> unlessTopUrl;
|
||||
|
||||
ContentBlockerTrigger(this.urlFilter, {this.resourceType = const []});
|
||||
ContentBlockerTrigger(String urlFilter, {bool urlFilterIsCaseSensitive = false, List<ContentBlockerTriggerResourceType> resourceType = const [],
|
||||
List<String> ifDomain = const [], List<String> unlessDomain = const [], List<ContentBlockerTriggerLoadType> loadType = const [],
|
||||
List<String> ifTopUrl = const [], List<String> unlessTopUrl = const []}) {
|
||||
this.urlFilter = urlFilter;
|
||||
this.resourceType = resourceType;
|
||||
this.urlFilterIsCaseSensitive = urlFilterIsCaseSensitive;
|
||||
this.ifDomain = ifDomain;
|
||||
this.unlessDomain = unlessDomain;
|
||||
assert(!(this.ifDomain.isEmpty || this.unlessDomain.isEmpty) == false);
|
||||
this.loadType = loadType;
|
||||
assert(this.loadType.length <= 2);
|
||||
this.ifTopUrl = ifTopUrl;
|
||||
this.unlessTopUrl = unlessTopUrl;
|
||||
assert(!(this.ifTopUrl.isEmpty || this.unlessTopUrl.isEmpty) == false);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List<String> resourceTypeStringList = [];
|
||||
resourceType.forEach((type) {
|
||||
resourceTypeStringList.add(type.toString());
|
||||
});
|
||||
List<String> loadTypeStringList = [];
|
||||
loadType.forEach((type) {
|
||||
loadTypeStringList.add(type.toString());
|
||||
});
|
||||
|
||||
return {
|
||||
Map<String, dynamic> map = {
|
||||
"url-filter": urlFilter,
|
||||
"resource-type": resourceTypeStringList
|
||||
"url-filter-is-case-sensitive": urlFilterIsCaseSensitive,
|
||||
"if-domain": ifDomain,
|
||||
"unless-domain": unlessDomain,
|
||||
"resource-type": resourceTypeStringList,
|
||||
"load-type": loadTypeStringList,
|
||||
"if-top-url": ifTopUrl,
|
||||
"unless-top-url": unlessTopUrl
|
||||
};
|
||||
|
||||
map.keys
|
||||
.where((key) => map[key] == null || (map[key] is List && (map[key] as List).length == 0)) // filter keys
|
||||
.toList() // create a copy to avoid concurrent modifications
|
||||
.forEach(map.remove);
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,9 +115,16 @@ class ContentBlockerAction {
|
|||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
Map<String, dynamic> map = {
|
||||
"type": type.toString(),
|
||||
"selector": selector
|
||||
};
|
||||
|
||||
map.keys
|
||||
.where((key) => map[key] == null || (map[key] is List && (map[key] as List).length == 0)) // filter keys
|
||||
.toList() // create a copy to avoid concurrent modifications
|
||||
.forEach(map.remove);
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:collection';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_inappbrowser/src/webview_options.dart';
|
||||
|
||||
import 'types.dart';
|
||||
import 'channel_manager.dart';
|
||||
|
@ -101,14 +102,20 @@ class InAppBrowser {
|
|||
/// - __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 {}, Map<String, dynamic> options = const {}}) async {
|
||||
Future<void> open({String url = "about:blank", Map<String, String> headers = const {}, List<BrowserOptions> options = const []}) async {
|
||||
assert(url != null && url.isNotEmpty);
|
||||
this.throwIsAlreadyOpened(message: 'Cannot open $url!');
|
||||
|
||||
Map<String, dynamic> optionsMap = {};
|
||||
options.forEach((webViewOption) {
|
||||
optionsMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
args.putIfAbsent('url', () => url);
|
||||
args.putIfAbsent('headers', () => headers);
|
||||
args.putIfAbsent('options', () => options);
|
||||
args.putIfAbsent('options', () => optionsMap);
|
||||
args.putIfAbsent('openWithSystemBrowser', () => false);
|
||||
args.putIfAbsent('isLocalFile', () => false);
|
||||
args.putIfAbsent('isData', () => false);
|
||||
|
@ -145,14 +152,20 @@ class InAppBrowser {
|
|||
///inAppBrowser.openFile("assets/index.html");
|
||||
///...
|
||||
///```
|
||||
Future<void> openFile(String assetFilePath, {Map<String, String> headers = const {}, Map<String, dynamic> options = const {}}) async {
|
||||
Future<void> openFile(String assetFilePath, {Map<String, String> headers = const {}, List<BrowserOptions> options = const []}) async {
|
||||
assert(assetFilePath != null && assetFilePath.isNotEmpty);
|
||||
this.throwIsAlreadyOpened(message: 'Cannot open $assetFilePath!');
|
||||
|
||||
Map<String, dynamic> optionsMap = {};
|
||||
options.forEach((webViewOption) {
|
||||
optionsMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
args.putIfAbsent('url', () => assetFilePath);
|
||||
args.putIfAbsent('headers', () => headers);
|
||||
args.putIfAbsent('options', () => options);
|
||||
args.putIfAbsent('options', () => optionsMap);
|
||||
args.putIfAbsent('openWithSystemBrowser', () => false);
|
||||
args.putIfAbsent('isLocalFile', () => true);
|
||||
args.putIfAbsent('isData', () => false);
|
||||
|
@ -163,11 +176,17 @@ class InAppBrowser {
|
|||
///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 [encoding] parameter specifies the encoding of the data.
|
||||
Future<void> openData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", Map<String, dynamic> options = const {}}) async {
|
||||
Future<void> openData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", List<BrowserOptions> options = const []}) async {
|
||||
assert(data != null);
|
||||
|
||||
Map<String, dynamic> optionsMap = {};
|
||||
options.forEach((webViewOption) {
|
||||
optionsMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
args.putIfAbsent('options', () => options);
|
||||
args.putIfAbsent('options', () => optionsMap);
|
||||
args.putIfAbsent('data', () => data);
|
||||
args.putIfAbsent('mimeType', () => mimeType);
|
||||
args.putIfAbsent('encoding', () => encoding);
|
||||
|
@ -227,16 +246,22 @@ class InAppBrowser {
|
|||
}
|
||||
|
||||
///Sets the [InAppBrowser] options with the new [options] and evaluates them.
|
||||
Future<void> setOptions(Map<String, dynamic> options) async {
|
||||
Future<void> setOptions(List<BrowserOptions> options) async {
|
||||
this.throwIsNotOpened();
|
||||
|
||||
Map<String, dynamic> optionsMap = {};
|
||||
options.forEach((webViewOption) {
|
||||
optionsMap.addAll(webViewOption.toMap());
|
||||
});
|
||||
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
args.putIfAbsent('uuid', () => uuid);
|
||||
args.putIfAbsent('options', () => options);
|
||||
args.putIfAbsent('options', () => optionsMap);
|
||||
args.putIfAbsent('optionsType', () => "InAppBrowserOptions");
|
||||
await ChannelManager.channel.invokeMethod('setOptions', args);
|
||||
}
|
||||
|
||||
///Gets the current [InAppBrowser] options. Returns `null` if the options are not setted yet.
|
||||
///Gets the current [InAppBrowser] options as a `Map`. Returns `null` if the options are not setted yet.
|
||||
Future<Map<String, dynamic>> getOptions() async {
|
||||
this.throwIsNotOpened();
|
||||
Map<String, dynamic> args = <String, dynamic>{};
|
||||
|
|
|
@ -6,7 +6,13 @@ class WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class InAppWebViewOptions implements WebViewOptions {
|
||||
class BrowserOptions {
|
||||
Map<String, dynamic> toMap() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class InAppWebViewOptions implements WebViewOptions, BrowserOptions {
|
||||
bool useShouldOverrideUrlLoading;
|
||||
bool useOnLoadResource;
|
||||
bool useOnDownloadStart;
|
||||
|
@ -53,7 +59,7 @@ class InAppWebViewOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class AndroidInAppWebViewOptions implements WebViewOptions {
|
||||
class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions {
|
||||
bool clearSessionCache;
|
||||
bool builtInZoomControls;
|
||||
bool displayZoomControls;
|
||||
|
@ -85,7 +91,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class iOSInAppWebViewOptions implements WebViewOptions {
|
||||
class iOSInAppWebViewOptions implements WebViewOptions, BrowserOptions {
|
||||
bool disallowOverScroll;
|
||||
bool enableViewportScale;
|
||||
bool suppressesIncrementalRendering;
|
||||
|
@ -118,7 +124,7 @@ class iOSInAppWebViewOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class InAppBrowserOptions implements WebViewOptions {
|
||||
class InAppBrowserOptions implements BrowserOptions {
|
||||
bool hidden;
|
||||
bool toolbarTop;
|
||||
String toolbarTopBackgroundColor;
|
||||
|
@ -139,7 +145,7 @@ class InAppBrowserOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class AndroidInAppBrowserOptions implements WebViewOptions {
|
||||
class AndroidInAppBrowserOptions implements BrowserOptions {
|
||||
bool hideTitleBar;
|
||||
bool closeOnCannotGoBack;
|
||||
bool progressBar;
|
||||
|
@ -156,7 +162,7 @@ class AndroidInAppBrowserOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class iOSInAppBrowserOptions implements WebViewOptions {
|
||||
class iOSInAppBrowserOptions implements BrowserOptions {
|
||||
bool toolbarBottom;
|
||||
String toolbarBottomBackgroundColor;
|
||||
bool toolbarBottomTranslucent;
|
||||
|
@ -184,7 +190,13 @@ class iOSInAppBrowserOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class AndroidChromeCustomTabsOptions implements WebViewOptions {
|
||||
class ChromeCustomTabsOptions {
|
||||
Map<String, dynamic> toMap() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class AndroidChromeCustomTabsOptions implements ChromeCustomTabsOptions {
|
||||
bool addShareButton;
|
||||
bool showTitle;
|
||||
String toolbarBackgroundColor;
|
||||
|
@ -205,7 +217,7 @@ class AndroidChromeCustomTabsOptions implements WebViewOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class iOSChromeCustomTabsOptions implements WebViewOptions {
|
||||
class iOSChromeCustomTabsOptions implements ChromeCustomTabsOptions {
|
||||
bool entersReaderIfAvailable;
|
||||
bool barCollapsingEnabled;
|
||||
int dismissButtonStyle; //default done
|
||||
|
|
Loading…
Reference in New Issue