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
35233f09
Commit
35233f09
authored
Oct 24, 2018
by
pichillilorenzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on CookieManager class (Manage cookies #8)
parent
aa88e7d7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
229 additions
and
107 deletions
+229
-107
.idea/workspace.xml
.idea/workspace.xml
+76
-101
CHANGELOG.md
CHANGELOG.md
+4
-0
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
...renzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
+4
-0
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
...pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
+96
-0
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.java
...n/java/com/pichillilorenzo/flutter_inappbrowser/Util.java
+3
-2
example/lib/main.dart
example/lib/main.dart
+2
-1
lib/flutter_inappbrowser.dart
lib/flutter_inappbrowser.dart
+43
-2
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
.idea/workspace.xml
View file @
35233f09
...
...
@@ -15,16 +15,12 @@
</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/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$/CHANGELOG.md"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/CHANGELOG.md"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/README.md"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/README.md"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/FlutterWebView.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.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/
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/
Util.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util
.java"
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$/ios/Classes/InAppBrowserWebViewController.swift"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/ios/Classes/InAppBrowserWebViewController.swift"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.swift"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/ios/Classes/SwiftFlutterPlugin.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$/pubspec.yaml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/pubspec.yaml"
afterDir=
"false"
/>
</list>
...
...
@@ -41,50 +37,25 @@
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
<component
name=
"DockManager"
>
<window
id=
"1"
>
<content
type=
"file-editors"
>
<state>
<leaf>
<file
leaf-file-name=
"README.md"
pinned=
"false"
current-in-tab=
"true"
>
<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=
"564"
>
<caret
line=
"320"
column=
"135"
selection-start-line=
"320"
selection-start-column=
"135"
selection-end-line=
"320"
selection-end-column=
"135"
/>
</first_editor>
<second_editor>
<markdownNavigatorState
/>
</second_editor>
</state>
</provider>
</entry>
</file>
</leaf>
</state>
</content>
</window>
</component>
<component
name=
"FileEditorManager"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<file
leaf-file-name=
"flutter_inappbrowser.dart"
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
329
"
>
<caret
line=
"
798"
column=
"127"
lean-forward=
"true"
selection-start-line=
"798"
selection-start-column=
"15"
selection-end-line=
"798"
selection-end-column=
"127
"
/>
<state
relative-caret-position=
"
461
"
>
<caret
line=
"
1157"
column=
"19"
selection-start-line=
"1157"
selection-start-column=
"19"
selection-end-line=
"1157"
selection-end-column=
"19
"
/>
<folding>
<element
signature=
"e#0#50883#0"
expanded=
"true"
/>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
</file>
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"
tru
e"
>
<file
leaf-file-name=
"main.dart"
pinned=
"false"
current-in-tab=
"
fals
e"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
233
"
>
<caret
line=
"
397"
column=
"18"
lean-forward=
"true"
selection-start-line=
"397"
selection-start-column=
"18"
selection-end-line=
"397"
selection-end-column=
"18
"
/>
<state
relative-caret-position=
"
432
"
>
<caret
line=
"
273"
column=
"94"
selection-start-line=
"273"
selection-start-column=
"94"
selection-end-line=
"273"
selection-end-column=
"94
"
/>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
</folding>
...
...
@@ -92,21 +63,26 @@
</provider>
</entry>
</file>
<file
leaf-file-name=
"index.html"
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
selection-end-line=
"33"
selection-end-column=
"7"
/>
<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=
"
fals
e"
>
<file
leaf-file-name=
"CHANGELOG.md"
pinned=
"false"
current-in-tab=
"
tru
e"
>
<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=
"
58"
selection-start-line=
"2"
selection-start-column=
"58"
selection-end-line=
"2"
selection-end-column=
"58
"
/>
<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
/>
...
...
@@ -126,8 +102,6 @@
</component>
<component
name=
"FindInProjectRecents"
>
<findStrings>
<find>
_throwIsAlreadyOpened
</find>
<find>
isHidden
</find>
<find>
shouldOverrideUrlLoading
</find>
<find>
toolbarTopFixedTitle
</find>
<find>
useChromeSafariBrowser
</find>
...
...
@@ -156,6 +130,8 @@
<find>
assert(
</find>
<find>
sNotEmpty()
</find>
<find>
loadData
</find>
<find>
_valide
</find>
<find>
initialized
</find>
</findStrings>
<replaceStrings>
<replace>
activity.getPreferences(0)
</replace>
...
...
@@ -197,11 +173,11 @@
<option
value=
"$PROJECT_DIR$/example/assets/index.html"
/>
<option
value=
"$PROJECT_DIR$/example/ios/Flutter/Generated.xcconfig"
/>
<option
value=
"$PROJECT_DIR$/example/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/README.md"
/>
<option
value=
"$PROJECT_DIR$/pubspec.yaml"
/>
<option
value=
"$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
<option
value=
"$PROJECT_DIR$/README.md"
/>
<option
value=
"$PROJECT_DIR$/example/lib/main.dart"
/>
<option
value=
"$PROJECT_DIR$/CHANGELOG.md"
/>
</list>
</option>
</component>
...
...
@@ -217,18 +193,6 @@
<foldersAlwaysOnTop
value=
"true"
/>
</navigator>
<panes>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
>
<expand>
<path>
<item
name=
"Root"
type=
"cbb8eebc:String"
user=
"Root"
/>
<item
name=
"flutter_inappbrowser"
type=
"cbb8eebc:String"
user=
"flutter_inappbrowser"
/>
</path>
</expand>
<select
/>
</subPane>
</pane>
<pane
id=
"AndroidView"
/>
<pane
id=
"PackagesPane"
/>
<pane
id=
"ProjectPane"
>
<subPane>
...
...
@@ -247,6 +211,18 @@
</subPane>
<option
name=
"show-excluded-files"
value=
"false"
/>
</pane>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
>
<expand>
<path>
<item
name=
"Root"
type=
"cbb8eebc:String"
user=
"Root"
/>
<item
name=
"flutter_inappbrowser"
type=
"cbb8eebc:String"
user=
"flutter_inappbrowser"
/>
</path>
</expand>
<select
/>
</subPane>
</pane>
<pane
id=
"AndroidView"
/>
</panes>
</component>
<component
name=
"PropertiesComponent"
>
...
...
@@ -408,16 +384,15 @@
<layout>
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"7"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"TODO"
order=
"6"
/>
<window_info
anchor=
"bottom"
id=
"Messages"
order=
"12"
weight=
"0.23692636"
/>
<window_info
anchor=
"right"
id=
"Palette	"
order=
"9"
/>
<window_info
id=
"Image Layers"
order=
"7"
/>
<window_info
id=
"Build Variants"
order=
"3"
side_tool=
"true"
/>
<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=
"Dart Analysis"
order=
"14"
weight=
"0.3276414"
/>
<window_info
active=
"true"
anchor=
"bottom"
id=
"Run"
order=
"2"
sideWeight=
"0.49644473"
visible=
"true"
weight=
"0.
22838847
"
/>
<window_info
active=
"true"
anchor=
"bottom"
id=
"Run"
order=
"2"
sideWeight=
"0.49644473"
visible=
"true"
weight=
"0.
44503736
"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49644473"
weight=
"0.
19530416
"
/>
<window_info
anchor=
"bottom"
id=
"Terminal"
order=
"10"
sideWeight=
"0.49644473"
weight=
"0.
30736393
"
/>
<window_info
anchor=
"right"
id=
"Flutter Outline"
order=
"6"
weight=
"0.32922077"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"11"
/>
<window_info
id=
"Captures"
order=
"4"
weight=
"0.32936507"
/>
...
...
@@ -430,6 +405,7 @@
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.34364995"
/>
<window_info
id=
"Favorites"
order=
"5"
side_tool=
"true"
/>
<window_info
anchor=
"right"
id=
"Flutter Inspector"
order=
"3"
weight=
"0.32938388"
/>
<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=
"right"
id=
"Commander"
order=
"0"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Assistant"
order=
"8"
visible=
"true"
weight=
"0.32987013"
/>
...
...
@@ -685,74 +661,73 @@
<state
/>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/pubspec.yaml"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"225"
>
<caret
line=
"15"
column=
"26"
selection-start-line=
"15"
selection-start-column=
"26"
selection-end-line=
"15"
selection-end-column=
"26"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/assets/index.html"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state>
<caret
selection-end-line=
"33"
selection-end-column=
"7"
/>
<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>
</entry>
<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=
"58"
selection-start-line=
"2"
selection-start-column=
"58"
selection-end-line=
"2"
selection-end-column=
"58
"
/>
<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>
<provider
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"30"
>
<caret
line=
"2"
column=
"69"
lean-forward=
"true"
selection-start-line=
"2"
selection-start-column=
"2"
selection-end-line=
"2"
selection-end-column=
"73"
/>
</entry>
<entry
file=
"file://$PROJECT_DIR$/pubspec.yaml"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"105"
>
<caret
line=
"7"
column=
"32"
selection-start-line=
"7"
selection-start-column=
"32"
selection-end-line=
"7"
selection-end-column=
"32"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/assets/index.html"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state>
<caret
selection-end-line=
"33"
selection-end-column=
"7"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/lib/flutter_inappbrowser.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
329
"
>
<caret
line=
"
798"
column=
"127"
lean-forward=
"true"
selection-start-line=
"798"
selection-start-column=
"15"
selection-end-line=
"798"
selection-end-column=
"127
"
/>
<state
relative-caret-position=
"
461
"
>
<caret
line=
"
1157"
column=
"19"
selection-start-line=
"1157"
selection-start-column=
"19"
selection-end-line=
"1157"
selection-end-column=
"19
"
/>
<folding>
<element
signature=
"e#0#50883#0"
expanded=
"true"
/>
<element
signature=
"e#814#831#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/README.md"
>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"432"
>
<caret
line=
"273"
column=
"94"
selection-start-line=
"273"
selection-start-column=
"94"
selection-end-line=
"273"
selection-end-column=
"94"
/>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/CHANGELOG.md"
>
<provider
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"30"
>
<caret
line=
"2"
column=
"69"
lean-forward=
"true"
selection-start-line=
"2"
selection-start-column=
"2"
selection-end-line=
"2"
selection-end-column=
"73"
/>
</state>
</provider>
<provider
selected=
"true"
editor-type-id=
"split-provider[text-editor;MarkdownPreviewEditor]"
>
<state
split_layout=
"SPLIT"
>
<first_editor
relative-caret-position=
"
564
"
>
<caret
line=
"
320"
column=
"135"
selection-start-line=
"320"
selection-start-column=
"135"
selection-end-line=
"320"
selection-end-column=
"135
"
/>
<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>
<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>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"233"
>
<caret
line=
"397"
column=
"18"
lean-forward=
"true"
selection-start-line=
"397"
selection-start-column=
"18"
selection-end-line=
"397"
selection-end-column=
"18"
/>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
</component>
<component
name=
"masterDetails"
>
...
...
CHANGELOG.md
View file @
35233f09
## 0.5.3
-
added
`CookieManager`
class
## 0.5.2
-
fixed some missing
`result.success()`
on Android and iOS
...
...
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java
View file @
35233f09
...
...
@@ -39,6 +39,8 @@ import com.pichillilorenzo.flutter_inappbrowser.ChromeCustomTabs.CustomTabActivi
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -78,6 +80,8 @@ public class InAppBrowserFlutterPlugin implements MethodCallHandler {
final
MethodChannel
channel
=
new
MethodChannel
(
registrar
.
messenger
(),
"com.pichillilorenzo/flutter_inappbrowser"
);
channel
.
setMethodCallHandler
(
new
InAppBrowserFlutterPlugin
(
registrar
,
activity
));
new
MyCookieManager
(
registrar
);
registrar
.
platformViewRegistry
()
.
registerViewFactory
(
...
...
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/MyCookieManager.java
0 → 100644
View file @
35233f09
package
com.pichillilorenzo.flutter_inappbrowser
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.webkit.CookieManager
;
import
android.webkit.ValueCallback
;
import
java.net.HttpCookie
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.List
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.PluginRegistry
;
public
class
MyCookieManager
implements
MethodChannel
.
MethodCallHandler
{
static
final
String
LOG_TAG
=
"MyCookieManager"
;
public
static
PluginRegistry
.
Registrar
registrar
;
public
static
MethodChannel
channel
;
public
MyCookieManager
(
PluginRegistry
.
Registrar
r
)
{
registrar
=
r
;
channel
=
new
MethodChannel
(
registrar
.
messenger
(),
"com.pichillilorenzo/flutter_inappbrowser_cookiemanager"
);
channel
.
setMethodCallHandler
(
this
);
}
@Override
public
void
onMethodCall
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
switch
(
call
.
method
)
{
case
"setCookie"
:
{
String
url
=
(
String
)
call
.
argument
(
"url"
);
String
name
=
(
String
)
call
.
argument
(
"name"
);
String
value
=
(
String
)
call
.
argument
(
"value"
);
String
domain
=
(
String
)
call
.
argument
(
"domain"
);
String
path
=
(
String
)
call
.
argument
(
"path"
);
Long
expiresDate
=
new
Long
((
Integer
)
call
.
argument
(
"expiresDate"
));
Boolean
isHTTPOnly
=
(
Boolean
)
call
.
argument
(
"isHTTPOnly"
);
Boolean
isSecure
=
(
Boolean
)
call
.
argument
(
"isSecure"
);
MyCookieManager
.
setCookie
(
url
,
name
,
value
,
domain
,
path
,
expiresDate
,
isHTTPOnly
,
isSecure
,
result
);
}
break
;
default
:
result
.
notImplemented
();
}
}
public
static
void
setCookie
(
String
url
,
String
name
,
String
value
,
String
domain
,
String
path
,
Long
expiresDate
,
Boolean
isHTTPOnly
,
Boolean
isSecure
,
final
MethodChannel
.
Result
result
)
{
String
cookieValue
=
name
+
"="
+
value
;
if
(
domain
!=
null
&&
!
domain
.
isEmpty
())
cookieValue
+=
"; Domain="
+
domain
;
if
(
path
!=
null
&&
!
path
.
isEmpty
())
cookieValue
+=
"; Path="
+
path
;
if
(
expiresDate
!=
null
)
cookieValue
+=
"; Max-Age="
+
expiresDate
.
toString
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
if
(
isHTTPOnly
!=
null
&&
isHTTPOnly
)
cookieValue
+=
"; HttpOnly"
;
if
(
isSecure
!=
null
&&
isSecure
)
cookieValue
+=
"; Secure"
;
CookieManager
cookieManager
=
CookieManager
.
getInstance
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
cookieManager
.
setCookie
(
url
,
cookieValue
,
new
ValueCallback
<
Boolean
>()
{
@Override
public
void
onReceiveValue
(
Boolean
aBoolean
)
{
result
.
success
(
true
);
}
});
}
else
{
cookieManager
.
setCookie
(
url
,
cookieValue
);
result
.
success
(
true
);
}
}
}
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/Util.java
View file @
35233f09
...
...
@@ -4,14 +4,14 @@ import android.content.res.AssetManager;
import
java.io.IOException
;
import
java.io.InputStream
;
import
io.flutter.plugin.common.PluginRegistry
;
public
class
Util
{
static
final
String
LOG_TAG
=
"Util"
;
public
static
final
String
ANDROID_ASSET_URL
=
"file:///android_asset/"
;
public
static
String
getUrlAsset
(
PluginRegistry
.
Registrar
registrar
,
String
assetFilePath
)
throws
IOException
{
public
static
String
getUrlAsset
(
PluginRegistry
.
Registrar
registrar
,
String
assetFilePath
)
throws
IOException
{
String
key
=
registrar
.
lookupKeyForAsset
(
assetFilePath
);
AssetManager
mg
=
registrar
.
activeContext
().
getResources
().
getAssets
();
InputStream
is
=
null
;
...
...
@@ -36,4 +36,5 @@ public class Util {
return
ANDROID_ASSET_URL
+
key
;
}
}
example/lib/main.dart
View file @
35233f09
...
...
@@ -65,7 +65,7 @@ class MyInAppBrowser extends InAppBrowser {
// await this.webViewController.injectScriptCode("console.error('testError', false);");
// await this.webViewController.injectScriptCode("console.debug('testDebug', true);");
//
// print(await this.webViewController.injectScriptCode("document.body.innerHTML
"));
print
(
await
this
.
webViewController
.
injectScriptCode
(
"document.cookie
"
));
//
// print(await this.webViewController.injectScriptCode("null"));
// print(await this.webViewController.injectScriptCode("undefined"));
...
...
@@ -271,6 +271,7 @@ class _MyAppState extends State<MyApp> {
// //"toolbarBottom": false
// });
//
await
CookieManager
.
setCookie
(
"https://flutter.io/"
,
"my_cookie2"
,
"cookieValue2"
,
"flutter.io"
,
expiresDate:
1000000
,
path:
"/get-started/install"
);
await
inAppBrowserFallback
.
open
(
url:
"https://flutter.io/"
,
options:
{
//"useOnLoadResource": true,
//"hidden": true,
...
...
lib/flutter_inappbrowser.dart
View file @
35233f09
...
...
@@ -86,7 +86,7 @@ class ConsoleMessage {
class
_ChannelManager
{
static
const
MethodChannel
channel
=
const
MethodChannel
(
'com.pichillilorenzo/flutter_inappbrowser'
);
static
fina
l
initialized
=
false
;
static
boo
l
initialized
=
false
;
static
final
listeners
=
HashMap
<
String
,
ListenerCallback
>();
static
Future
<
dynamic
>
_handleMethod
(
MethodCall
call
)
async
{
...
...
@@ -102,6 +102,7 @@ class _ChannelManager {
static
void
init
()
{
channel
.
setMethodCallHandler
(
_handleMethod
);
initialized
=
true
;
}
}
...
...
@@ -1116,4 +1117,44 @@ class InAppLocalhostServer {
}
}
}
\ No newline at end of file
}
class
CookieManager
{
static
bool
_initialized
=
false
;
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'com.pichillilorenzo/flutter_inappbrowser_cookiemanager'
);
static
void
_init
()
{
_channel
.
setMethodCallHandler
(
_handleMethod
);
_initialized
=
true
;
}
static
Future
<
dynamic
>
_handleMethod
(
MethodCall
call
)
async
{
}
static
Future
<
void
>
setCookie
(
String
url
,
String
name
,
String
value
,
String
domain
,
{
String
path
=
"/"
,
int
expiresDate
,
bool
isHTTPOnly
,
bool
isSecure
})
async
{
if
(!
_initialized
)
_init
();
assert
(
url
!=
null
&&
url
.
isNotEmpty
);
assert
(
name
!=
null
&&
name
.
isNotEmpty
);
assert
(
value
!=
null
&&
value
.
isNotEmpty
);
assert
(
domain
!=
null
&&
domain
.
isNotEmpty
);
assert
(
path
!=
null
&&
path
.
isNotEmpty
);
Map
<
String
,
dynamic
>
args
=
<
String
,
dynamic
>{};
args
.
putIfAbsent
(
'url'
,
()
=>
url
);
args
.
putIfAbsent
(
'name'
,
()
=>
name
);
args
.
putIfAbsent
(
'value'
,
()
=>
value
);
args
.
putIfAbsent
(
'domain'
,
()
=>
domain
);
args
.
putIfAbsent
(
'path'
,
()
=>
path
);
args
.
putIfAbsent
(
'expiresDate'
,
()
=>
expiresDate
);
args
.
putIfAbsent
(
'isHTTPOnly'
,
()
=>
isHTTPOnly
);
args
.
putIfAbsent
(
'isSecure'
,
()
=>
isSecure
);
await
_channel
.
invokeMethod
(
'setCookie'
,
args
);
}
}
pubspec.yaml
View file @
35233f09
name
:
flutter_inappbrowser
description
:
A Flutter plugin that allows you to add an inline webview or open an in-app browser window. (inspired by the popular cordova-plugin-inappbrowser).
version
:
0.5.
2
version
:
0.5.
3
author
:
Lorenzo Pichilli <pichillilorenzo@gmail.com>
homepage
:
https://github.com/pichillilorenzo/flutter_inappbrowser
...
...
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