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,
}
/// 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))]
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub enum OpenURLMode {
/// Allow all navigate_to_url website calls.
/// Allow all links to open a new website.
#[serde(rename = "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")]
Confirm,
/// Deny all navigate_to_url website calls.
/// Deny all links to open a new website.
#[serde(rename = "deny")]
Deny,
}

View File

@ -33,11 +33,23 @@ pub enum NetworkingAccessMode {
All,
/// 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")]
Internal,
/// The SWF file may not call browser navigation or browser interaction 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")]
None,
}

View File

@ -156,7 +156,7 @@ struct Opt {
#[clap(long)]
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")]
open_url_mode: OpenURLMode,
}

View File

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

View File

@ -173,21 +173,21 @@ export interface 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 {
/**
* Allow all navigate_to_url website calls.
* Allow all links to open a new website.
*/
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",
/**
* Deny all navigate_to_url website calls.
* Deny all links to open a new website.
*/
Deny = "deny",
}
@ -203,12 +203,24 @@ export const enum NetworkingAccessMode {
/**
* 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",
/**
* The SWF file may not call browser navigation or browser interaction 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",
}
@ -452,14 +464,14 @@ export interface BaseLoadOptions {
polyfills?: boolean;
/**
* The handling mode of navigate_to_url website calls.
* The handling mode of links opening a new website.
*
* @default OpenURLMode.Allow
*/
openUrlMode?: OpenURLMode;
/**
* Whether and in what way the flash networking APIs can be accessed.
* Which flash networking APIs may be accessed.
*
* @default NetworkingAccessMode.All
*/

View File

@ -126,7 +126,7 @@ impl NavigatorBackend for WebNavigatorBackend {
if !js_call {
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
let confirm = window
.confirm_with_message(&message)