Add secure context on android (#4428)
* Add secure context on android * Remove location permission in AndroidManifest.xml.hbs
This commit is contained in:
1 parent
6524f55462
commit
196db43e23
2 files changed
+16
-2
No files matched your search
@@ -7,7 +7,10 @@ use wry::{
|
|||||||
RequestAsyncResponder,
|
RequestAsyncResponder,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(target_os = "android", target_os = "windows"))]
|
#[cfg(target_os = "android")]
|
||||||
|
const EVENTS_PATH: &str = "https://dioxus.index.html/__events";
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
const EVENTS_PATH: &str = "http://dioxus.index.html/__events";
|
const EVENTS_PATH: &str = "http://dioxus.index.html/__events";
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "windows")))]
|
#[cfg(not(any(target_os = "android", target_os = "windows")))]
|
||||||
|
|||||||
@@ -317,7 +317,10 @@ impl WebviewInstance {
|
|||||||
.with_navigation_handler(move |var| {
|
.with_navigation_handler(move |var| {
|
||||||
// We don't want to allow any navigation
|
// We don't want to allow any navigation
|
||||||
// We only want to serve the index file and assets
|
// We only want to serve the index file and assets
|
||||||
if var.starts_with("dioxus://") || var.starts_with("http://dioxus.") {
|
if var.starts_with("dioxus://")
|
||||||
|
|| var.starts_with("http://dioxus.")
|
||||||
|
|| var.starts_with("https://dioxus.")
|
||||||
|
{
|
||||||
// After the page has loaded once, don't allow any more navigation
|
// After the page has loaded once, don't allow any more navigation
|
||||||
let page_loaded = page_loaded.swap(true, std::sync::atomic::Ordering::SeqCst);
|
let page_loaded = page_loaded.swap(true, std::sync::atomic::Ordering::SeqCst);
|
||||||
!page_loaded
|
!page_loaded
|
||||||
@@ -333,6 +336,14 @@ impl WebviewInstance {
|
|||||||
}) // prevent all navigations
|
}) // prevent all navigations
|
||||||
.with_asynchronous_custom_protocol(String::from("dioxus"), request_handler);
|
.with_asynchronous_custom_protocol(String::from("dioxus"), request_handler);
|
||||||
|
|
||||||
|
// Enable https scheme on android, needed for secure context API, like the geolocation API
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
use wry::WebViewBuilderExtAndroid as _;
|
||||||
|
|
||||||
|
webview = webview.with_https_scheme(true);
|
||||||
|
};
|
||||||
|
|
||||||
// Disable the webview default shortcuts to disable the reload shortcut
|
// Disable the webview default shortcuts to disable the reload shortcut
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user