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
5 years ago
by
Lorenzo Pichilli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated shouldInterceptFetchRequest
parent
e4d8b798
Changes
8
Expand all
Hide 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;
...
@@ -14,6 +14,7 @@ import android.webkit.CookieSyncManager;
import
android.webkit.HttpAuthHandler
;
import
android.webkit.HttpAuthHandler
;
import
android.webkit.SafeBrowsingResponse
;
import
android.webkit.SafeBrowsingResponse
;
import
android.webkit.SslErrorHandler
;
import
android.webkit.SslErrorHandler
;
import
android.webkit.ValueCallback
;
import
android.webkit.WebResourceRequest
;
import
android.webkit.WebResourceRequest
;
import
android.webkit.WebResourceResponse
;
import
android.webkit.WebResourceResponse
;
import
android.webkit.WebView
;
import
android.webkit.WebView
;
...
@@ -182,7 +183,7 @@ public class InAppWebViewClient extends WebViewClient {
...
@@ -182,7 +183,7 @@ public class InAppWebViewClient extends WebViewClient {
view
.
requestFocus
();
view
.
requestFocus
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
webView
.
evaluateJavascript
(
InAppWebView
.
platformReadyJS
,
(
MethodChannel
.
Result
)
null
);
webView
.
evaluateJavascript
(
InAppWebView
.
platformReadyJS
,
(
ValueCallback
<
String
>
)
null
);
}
else
{
}
else
{
webView
.
loadUrl
(
"javascript:"
+
InAppWebView
.
platformReadyJS
.
replaceAll
(
"[\r\n]+"
,
""
));
webView
.
loadUrl
(
"javascript:"
+
InAppWebView
.
platformReadyJS
.
replaceAll
(
"[\r\n]+"
,
""
));
}
}
...
...
This diff is collapsed.
Click to expand it.
example/assets/index.html
View file @
b4544c7d
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
<option
value=
"1"
>
option 1
</option>
<option
value=
"1"
>
option 1
</option>
<option
value=
"2"
>
option 2
</option>
<option
value=
"2"
>
option 2
</option>
</select>
</select>
<input
type=
"file"
>
<input
type=
"file"
accept=
"image/*"
capture
>
<button
onclick=
"testHistoryPush1()"
>
History Push 1
</button>
<button
onclick=
"testHistoryPush1()"
>
History Push 1
</button>
<button
onclick=
"testHistoryPush2()"
>
History Push 2
</button>
<button
onclick=
"testHistoryPush2()"
>
History Push 2
</button>
<button
onclick=
"testLocationHref()"
>
Location Href
</button>
<button
onclick=
"testLocationHref()"
>
Location Href
</button>
...
@@ -110,6 +112,20 @@
...
@@ -110,6 +112,20 @@
console
.
error
(
"
ERROR:
"
+
error
);
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");
alert("Alert Popup");
console.log(confirm("Press a button!"));
console.log(confirm("Press a button!"));
...
...
This diff is collapsed.
Click to expand it.
example/lib/inline_example.screen.dart
View file @
b4544c7d
...
@@ -289,7 +289,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
...
@@ -289,7 +289,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
print
(
"Current highlighted:
$activeMatchOrdinal
, Number of matches found:
$numberOfMatches
, find operation completed:
$isDoneCounting
"
);
print
(
"Current highlighted:
$activeMatchOrdinal
, Number of matches found:
$numberOfMatches
, find operation completed:
$isDoneCounting
"
);
},
},
shouldInterceptAjaxRequest:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
shouldInterceptAjaxRequest:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX REQUEST:
${ajaxRequest.method}
-
${ajaxRequest.url}
, DATA:
${ajaxRequest.data}
"
);
//
print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}");
// ajaxRequest.method = "GET";
// ajaxRequest.method = "GET";
// ajaxRequest.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.url = "http://192.168.1.20:8082/test-download-file";
// ajaxRequest.headers = {
// ajaxRequest.headers = {
...
@@ -299,16 +299,17 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
...
@@ -299,16 +299,17 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return
null
;
return
null
;
},
},
onAjaxReadyStateChange:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
onAjaxReadyStateChange:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX READY STATE CHANGE:
${ajaxRequest.method}
-
${ajaxRequest.url}
,
${ajaxRequest.status}
,
${ajaxRequest.readyState}
,
${ajaxRequest.responseType}
,
${ajaxRequest.responseText}
,
${ajaxRequest.responseHeaders}
"
);
//
print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}");
return
AjaxRequestAction
.
ABORT
;
return
AjaxRequestAction
.
PROCEED
;
},
},
onAjaxProgress:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
onAjaxProgress:
(
InAppWebViewController
controller
,
AjaxRequest
ajaxRequest
)
async
{
print
(
"AJAX EVENT:
${ajaxRequest.method}
-
${ajaxRequest.url}
,
${ajaxRequest.event.type}
, LOADED:
${ajaxRequest.event.loaded}
,
${ajaxRequest.responseHeaders}
"
);
//
print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}");
return
AjaxRequestAction
.
ABORT
;
return
AjaxRequestAction
.
PROCEED
;
},
},
shouldInterceptFetchRequest:
(
InAppWebViewController
controller
,
FetchRequest
fetchRequest
)
async
{
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
;
fetchRequest
.
action
=
FetchRequestAction
.
ABORT
;
print
(
fetchRequest
.
body
);
return
fetchRequest
;
return
fetchRequest
;
},
},
onNavigationStateChange:
(
InAppWebViewController
controller
,
String
url
)
async
{
onNavigationStateChange:
(
InAppWebViewController
controller
,
String
url
)
async
{
...
...
This diff is collapsed.
Click to expand it.
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 {
...
@@ -647,9 +647,9 @@ class InAppWebViewController {
String
url
=
argMap
[
"url"
];
String
url
=
argMap
[
"url"
];
String
method
=
argMap
[
"method"
];
String
method
=
argMap
[
"method"
];
Map
<
dynamic
,
dynamic
>
headers
=
argMap
[
"headers"
];
Map
<
dynamic
,
dynamic
>
headers
=
argMap
[
"headers"
];
dynamic
body
=
argMap
[
"body"
]
;
Uint8List
body
=
Uint8List
.
fromList
(
argMap
[
"body"
].
cast
<
int
>())
;
String
mode
=
argMap
[
"mode"
];
String
mode
=
argMap
[
"mode"
];
String
credentials
=
argMap
[
"credentials"
]
;
FetchRequestCredential
credentials
=
FetchRequest
.
createFetchRequestCredentialFromMap
(
argMap
[
"credentials"
])
;
String
cache
=
argMap
[
"cache"
];
String
cache
=
argMap
[
"cache"
];
String
redirect
=
argMap
[
"redirect"
];
String
redirect
=
argMap
[
"redirect"
];
String
referrer
=
argMap
[
"referrer"
];
String
referrer
=
argMap
[
"referrer"
];
...
...
This diff is collapsed.
Click to expand it.
lib/src/types.dart
View file @
b4544c7d
...
@@ -820,14 +820,83 @@ class FetchRequestAction {
...
@@ -820,14 +820,83 @@ class FetchRequestAction {
static
const
PROCEED
=
const
FetchRequestAction
.
_internal
(
1
);
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
{
class
FetchRequest
{
String
url
;
String
url
;
String
method
;
String
method
;
Map
<
dynamic
,
dynamic
>
headers
;
Map
<
String
,
dynamic
>
headers
;
dynamic
body
;
Uint8List
body
;
String
mode
;
String
mode
;
String
credentials
;
FetchRequestCredential
credentials
;
String
cache
;
String
cache
;
String
redirect
;
String
redirect
;
String
referrer
;
String
referrer
;
...
@@ -847,7 +916,7 @@ class FetchRequest {
...
@@ -847,7 +916,7 @@ class FetchRequest {
"headers"
:
headers
,
"headers"
:
headers
,
"body"
:
body
,
"body"
:
body
,
"mode"
:
mode
,
"mode"
:
mode
,
"credentials"
:
credentials
,
"credentials"
:
credentials
?.
toMap
()
,
"cache"
:
cache
,
"cache"
:
cache
,
"redirect"
:
redirect
,
"redirect"
:
redirect
,
"referrer"
:
referrer
,
"referrer"
:
referrer
,
...
@@ -861,4 +930,19 @@ class FetchRequest {
...
@@ -861,4 +930,19 @@ class FetchRequest {
Map
<
String
,
dynamic
>
toJson
()
{
Map
<
String
,
dynamic
>
toJson
()
{
return
this
.
toMap
();
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
This diff is collapsed.
Click to expand it.
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