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
b4544c7d
Commit
b4544c7d
authored
Nov 06, 2019
by
Lorenzo Pichilli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated shouldInterceptFetchRequest
parent
e4d8b798
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
783 additions
and
414 deletions
+783
-414
.idea/workspace.xml
.idea/workspace.xml
+105
-99
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
...renzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
+289
-145
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
...flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
+2
-1
example/assets/index.html
example/assets/index.html
+16
-0
example/lib/inline_example.screen.dart
example/lib/inline_example.screen.dart
+7
-6
ios/Classes/InAppWebView.swift
ios/Classes/InAppWebView.swift
+274
-157
lib/src/in_app_webview.dart
lib/src/in_app_webview.dart
+2
-2
lib/src/types.dart
lib/src/types.dart
+88
-4
No files found.
.idea/workspace.xml
View file @
b4544c7d
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
View file @
b4544c7d
This diff is collapsed.
Click to expand it.
android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewClient.java
View file @
b4544c7d
...
...
@@ -14,6 +14,7 @@ import android.webkit.CookieSyncManager;
import
android.webkit.HttpAuthHandler
;
import
android.webkit.SafeBrowsingResponse
;
import
android.webkit.SslErrorHandler
;
import
android.webkit.ValueCallback
;
import
android.webkit.WebResourceRequest
;
import
android.webkit.WebResourceResponse
;
import
android.webkit.WebView
;
...
...
@@ -182,7 +183,7 @@ public class InAppWebViewClient extends WebViewClient {
view
.
requestFocus
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
webView
.
evaluateJavascript
(
InAppWebView
.
platformReadyJS
,
(
MethodChannel
.
Result
)
null
);
webView
.
evaluateJavascript
(
InAppWebView
.
platformReadyJS
,
(
ValueCallback
<
String
>
)
null
);
}
else
{
webView
.
loadUrl
(
"javascript:"
+
InAppWebView
.
platformReadyJS
.
replaceAll
(
"[\r\n]+"
,
""
));
}
...
...
example/assets/index.html
View file @
b4544c7d
...
...
@@ -31,6 +31,8 @@
<option
value=
"1"
>
option 1
</option>
<option
value=
"2"
>
option 2
</option>
</select>
<input
type=
"file"
>
<input
type=
"file"
accept=
"image/*"
capture
>
<button
onclick=
"testHistoryPush1()"
>
History Push 1
</button>
<button
onclick=
"testHistoryPush2()"
>
History Push 2
</button>
<button
onclick=
"testLocationHref()"
>
Location Href
</button>
...
...
@@ -110,6 +112,20 @@
console
.
error
(
"
ERROR:
"
+
error
);
});
fetch
(
"
http://192.168.1.20:8082/test-ajax-post
"
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
name
:
'
Lorenzo Fetch API
'
}),
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
}).
then
(
function
(
response
)
{
console
.
log
(
response
);
}).
catch
(
function
(
error
)
{
console
.
error
(
"
ERROR:
"
+
error
);
});
/*
alert("Alert Popup");
console.log(confirm("Press a button!"));
...
...
example/lib/inline_example.screen.dart
View file @
b4544c7d
...
...
@@ -289,7 +289,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
print
(
"Current highlighted:
$activeMatchOrdinal
, Number of matches found:
$numberOfMatches
, find operation completed:
$isDoneCounting
"
);
},
shouldInterceptAjaxRequest:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX REQUEST:
${ajaxRequest.method}
-
${ajaxRequest.url}
, DATA:
${ajaxRequest.data}
"
);
//
print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}");
// ajaxRequest.method = "GET";
// ajaxRequest.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.headers = {
...
...
@@ -299,16 +299,17 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return
null
;
},
onAjaxReadyStateChange:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX READY STATE CHANGE:
${ajaxRequest.method}
-
${ajaxRequest.url}
,
${ajaxRequest.status}
,
${ajaxRequest.readyState}
,
${ajaxRequest.responseType}
,
${ajaxRequest.responseText}
,
${ajaxRequest.responseHeaders}
"
);
return
AjaxRequestAction
.
ABORT
;
//
print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}");
return
AjaxRequestAction
.
PROCEED
;
},
onAjaxProgress:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX EVENT:
${ajaxRequest.method}
-
${ajaxRequest.url}
,
${ajaxRequest.event.type}
, LOADED:
${ajaxRequest.event.loaded}
,
${ajaxRequest.responseHeaders}
"
);
return
AjaxRequestAction
.
ABORT
;
//
print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}");
return
AjaxRequestAction
.
PROCEED
;
},
shouldInterceptFetchRequest:
(
InAppWebViewController
controller
,
FetchRequest
fetchRequest
)
async
{
print
(
"FETCH REQUEST:
${fetchRequest.method}
-
${fetchRequest.url}
"
);
print
(
"FETCH REQUEST:
${fetchRequest.method}
-
${fetchRequest.url}
, headers:
${fetchRequest.headers}
"
);
fetchRequest
.
action
=
FetchRequestAction
.
ABORT
;
print
(
fetchRequest
.
body
);
return
fetchRequest
;
},
onNavigationStateChange:
(
InAppWebViewController
controller
,
String
url
)
async
{
...
...
ios/Classes/InAppWebView.swift
View file @
b4544c7d
This diff is collapsed.
Click to expand it.
lib/src/in_app_webview.dart
View file @
b4544c7d
...
...
@@ -647,9 +647,9 @@ class InAppWebViewController {
String
url
=
argMap
[
"url"
];
String
method
=
argMap
[
"method"
];
Map
<
dynamic
,
dynamic
>
headers
=
argMap
[
"headers"
];
dynamic
body
=
argMap
[
"body"
]
;
Uint8List
body
=
Uint8List
.
fromList
(
argMap
[
"body"
].
cast
<
int
>())
;
String
mode
=
argMap
[
"mode"
];
String
credentials
=
argMap
[
"credentials"
]
;
FetchRequestCredential
credentials
=
FetchRequest
.
createFetchRequestCredentialFromMap
(
argMap
[
"credentials"
])
;
String
cache
=
argMap
[
"cache"
];
String
redirect
=
argMap
[
"redirect"
];
String
referrer
=
argMap
[
"referrer"
];
...
...
lib/src/types.dart
View file @
b4544c7d
...
...
@@ -820,14 +820,83 @@ class FetchRequestAction {
static
const
PROCEED
=
const
FetchRequestAction
.
_internal
(
1
);
}
///
class
FetchRequestCredential
{
String
type
;
FetchRequestCredential
({
this
.
type
});
Map
<
String
,
dynamic
>
toMap
()
{
return
{
"type"
:
type
};
}
}
///
class
FetchRequestCredentialDefault
extends
FetchRequestCredential
{
String
value
;
FetchRequestCredentialDefault
({
type
,
this
.
value
}):
super
(
type:
type
);
Map
<
String
,
dynamic
>
toMap
()
{
return
{
"type"
:
type
,
"value"
:
value
,
};
}
}
///
class
FetchRequestFederatedCredential
extends
FetchRequestCredential
{
dynamic
id
;
String
name
;
String
protocol
;
String
provider
;
String
iconURL
;
FetchRequestFederatedCredential
({
type
,
this
.
id
,
this
.
name
,
this
.
protocol
,
this
.
provider
,
this
.
iconURL
}):
super
(
type:
type
);
Map
<
String
,
dynamic
>
toMap
()
{
return
{
"type"
:
type
,
"id"
:
id
,
"name"
:
name
,
"protocol"
:
protocol
,
"provider"
:
provider
,
"iconURL"
:
iconURL
};
}
}
///
class
FetchRequestPasswordCredential
extends
FetchRequestCredential
{
dynamic
id
;
String
name
;
String
password
;
String
iconURL
;
FetchRequestPasswordCredential
({
type
,
this
.
id
,
this
.
name
,
this
.
password
,
this
.
iconURL
}):
super
(
type:
type
);
Map
<
String
,
dynamic
>
toMap
()
{
return
{
"type"
:
type
,
"id"
:
id
,
"name"
:
name
,
"password"
:
password
,
"iconURL"
:
iconURL
};
}
}
///
class
FetchRequest
{
String
url
;
String
method
;
Map
<
dynamic
,
dynamic
>
headers
;
dynamic
body
;
Map
<
String
,
dynamic
>
headers
;
Uint8List
body
;
String
mode
;
String
credentials
;
FetchRequestCredential
credentials
;
String
cache
;
String
redirect
;
String
referrer
;
...
...
@@ -847,7 +916,7 @@ class FetchRequest {
"headers"
:
headers
,
"body"
:
body
,
"mode"
:
mode
,
"credentials"
:
credentials
,
"credentials"
:
credentials
?.
toMap
()
,
"cache"
:
cache
,
"redirect"
:
redirect
,
"referrer"
:
referrer
,
...
...
@@ -861,4 +930,19 @@ class FetchRequest {
Map
<
String
,
dynamic
>
toJson
()
{
return
this
.
toMap
();
}
static
FetchRequestCredential
createFetchRequestCredentialFromMap
(
credentialsMap
)
{
if
(
credentialsMap
!=
null
)
{
if
(
credentialsMap
[
"type"
]
==
"default"
)
{
return
FetchRequestCredentialDefault
(
type:
credentialsMap
[
"type"
],
value:
credentialsMap
[
"value"
]);
}
else
if
(
credentialsMap
[
"type"
]
==
"federated"
)
{
return
FetchRequestFederatedCredential
(
type:
credentialsMap
[
"type"
],
id:
credentialsMap
[
"id"
],
name:
credentialsMap
[
"name"
],
protocol:
credentialsMap
[
"protocol"
],
provider:
credentialsMap
[
"provider"
],
iconURL:
credentialsMap
[
"iconURL"
]);
}
else
if
(
credentialsMap
[
"type"
]
==
"password"
)
{
return
FetchRequestPasswordCredential
(
type:
credentialsMap
[
"type"
],
id:
credentialsMap
[
"id"
],
name:
credentialsMap
[
"name"
],
password:
credentialsMap
[
"password"
],
iconURL:
credentialsMap
[
"iconURL"
]);
}
}
return
null
;
}
}
\ No newline at end of file
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