Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Flutter Inappwebview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
Flutter Inappwebview
Commits
40dccfde
Commit
40dccfde
authored
Oct 25, 2018
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getCookies() and getCookie() for Android
parent
35233f09
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
101 deletions
+107
-101
.idea/workspace.xml
.idea/workspace.xml
+37
-94
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
...pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
+28
-6
example/android/build.gradle
example/android/build.gradle
+1
-1
example/lib/main.dart
example/lib/main.dart
+7
-0
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+34
-0
No files found.
.idea/workspace.xml
View file @
40dccfde
...
@@ -15,14 +15,12 @@
...
@@ -15,14 +15,12 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"9b41f7a2-a71e-4923-91fb-249d7815b3e7"
name=
"Default"
comment=
""
>
<list
default=
"true"
id=
"9b41f7a2-a71e-4923-91fb-249d7815b3e7"
name=
"Default"
comment=
""
>
<change
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java"
afterDir=
"false"
/>
<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$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java"
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$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/android/build.gradle"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/android/build.gradle"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/lib/main.dart"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/lib/main.dart"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/lib/main.dart"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/lib/main.dart"
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/flutter_inappbrowser.dart"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/pubspec.yaml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/pubspec.yaml"
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/"
/>
...
@@ -39,11 +37,11 @@
...
@@ -39,11 +37,11 @@
</component>
</component>
<component
name=
"FileEditorManager"
>
<component
name=
"FileEditorManager"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<file
leaf-file-name=
"flutter_inappbrowser.dart"
pinned=
"false"
current-in-tab=
"
fals
e"
>
<file
leaf-file-name=
"flutter_inappbrowser.dart"
pinned=
"false"
current-in-tab=
"
tru
e"
>
<entry
file=
"file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
461
"
>
<state
relative-caret-position=
"
542
"
>
<caret
line=
"11
57"
column=
"19"
selection-start-line=
"1157"
selection-start-column=
"19"
selection-end-line=
"1157"
selection-end-column=
"19
"
/>
<caret
line=
"11
78"
column=
"47"
selection-start-line=
"1178"
selection-start-column=
"38"
selection-end-line=
"1178"
selection-end-column=
"47
"
/>
<folding>
<folding>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
</folding>
</folding>
...
@@ -54,8 +52,8 @@
...
@@ -54,8 +52,8 @@
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"false"
>
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"4
3
2"
>
<state
relative-caret-position=
"4
2
2"
>
<caret
line=
"
273"
column=
"94"
selection-start-line=
"273"
selection-start-column=
"94"
selection-end-line=
"273"
selection-end-column=
"94
"
/>
<caret
line=
"
72"
column=
"67"
selection-start-line=
"72"
selection-start-column=
"67"
selection-end-line=
"72"
selection-end-column=
"67
"
/>
<folding>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
</folding>
</folding>
...
@@ -63,34 +61,6 @@
...
@@ -63,34 +61,6 @@
</provider>
</provider>
</entry>
</entry>
</file>
</file>
<file
leaf-file-name=
"README.md"
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/README.md"
>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
<state
split_layout=
"SPLIT"
>
<first_editor
relative-caret-position=
"525"
>
<caret
line=
"35"
selection-start-line=
"35"
selection-end-line=
"35"
/>
</first_editor>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</provider>
</entry>
</file>
<file
leaf-file-name=
"CHANGELOG.md"
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
<state
split_layout=
"SPLIT"
>
<first_editor
relative-caret-position=
"30"
>
<caret
line=
"2"
column=
"7"
selection-start-line=
"2"
selection-start-column=
"7"
selection-end-line=
"2"
selection-end-column=
"7"
/>
</first_editor>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</provider>
</entry>
</file>
</leaf>
</leaf>
</component>
</component>
<component
name=
"FileTemplateManagerImpl"
>
<component
name=
"FileTemplateManagerImpl"
>
...
@@ -102,10 +72,6 @@
...
@@ -102,10 +72,6 @@
</component>
</component>
<component
name=
"FindInProjectRecents"
>
<component
name=
"FindInProjectRecents"
>
<findStrings>
<findStrings>
<find>
shouldOverrideUrlLoading
</find>
<find>
toolbarTopFixedTitle
</find>
<find>
useChromeSafariBrowser
</find>
<find>
toolbat
</find>
<find>
onProgress
</find>
<find>
onProgress
</find>
<find>
goBack
</find>
<find>
goBack
</find>
<find>
_controller
</find>
<find>
_controller
</find>
...
@@ -132,6 +98,10 @@
...
@@ -132,6 +98,10 @@
<find>
loadData
</find>
<find>
loadData
</find>
<find>
_valide
</find>
<find>
_valide
</find>
<find>
initialized
</find>
<find>
initialized
</find>
<find>
HashMap
</find>
<find>
headers
</find>
<find>
.cast
</find>
<find>
WebView
</find>
</findStrings>
</findStrings>
<replaceStrings>
<replaceStrings>
<replace>
activity.getPreferences(0)
</replace>
<replace>
activity.getPreferences(0)
</replace>
...
@@ -175,9 +145,9 @@
...
@@ -175,9 +145,9 @@
<option
value=
"$PROJECT_DIR$/example/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/example/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/README.md"
/>
<option
value=
"$PROJECT_DIR$/README.md"
/>
<option
value=
"$PROJECT_DIR$/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
/>
<option
value=
"$PROJECT_DIR$/example/lib/main.dart"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
<option
value=
"$PROJECT_DIR$/example/lib/main.dart"
/>
<option
value=
"$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
/>
</list>
</list>
</option>
</option>
</component>
</component>
...
@@ -211,6 +181,7 @@
...
@@ -211,6 +181,7 @@
</subPane>
</subPane>
<option
name=
"show-excluded-files"
value=
"false"
/>
<option
name=
"show-excluded-files"
value=
"false"
/>
</pane>
</pane>
<pane
id=
"AndroidView"
/>
<pane
id=
"Scope"
>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
>
<subPane
subId=
"Project Files"
>
<expand>
<expand>
...
@@ -222,7 +193,6 @@
...
@@ -222,7 +193,6 @@
<select
/>
<select
/>
</subPane>
</subPane>
</pane>
</pane>
<pane
id=
"AndroidView"
/>
</panes>
</panes>
</component>
</component>
<component
name=
"PropertiesComponent"
>
<component
name=
"PropertiesComponent"
>
...
@@ -390,9 +360,9 @@
...
@@ -390,9 +360,9 @@
<window_info
anchor=
"right"
id=
"Capture Analysis"
order=
"4"
/>
<window_info
anchor=
"right"
id=
"Capture Analysis"
order=
"4"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"8"
sideWeight=
"0.5035553"
side_tool=
"true"
weight=
"0.25689086"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"8"
sideWeight=
"0.5035553"
side_tool=
"true"
weight=
"0.25689086"
/>
<window_info
anchor=
"bottom"
id=
"Dart Analysis"
order=
"14"
weight=
"0.3276414"
/>
<window_info
anchor=
"bottom"
id=
"Dart Analysis"
order=
"14"
weight=
"0.3276414"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Run"
order=
"2"
sideWeight=
"0.49644473"
visible=
"true
"
weight=
"0.44503736"
/>
<window_info
a
nchor=
"bottom"
id=
"Run"
order=
"2"
sideWeight=
"0.49644473
"
weight=
"0.44503736"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
a
nchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49644473
"
weight=
"0.30736393"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49644473"
visible=
"true
"
weight=
"0.30736393"
/>
<window_info
anchor=
"right"
id=
"Flutter Outline"
order=
"6"
weight=
"0.32922077"
/>
<window_info
anchor=
"right"
id=
"Flutter Outline"
order=
"6"
weight=
"0.32922077"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"11"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"11"
/>
<window_info
id=
"Captures"
order=
"4"
weight=
"0.32936507"
/>
<window_info
id=
"Captures"
order=
"4"
weight=
"0.32936507"
/>
...
@@ -408,7 +378,7 @@
...
@@ -408,7 +378,7 @@
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"12"
weight=
"0.23692636"
/>
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"12"
weight=
"0.23692636"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Commander"
order=
"0"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Commander"
order=
"0"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Assistant"
order=
"8"
visible=
"true"
weight=
"0.329
87013
"
/>
<window_info
anchor=
"right"
id=
"Assistant"
order=
"8"
visible=
"true"
weight=
"0.329
5129
"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<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=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
...
@@ -646,38 +616,12 @@
...
@@ -646,38 +616,12 @@
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/README.md"
>
<entry
file=
"file://$PROJECT_DIR$/example/README.md"
/>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
<state
split_layout=
"SPLIT"
>
<first_editor
/>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</provider>
</entry>
<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"
>
<state
/>
<state
/>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/README.md"
>
<provider
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"247"
>
<caret
line=
"19"
column=
"15"
selection-start-line=
"19"
selection-start-column=
"3"
selection-end-line=
"19"
selection-end-column=
"15"
/>
</state>
</provider>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
<state
split_layout=
"SPLIT"
>
<first_editor
relative-caret-position=
"525"
>
<caret
line=
"35"
selection-start-line=
"35"
selection-end-line=
"35"
/>
</first_editor>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/pubspec.yaml"
>
<entry
file=
"file://$PROJECT_DIR$/pubspec.yaml"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"105"
>
<state
relative-caret-position=
"105"
>
...
@@ -692,40 +636,39 @@
...
@@ -692,40 +636,39 @@
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/
lib/flutter_inappbrowser.dart
"
>
<entry
file=
"file://$PROJECT_DIR$/
README.md
"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"461"
>
<state
relative-caret-position=
"-3761"
>
<caret
line=
"1157"
column=
"19"
selection-start-line=
"1157"
selection-start-column=
"19"
selection-end-line=
"1157"
selection-end-column=
"19"
/>
<folding>
<folding>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#39#0"
expanded=
"true"
/>
<element
signature=
"e#0#39#0"
expanded=
"true"
/>
</folding>
</folding>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
/>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"4
3
2"
>
<state
relative-caret-position=
"4
2
2"
>
<caret
line=
"
273"
column=
"94"
selection-start-line=
"273"
selection-start-column=
"94"
selection-end-line=
"273"
selection-end-column=
"94
"
/>
<caret
line=
"
72"
column=
"67"
selection-start-line=
"72"
selection-start-column=
"67"
selection-end-line=
"72"
selection-end-column=
"67
"
/>
<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$/CHANGELOG.md"
>
<entry
file=
"file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
>
<provider
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"30"
>
<state
relative-caret-position=
"542"
>
<caret
line=
"2"
column=
"69"
lean-forward=
"true"
selection-start-line=
"2"
selection-start-column=
"2"
selection-end-line=
"2"
selection-end-column=
"73"
/>
<caret
line=
"1178"
column=
"47"
selection-start-line=
"1178"
selection-start-column=
"38"
selection-end-line=
"1178"
selection-end-column=
"47"
/>
</state>
<folding>
</provider>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
</folding>
<state
split_layout=
"SPLIT"
>
<first_editor
relative-caret-position=
"30"
>
<caret
line=
"2"
column=
"7"
selection-start-line=
"2"
selection-start-column=
"7"
selection-end-line=
"2"
selection-end-column=
"7"
/>
</first_editor>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
...
...
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
View file @
40dccfde
package
com.pichillilorenzo.flutter_inappbrowser
;
package
com.pichillilorenzo.flutter_inappbrowser
;
import
android.os.Build
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.Log
;
import
android.webkit.CookieManager
;
import
android.webkit.CookieManager
;
import
android.webkit.ValueCallback
;
import
android.webkit.ValueCallback
;
import
java.net.HttpCookie
;
import
java.net.HttpCookie
;
import
java.
net.MalformedURLException
;
import
java.
util.ArrayList
;
import
java.
net.URL
;
import
java.
util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel
;
...
@@ -44,6 +44,9 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
...
@@ -44,6 +44,9 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
MyCookieManager
.
setCookie
(
url
,
name
,
value
,
domain
,
path
,
expiresDate
,
isHTTPOnly
,
isSecure
,
result
);
MyCookieManager
.
setCookie
(
url
,
name
,
value
,
domain
,
path
,
expiresDate
,
isHTTPOnly
,
isSecure
,
result
);
}
}
break
;
break
;
case
"getCookies"
:
result
.
success
(
MyCookieManager
.
getCookies
((
String
)
call
.
argument
(
"url"
)));
break
;
default
:
default
:
result
.
notImplemented
();
result
.
notImplemented
();
}
}
...
@@ -70,9 +73,8 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
...
@@ -70,9 +73,8 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
if
(
expiresDate
!=
null
)
if
(
expiresDate
!=
null
)
cookieValue
+=
"; Max-Age="
+
expiresDate
.
toString
();
cookieValue
+=
"; Max-Age="
+
expiresDate
.
toString
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
if
(
isHTTPOnly
!=
null
&&
isHTTPOnly
)
if
(
isHTTPOnly
!=
null
&&
isHTTPOnly
)
cookieValue
+=
"; HttpOnly"
;
cookieValue
+=
"; HttpOnly"
;
if
(
isSecure
!=
null
&&
isSecure
)
if
(
isSecure
!=
null
&&
isSecure
)
cookieValue
+=
"; Secure"
;
cookieValue
+=
"; Secure"
;
...
@@ -93,4 +95,24 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
...
@@ -93,4 +95,24 @@ public class MyCookieManager implements MethodChannel.MethodCallHandler {
}
}
}
}
public
static
List
<
Map
<
String
,
Object
>>
getCookies
(
final
String
url
)
{
final
List
<
Map
<
String
,
Object
>>
cookieListMap
=
new
ArrayList
<>();
CookieManager
cookieManager
=
CookieManager
.
getInstance
();
String
[]
cookies
=
cookieManager
.
getCookie
(
url
).
split
(
";"
);
for
(
String
cookie
:
cookies
)
{
String
[]
nameValue
=
cookie
.
split
(
"="
,
2
);
String
name
=
nameValue
[
0
].
trim
();
String
value
=
nameValue
[
1
].
trim
();
Map
<
String
,
Object
>
cookieMap
=
new
HashMap
<>();
cookieMap
.
put
(
"name"
,
name
);
cookieMap
.
put
(
"value"
,
value
);
cookieListMap
.
add
(
cookieMap
);
}
return
cookieListMap
;
}
}
}
example/android/build.gradle
View file @
40dccfde
...
@@ -5,7 +5,7 @@ buildscript {
...
@@ -5,7 +5,7 @@ buildscript {
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:3.2.
0
'
classpath
'com.android.tools.build:gradle:3.2.
1
'
}
}
}
}
...
...
example/lib/main.dart
View file @
40dccfde
...
@@ -66,6 +66,12 @@ class MyInAppBrowser extends InAppBrowser {
...
@@ -66,6 +66,12 @@ class MyInAppBrowser extends InAppBrowser {
// await this.webViewController.injectScriptCode("console.debug('testDebug', true);");
// await this.webViewController.injectScriptCode("console.debug('testDebug', true);");
//
//
print
(
await
this
.
webViewController
.
injectScriptCode
(
"document.cookie"
));
print
(
await
this
.
webViewController
.
injectScriptCode
(
"document.cookie"
));
print
(
""
);
print
(
await
CookieManager
.
getCookies
(
"https://flutter.io/"
));
print
(
""
);
print
(
await
CookieManager
.
getCookie
(
"https://flutter.io/"
,
"_ga"
));
print
(
""
);
//
//
// print(await this.webViewController.injectScriptCode("null"));
// print(await this.webViewController.injectScriptCode("null"));
// print(await this.webViewController.injectScriptCode("undefined"));
// print(await this.webViewController.injectScriptCode("undefined"));
...
@@ -281,6 +287,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -281,6 +287,7 @@ class _MyAppState extends State<MyApp> {
//"toolbarTop": false,
//"toolbarTop": false,
//"toolbarBottom": false
//"toolbarBottom": false
});
});
},
},
child:
Text
(
"Open InAppBrowser"
)
child:
Text
(
"Open InAppBrowser"
)
),
),
...
...
lib/flutter_inappbrowser.dart
View file @
40dccfde
...
@@ -1119,6 +1119,7 @@ class InAppLocalhostServer {
...
@@ -1119,6 +1119,7 @@ class InAppLocalhostServer {
}
}
///Manages the cookies used by an application's [InAppWebView] instances.
class
CookieManager
{
class
CookieManager
{
static
bool
_initialized
=
false
;
static
bool
_initialized
=
false
;
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'com.pichillilorenzo/flutter_inappbrowser_cookiemanager'
);
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'com.pichillilorenzo/flutter_inappbrowser_cookiemanager'
);
...
@@ -1131,6 +1132,7 @@ class CookieManager {
...
@@ -1131,6 +1132,7 @@ class CookieManager {
static
Future
<
dynamic
>
_handleMethod
(
MethodCall
call
)
async
{
static
Future
<
dynamic
>
_handleMethod
(
MethodCall
call
)
async
{
}
}
///Sets a cookie for the given [url]. Any existing cookie with the same [host], [path] and [name] will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
static
Future
<
void
>
setCookie
(
String
url
,
String
name
,
String
value
,
String
domain
,
static
Future
<
void
>
setCookie
(
String
url
,
String
name
,
String
value
,
String
domain
,
{
String
path
=
"/"
,
{
String
path
=
"/"
,
int
expiresDate
,
int
expiresDate
,
...
@@ -1157,4 +1159,36 @@ class CookieManager {
...
@@ -1157,4 +1159,36 @@ class CookieManager {
await
_channel
.
invokeMethod
(
'setCookie'
,
args
);
await
_channel
.
invokeMethod
(
'setCookie'
,
args
);
}
}
///Gets all the cookies for the given [url].
static
Future
<
List
<
Map
<
String
,
dynamic
>>>
getCookies
(
String
url
)
async
{
assert
(
url
!=
null
&&
url
.
isNotEmpty
);
Map
<
String
,
dynamic
>
args
=
<
String
,
dynamic
>{};
args
.
putIfAbsent
(
'url'
,
()
=>
url
);
List
<
dynamic
>
cookies
=
await
_channel
.
invokeMethod
(
'getCookies'
,
args
);
cookies
=
cookies
.
cast
<
Map
<
dynamic
,
dynamic
>>();
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++)
{
cookies
[
i
]
=
cookies
[
i
].
cast
<
String
,
dynamic
>();
}
cookies
=
cookies
.
cast
<
Map
<
String
,
dynamic
>>();
return
cookies
;
}
///Gets a cookie by its [cookieName] for the given [url].
static
Future
<
Map
<
String
,
dynamic
>>
getCookie
(
String
url
,
String
cookieName
)
async
{
assert
(
url
!=
null
&&
url
.
isNotEmpty
);
assert
(
cookieName
!=
null
&&
cookieName
.
isNotEmpty
);
Map
<
String
,
dynamic
>
args
=
<
String
,
dynamic
>{};
args
.
putIfAbsent
(
'url'
,
()
=>
url
);
List
<
dynamic
>
cookies
=
await
_channel
.
invokeMethod
(
'getCookies'
,
args
);
cookies
=
cookies
.
cast
<
Map
<
dynamic
,
dynamic
>>();
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++)
{
cookies
[
i
]
=
cookies
[
i
].
cast
<
String
,
dynamic
>();
if
(
cookies
[
i
][
"name"
]
==
cookieName
)
return
cookies
[
i
];
}
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment