@@ -7,7 +7,7 @@ use gloo_net::websocket::{futures::WebSocket, Message};
7
7
use js_sys:: { Array , Promise , Uint8Array } ;
8
8
use ruffle_core:: backend:: navigator:: {
9
9
async_return, create_fetch_error, create_specific_fetch_error, get_encoding, ErrorResponse ,
10
- NavigationMethod , NavigatorBackend , OpenURLMode , OwnedFuture , Request , SuccessResponse ,
10
+ NavigationMethod , NavigatorBackend , OwnedFuture , Request , SuccessResponse ,
11
11
} ;
12
12
use ruffle_core:: config:: NetworkingAccessMode ;
13
13
use ruffle_core:: indexmap:: IndexMap ;
@@ -32,13 +32,29 @@ use web_sys::{
32
32
RequestCredentials , RequestInit , Response as WebResponse ,
33
33
} ;
34
34
35
+ /// The handling mode of links opening a new website.
36
+ #[ derive( Clone , Copy , Debug , PartialEq , serde:: Serialize , serde:: Deserialize ) ]
37
+ pub enum OpenUrlMode {
38
+ /// Allow all links to open a new website.
39
+ #[ serde( rename = "allow" ) ]
40
+ Allow ,
41
+
42
+ /// A confirmation dialog opens with every link trying to open a new website.
43
+ #[ serde( rename = "confirm" ) ]
44
+ Confirm ,
45
+
46
+ /// Deny all links to open a new website.
47
+ #[ serde( rename = "deny" ) ]
48
+ Deny ,
49
+ }
50
+
35
51
pub struct WebNavigatorBackend {
36
52
log_subscriber : Arc < Layered < WASMLayer , Registry > > ,
37
53
allow_script_access : bool ,
38
54
allow_networking : NetworkingAccessMode ,
39
55
upgrade_to_https : bool ,
40
56
base_url : Option < Url > ,
41
- open_url_mode : OpenURLMode ,
57
+ open_url_mode : OpenUrlMode ,
42
58
socket_proxies : Vec < SocketProxy > ,
43
59
credential_allow_list : Vec < String > ,
44
60
player : Weak < Mutex < Player > > ,
@@ -52,7 +68,7 @@ impl WebNavigatorBackend {
52
68
upgrade_to_https : bool ,
53
69
base_url : Option < String > ,
54
70
log_subscriber : Arc < Layered < WASMLayer , Registry > > ,
55
- open_url_mode : OpenURLMode ,
71
+ open_url_mode : OpenUrlMode ,
56
72
socket_proxies : Vec < SocketProxy > ,
57
73
credential_allow_list : Vec < String > ,
58
74
) -> Self {
@@ -168,7 +184,7 @@ impl NavigatorBackend for WebNavigatorBackend {
168
184
let window = window ( ) . expect ( "window()" ) ;
169
185
170
186
if url. scheme ( ) != "javascript" {
171
- if self . open_url_mode == OpenURLMode :: Confirm {
187
+ if self . open_url_mode == OpenUrlMode :: Confirm {
172
188
let message = format ! ( "The SWF file wants to open the website {}" , & url) ;
173
189
// TODO: Add a checkbox with a GUI toolkit
174
190
let confirm = window
@@ -180,7 +196,7 @@ impl NavigatorBackend for WebNavigatorBackend {
180
196
) ;
181
197
return ;
182
198
}
183
- } else if self . open_url_mode == OpenURLMode :: Deny {
199
+ } else if self . open_url_mode == OpenUrlMode :: Deny {
184
200
tracing:: warn!( "SWF tried to open a website, but opening a website is not allowed" ) ;
185
201
return ;
186
202
}
0 commit comments