core: Implement suggested changes in PR to documentation & code

- Documentation has been added, improved and clarified.
- The code of a string concatenation has been improved.
This commit is contained in:
Kornelius Rohrschneider 2023-05-02 15:52:37 +02:00 committed by Nathan Adams
parent 27738a492e
commit fe56f8d212
6 changed files with 37 additions and 14 deletions

View File

@ -21,19 +21,19 @@ pub enum NavigationMethod {
Post, Post,
} }
/// The handling mode of navigate_to_url website calls. /// The handling mode of links opening a new website.
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub enum OpenURLMode { pub enum OpenURLMode {
/// Allow all navigate_to_url website calls. /// Allow all links to open a new website.
#[serde(rename = "allow")] #[serde(rename = "allow")]
Allow, Allow,
/// A confirmation dialog opens with every navigate_to_url website call. /// A confirmation dialog opens with every link trying to open a new website.
#[serde(rename = "confirm")] #[serde(rename = "confirm")]
Confirm, Confirm,
/// Deny all navigate_to_url website calls. /// Deny all links to open a new website.
#[serde(rename = "deny")] #[serde(rename = "deny")]
Deny, Deny,
} }

View File

@ -33,11 +33,23 @@ pub enum NetworkingAccessMode {
All, All,
/// The SWF file may not call browser navigation or browser interaction APIs. /// The SWF file may not call browser navigation or browser interaction APIs.
///
/// The APIs getURL(), navigateToURL(), fscommand() and ExternalInterface.call()
/// are prevented in this mode.
#[serde(rename = "internal")] #[serde(rename = "internal")]
Internal, Internal,
/// The SWF file may not call browser navigation or browser interaction APIs /// The SWF file may not call browser navigation or browser interaction APIs
/// and it cannot use any SWF-to-SWF communication APIs. /// and it cannot use any SWF-to-SWF communication APIs.
///
/// Additionally to the ones in internal mode, the APIs sendToURL(),
/// FileReference.download(), FileReference.upload(), Loader.load(),
/// LocalConnection.connect(), LocalConnection.send(), NetConnection.connect(),
/// NetStream.play(), Security.loadPolicyFile(), SharedObject.getLocal(),
/// SharedObject.getRemote(), Socket.connect(), Sound.load(), URLLoader.load(),
/// URLStream.load() and XMLSocket.connect() are prevented in this mode.
///
/// This mode is not implemented yet.
#[serde(rename = "none")] #[serde(rename = "none")]
None, None,
} }

View File

@ -156,7 +156,7 @@ struct Opt {
#[clap(long)] #[clap(long)]
frame_rate: Option<f64>, frame_rate: Option<f64>,
/// The handling mode of navigate_to_url website calls. /// The handling mode of links opening a new website.
#[clap(long, default_value = "allow")] #[clap(long, default_value = "allow")]
open_url_mode: OpenURLMode, open_url_mode: OpenURLMode,
} }

View File

@ -118,8 +118,7 @@ impl NavigatorBackend for ExternalNavigatorBackend {
} }
if self.open_url_mode == OpenURLMode::Confirm { if self.open_url_mode == OpenURLMode::Confirm {
let message = let message = format!("The SWF file wants to open the website {}", processed_url);
"The SWF file wants to open the website ".to_string() + processed_url.as_str();
// TODO: Add a checkbox with a GUI toolkit // TODO: Add a checkbox with a GUI toolkit
let confirm = MessageDialog::new() let confirm = MessageDialog::new()
.set_title("Open website?") .set_title("Open website?")

View File

@ -173,21 +173,21 @@ export interface ObsoleteDuration {
export type Duration = SecsDuration | ObsoleteDuration; export type Duration = SecsDuration | ObsoleteDuration;
/** /**
* The handling mode of navigate_to_url website calls. * The handling mode of links opening a new website.
*/ */
export const enum OpenURLMode { export const enum OpenURLMode {
/** /**
* Allow all navigate_to_url website calls. * Allow all links to open a new website.
*/ */
Allow = "allow", Allow = "allow",
/** /**
* A confirmation dialog opens with every navigate_to_url website call. * A confirmation dialog opens with every link trying to open a new website.
*/ */
Confirm = "confirm", Confirm = "confirm",
/** /**
* Deny all navigate_to_url website calls. * Deny all links to open a new website.
*/ */
Deny = "deny", Deny = "deny",
} }
@ -203,12 +203,24 @@ export const enum NetworkingAccessMode {
/** /**
* The SWF file may not call browser navigation or browser interaction APIs. * The SWF file may not call browser navigation or browser interaction APIs.
*
* The APIs navigateToURL(), fscommand() and ExternalInterface.call() are
* prevented in this mode.
*/ */
Internal = "internal", Internal = "internal",
/** /**
* The SWF file may not call browser navigation or browser interaction APIs * The SWF file may not call browser navigation or browser interaction APIs
* and it cannot use any SWF-to-SWF communication APIs. * and it cannot use any SWF-to-SWF communication APIs.
*
* Additionally to the ones in internal mode, the APIs sendToURL(),
* FileReference.download(), FileReference.upload(), Loader.load(),
* LocalConnection.connect(), LocalConnection.send(), NetConnection.connect(),
* NetStream.play(), Security.loadPolicyFile(), SharedObject.getLocal(),
* SharedObject.getRemote(), Socket.connect(), Sound.load(), URLLoader.load(),
* URLStream.load() and XMLSocket.connect() are prevented in this mode.
*
* This mode is not implemented yet.
*/ */
None = "none", None = "none",
} }
@ -452,14 +464,14 @@ export interface BaseLoadOptions {
polyfills?: boolean; polyfills?: boolean;
/** /**
* The handling mode of navigate_to_url website calls. * The handling mode of links opening a new website.
* *
* @default OpenURLMode.Allow * @default OpenURLMode.Allow
*/ */
openUrlMode?: OpenURLMode; openUrlMode?: OpenURLMode;
/** /**
* Whether and in what way the flash networking APIs can be accessed. * Which flash networking APIs may be accessed.
* *
* @default NetworkingAccessMode.All * @default NetworkingAccessMode.All
*/ */

View File

@ -126,7 +126,7 @@ impl NavigatorBackend for WebNavigatorBackend {
if !js_call { if !js_call {
if self.open_url_mode == OpenURLMode::Confirm { if self.open_url_mode == OpenURLMode::Confirm {
let message = "The SWF file wants to open the website ".to_owned() + &url; let message = format!("The SWF file wants to open the website {}", &url);
// TODO: Add a checkbox with a GUI toolkit // TODO: Add a checkbox with a GUI toolkit
let confirm = window let confirm = window
.confirm_with_message(&message) .confirm_with_message(&message)