Skip to content

Commit f4bf36a

Browse files
kjaroshDinnerbone
authored andcommitted
desktop: Use open URL mode from preferences in DesktopNavigatorInterface
1 parent 2e72fd1 commit f4bf36a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

desktop/src/backends/navigator.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use rfd::{MessageButtons, MessageDialog, MessageDialogResult, MessageLevel};
2-
use ruffle_core::backend::navigator::OpenURLMode;
32
use ruffle_frontend_utils::backends::navigator::NavigatorInterface;
43
use std::fs::File;
54
use std::io;
@@ -10,7 +9,7 @@ use tokio::sync::oneshot;
109
use url::Url;
1110
use winit::event_loop::EventLoopProxy;
1211

13-
use crate::cli::FilesystemAccessMode;
12+
use crate::cli::{FilesystemAccessMode, OpenUrlMode};
1413
use crate::custom_event::RuffleEvent;
1514
use crate::gui::dialogs::filesystem_access_dialog::{
1615
FilesystemAccessDialogConfiguration, FilesystemAccessDialogResult,
@@ -19,6 +18,7 @@ use crate::gui::dialogs::network_access_dialog::{
1918
NetworkAccessDialogConfiguration, NetworkAccessDialogResult,
2019
};
2120
use crate::gui::DialogDescriptor;
21+
use crate::preferences::GlobalPreferences;
2222
use crate::util::open_url;
2323

2424
// TODO Make this more generic, maybe a manager?
@@ -75,28 +75,28 @@ impl PathAllowList {
7575

7676
#[derive(Clone)]
7777
pub struct DesktopNavigatorInterface {
78+
preferences: GlobalPreferences,
79+
7880
// Arc + Mutex due to macOS
7981
event_loop: Arc<Mutex<EventLoopProxy<RuffleEvent>>>,
8082

8183
filesystem_access_mode: FilesystemAccessMode,
8284

83-
open_url_mode: OpenURLMode,
84-
8585
allow_list: PathAllowList,
8686
}
8787

8888
impl DesktopNavigatorInterface {
8989
pub fn new(
90+
preferences: GlobalPreferences,
9091
event_loop: EventLoopProxy<RuffleEvent>,
9192
movie_path: Option<PathBuf>,
9293
filesystem_access_mode: FilesystemAccessMode,
93-
open_url_mode: OpenURLMode,
9494
) -> Self {
9595
Self {
96+
preferences,
9697
event_loop: Arc::new(Mutex::new(event_loop)),
9798
allow_list: PathAllowList::new(movie_path),
9899
filesystem_access_mode,
99-
open_url_mode,
100100
}
101101
}
102102

@@ -120,12 +120,13 @@ impl DesktopNavigatorInterface {
120120

121121
impl NavigatorInterface for DesktopNavigatorInterface {
122122
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 {
124125
tracing::warn!("SWF tried to open a website, but opening a website is not allowed");
125126
return;
126127
}
127128

128-
if self.open_url_mode == OpenURLMode::Allow {
129+
if open_url_mode == OpenUrlMode::Allow {
129130
open_url(&url);
130131
return;
131132
}

desktop/src/player.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ impl ActivePlayer {
231231
opt.tcp_connections.unwrap_or(SocketMode::Ask),
232232
Rc::new(content),
233233
DesktopNavigatorInterface::new(
234+
preferences.clone(),
234235
event_loop.clone(),
235236
movie_url.to_file_path().ok(),
236237
opt.filesystem_access_mode,
237-
opt.open_url_mode,
238238
),
239239
);
240240

0 commit comments

Comments
 (0)