web: Remove upgrade_to_https param from Ruffle::new
Grab it from the `config` directly instead of using an extra param.
This commit is contained in:
parent
bacb66b97b
commit
01aca9f861
|
@ -43,11 +43,12 @@ mod vminterface;
|
||||||
mod xml;
|
mod xml;
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
|
pub mod config;
|
||||||
pub mod external;
|
pub mod external;
|
||||||
|
|
||||||
pub use chrono;
|
pub use chrono;
|
||||||
pub use events::PlayerEvent;
|
pub use events::PlayerEvent;
|
||||||
pub use indexmap;
|
pub use indexmap;
|
||||||
pub use player::{Letterbox, Player};
|
pub use player::Player;
|
||||||
pub use swf;
|
pub use swf;
|
||||||
pub use swf::Color;
|
pub use swf::Color;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use crate::backend::locale::LocaleBackend;
|
||||||
use crate::backend::navigator::{NavigatorBackend, RequestOptions};
|
use crate::backend::navigator::{NavigatorBackend, RequestOptions};
|
||||||
use crate::backend::storage::StorageBackend;
|
use crate::backend::storage::StorageBackend;
|
||||||
use crate::backend::{audio::AudioBackend, log::LogBackend, render::RenderBackend, ui::UiBackend};
|
use crate::backend::{audio::AudioBackend, log::LogBackend, render::RenderBackend, ui::UiBackend};
|
||||||
|
use crate::config::Letterbox;
|
||||||
use crate::context::{ActionQueue, ActionType, RenderContext, UpdateContext};
|
use crate::context::{ActionQueue, ActionType, RenderContext, UpdateContext};
|
||||||
use crate::display_object::{EditText, MorphShape, MovieClip};
|
use crate::display_object::{EditText, MorphShape, MovieClip};
|
||||||
use crate::events::{ButtonKeyCode, ClipEvent, ClipEventResult, KeyCode, PlayerEvent};
|
use crate::events::{ButtonKeyCode, ClipEvent, ClipEventResult, KeyCode, PlayerEvent};
|
||||||
|
@ -27,8 +28,6 @@ use gc_arena::{make_arena, ArenaParameters, Collect, GcCell};
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rand::{rngs::SmallRng, SeedableRng};
|
use rand::{rngs::SmallRng, SeedableRng};
|
||||||
#[cfg(feature = "serde")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
@ -1403,23 +1402,3 @@ unsafe impl<'gc> gc_arena::Collect for DragObject<'gc> {
|
||||||
self.display_object.trace(cc);
|
self.display_object.trace(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[cfg_attr(feature = "serde", serde(rename = "letterbox"))]
|
|
||||||
pub enum Letterbox {
|
|
||||||
#[cfg_attr(feature = "serde", serde(rename = "off"))]
|
|
||||||
Off,
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", serde(rename = "fullscreen"))]
|
|
||||||
Fullscreen,
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", serde(rename = "on"))]
|
|
||||||
On,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Letterbox {
|
|
||||||
fn default() -> Self {
|
|
||||||
Letterbox::Fullscreen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ use clap::Clap;
|
||||||
use isahc::{config::RedirectPolicy, prelude::*, HttpClient};
|
use isahc::{config::RedirectPolicy, prelude::*, HttpClient};
|
||||||
use ruffle_core::{
|
use ruffle_core::{
|
||||||
backend::audio::{AudioBackend, NullAudioBackend},
|
backend::audio::{AudioBackend, NullAudioBackend},
|
||||||
Letterbox, Player,
|
config::Letterbox,
|
||||||
|
Player,
|
||||||
};
|
};
|
||||||
use ruffle_render_wgpu::WgpuRenderBackend;
|
use ruffle_render_wgpu::WgpuRenderBackend;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
|
@ -316,8 +316,6 @@ export class RufflePlayer extends HTMLElement {
|
||||||
this.container,
|
this.container,
|
||||||
this,
|
this,
|
||||||
this.allowScriptAccess,
|
this.allowScriptAccess,
|
||||||
config.upgradeToHttps !== false &&
|
|
||||||
window.location.protocol === "https:",
|
|
||||||
config
|
config
|
||||||
);
|
);
|
||||||
console.log("New Ruffle instance created.");
|
console.log("New Ruffle instance created.");
|
||||||
|
|
|
@ -21,6 +21,7 @@ use ruffle_core::backend::input::InputBackend;
|
||||||
use ruffle_core::backend::render::RenderBackend;
|
use ruffle_core::backend::render::RenderBackend;
|
||||||
use ruffle_core::backend::storage::MemoryStorageBackend;
|
use ruffle_core::backend::storage::MemoryStorageBackend;
|
||||||
use ruffle_core::backend::storage::StorageBackend;
|
use ruffle_core::backend::storage::StorageBackend;
|
||||||
|
use ruffle_core::config::Letterbox;
|
||||||
use ruffle_core::context::UpdateContext;
|
use ruffle_core::context::UpdateContext;
|
||||||
use ruffle_core::events::{KeyCode, MouseWheelDelta};
|
use ruffle_core::events::{KeyCode, MouseWheelDelta};
|
||||||
use ruffle_core::external::{
|
use ruffle_core::external::{
|
||||||
|
@ -28,7 +29,7 @@ use ruffle_core::external::{
|
||||||
};
|
};
|
||||||
use ruffle_core::property_map::PropertyMap;
|
use ruffle_core::property_map::PropertyMap;
|
||||||
use ruffle_core::tag_utils::SwfMovie;
|
use ruffle_core::tag_utils::SwfMovie;
|
||||||
use ruffle_core::{Letterbox, PlayerEvent};
|
use ruffle_core::PlayerEvent;
|
||||||
use ruffle_web_common::JsResult;
|
use ruffle_web_common::JsResult;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
@ -110,10 +111,22 @@ struct JavascriptInterface {
|
||||||
js_player: JavascriptPlayer,
|
js_player: JavascriptPlayer,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(default = "Default::default")]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(default)]
|
|
||||||
letterbox: Letterbox,
|
letterbox: Letterbox,
|
||||||
|
|
||||||
|
#[serde(rename = "upgradeToHttps")]
|
||||||
|
upgrade_to_https: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
letterbox: Default::default(),
|
||||||
|
upgrade_to_https: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An opaque handle to a `RuffleInstance` inside the pool.
|
/// An opaque handle to a `RuffleInstance` inside the pool.
|
||||||
|
@ -130,7 +143,6 @@ impl Ruffle {
|
||||||
parent: HtmlElement,
|
parent: HtmlElement,
|
||||||
js_player: JavascriptPlayer,
|
js_player: JavascriptPlayer,
|
||||||
allow_script_access: bool,
|
allow_script_access: bool,
|
||||||
upgrade_to_https: bool,
|
|
||||||
config: &JsValue,
|
config: &JsValue,
|
||||||
) -> Result<Ruffle, JsValue> {
|
) -> Result<Ruffle, JsValue> {
|
||||||
if RUFFLE_GLOBAL_PANIC.is_completed() {
|
if RUFFLE_GLOBAL_PANIC.is_completed() {
|
||||||
|
@ -142,14 +154,8 @@ impl Ruffle {
|
||||||
|
|
||||||
let config: Config = config.into_serde().unwrap_or_default();
|
let config: Config = config.into_serde().unwrap_or_default();
|
||||||
|
|
||||||
Ruffle::new_internal(
|
Ruffle::new_internal(parent, js_player, allow_script_access, config)
|
||||||
parent,
|
.map_err(|_| "Error creating player".into())
|
||||||
js_player,
|
|
||||||
allow_script_access,
|
|
||||||
upgrade_to_https,
|
|
||||||
config,
|
|
||||||
)
|
|
||||||
.map_err(|_| "Error creating player".into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stream an arbitrary movie file from (presumably) the Internet.
|
/// Stream an arbitrary movie file from (presumably) the Internet.
|
||||||
|
@ -314,7 +320,6 @@ impl Ruffle {
|
||||||
parent: HtmlElement,
|
parent: HtmlElement,
|
||||||
js_player: JavascriptPlayer,
|
js_player: JavascriptPlayer,
|
||||||
allow_script_access: bool,
|
allow_script_access: bool,
|
||||||
upgrade_to_https: bool,
|
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Ruffle, Box<dyn Error>> {
|
) -> Result<Ruffle, Box<dyn Error>> {
|
||||||
let _ = console_log::init_with_level(log::Level::Trace);
|
let _ = console_log::init_with_level(log::Level::Trace);
|
||||||
|
@ -328,7 +333,7 @@ impl Ruffle {
|
||||||
.into_js_result()?;
|
.into_js_result()?;
|
||||||
|
|
||||||
let audio = Box::new(WebAudioBackend::new()?);
|
let audio = Box::new(WebAudioBackend::new()?);
|
||||||
let navigator = Box::new(WebNavigatorBackend::new(upgrade_to_https));
|
let navigator = Box::new(WebNavigatorBackend::new(config.upgrade_to_https));
|
||||||
let input = Box::new(WebInputBackend::new(&canvas));
|
let input = Box::new(WebInputBackend::new(&canvas));
|
||||||
let locale = Box::new(WebLocaleBackend::new());
|
let locale = Box::new(WebLocaleBackend::new());
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ impl WebNavigatorBackend {
|
||||||
let window = web_sys::window().expect("window()");
|
let window = web_sys::window().expect("window()");
|
||||||
let performance = window.performance().expect("window.performance()");
|
let performance = window.performance().expect("window.performance()");
|
||||||
|
|
||||||
|
// Upgarde to HTTPS takes effect if the current page is hosted on HTTPS.
|
||||||
|
let upgrade_to_https =
|
||||||
|
upgrade_to_https && window.location().protocol().unwrap_or_default() == "https:";
|
||||||
|
|
||||||
WebNavigatorBackend {
|
WebNavigatorBackend {
|
||||||
start_time: performance.now(),
|
start_time: performance.now(),
|
||||||
performance,
|
performance,
|
||||||
|
|
Loading…
Reference in New Issue