1
1
use rfd:: { MessageButtons , MessageDialog , MessageDialogResult , MessageLevel } ;
2
- use ruffle_core:: backend:: navigator:: OpenURLMode ;
3
2
use ruffle_frontend_utils:: backends:: navigator:: NavigatorInterface ;
4
3
use std:: fs:: File ;
5
4
use std:: io;
@@ -10,7 +9,7 @@ use tokio::sync::oneshot;
10
9
use url:: Url ;
11
10
use winit:: event_loop:: EventLoopProxy ;
12
11
13
- use crate :: cli:: FilesystemAccessMode ;
12
+ use crate :: cli:: { FilesystemAccessMode , OpenUrlMode } ;
14
13
use crate :: custom_event:: RuffleEvent ;
15
14
use crate :: gui:: dialogs:: filesystem_access_dialog:: {
16
15
FilesystemAccessDialogConfiguration , FilesystemAccessDialogResult ,
@@ -19,6 +18,7 @@ use crate::gui::dialogs::network_access_dialog::{
19
18
NetworkAccessDialogConfiguration , NetworkAccessDialogResult ,
20
19
} ;
21
20
use crate :: gui:: DialogDescriptor ;
21
+ use crate :: preferences:: GlobalPreferences ;
22
22
use crate :: util:: open_url;
23
23
24
24
// TODO Make this more generic, maybe a manager?
@@ -75,28 +75,28 @@ impl PathAllowList {
75
75
76
76
#[ derive( Clone ) ]
77
77
pub struct DesktopNavigatorInterface {
78
+ preferences : GlobalPreferences ,
79
+
78
80
// Arc + Mutex due to macOS
79
81
event_loop : Arc < Mutex < EventLoopProxy < RuffleEvent > > > ,
80
82
81
83
filesystem_access_mode : FilesystemAccessMode ,
82
84
83
- open_url_mode : OpenURLMode ,
84
-
85
85
allow_list : PathAllowList ,
86
86
}
87
87
88
88
impl DesktopNavigatorInterface {
89
89
pub fn new (
90
+ preferences : GlobalPreferences ,
90
91
event_loop : EventLoopProxy < RuffleEvent > ,
91
92
movie_path : Option < PathBuf > ,
92
93
filesystem_access_mode : FilesystemAccessMode ,
93
- open_url_mode : OpenURLMode ,
94
94
) -> Self {
95
95
Self {
96
+ preferences,
96
97
event_loop : Arc :: new ( Mutex :: new ( event_loop) ) ,
97
98
allow_list : PathAllowList :: new ( movie_path) ,
98
99
filesystem_access_mode,
99
- open_url_mode,
100
100
}
101
101
}
102
102
@@ -120,12 +120,13 @@ impl DesktopNavigatorInterface {
120
120
121
121
impl NavigatorInterface for DesktopNavigatorInterface {
122
122
fn navigate_to_website ( & self , url : Url ) {
123
- if self . open_url_mode == OpenURLMode :: Deny {
123
+ let open_url_mode = self . preferences . open_url_mode ( ) ;
124
+ if open_url_mode == OpenUrlMode :: Deny {
124
125
tracing:: warn!( "SWF tried to open a website, but opening a website is not allowed" ) ;
125
126
return ;
126
127
}
127
128
128
- if self . open_url_mode == OpenURLMode :: Allow {
129
+ if open_url_mode == OpenUrlMode :: Allow {
129
130
open_url ( & url) ;
130
131
return ;
131
132
}
0 commit comments