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;
|
||||
|
||||
pub mod backend;
|
||||
pub mod config;
|
||||
pub mod external;
|
||||
|
||||
pub use chrono;
|
||||
pub use events::PlayerEvent;
|
||||
pub use indexmap;
|
||||
pub use player::{Letterbox, Player};
|
||||
pub use player::Player;
|
||||
pub use swf;
|
||||
pub use swf::Color;
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::backend::locale::LocaleBackend;
|
|||
use crate::backend::navigator::{NavigatorBackend, RequestOptions};
|
||||
use crate::backend::storage::StorageBackend;
|
||||
use crate::backend::{audio::AudioBackend, log::LogBackend, render::RenderBackend, ui::UiBackend};
|
||||
use crate::config::Letterbox;
|
||||
use crate::context::{ActionQueue, ActionType, RenderContext, UpdateContext};
|
||||
use crate::display_object::{EditText, MorphShape, MovieClip};
|
||||
use crate::events::{ButtonKeyCode, ClipEvent, ClipEventResult, KeyCode, PlayerEvent};
|
||||
|
@ -27,8 +28,6 @@ use gc_arena::{make_arena, ArenaParameters, Collect, GcCell};
|
|||
use instant::Instant;
|
||||
use log::info;
|
||||
use rand::{rngs::SmallRng, SeedableRng};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::convert::TryFrom;
|
||||
use std::ops::DerefMut;
|
||||
|
@ -1403,23 +1402,3 @@ unsafe impl<'gc> gc_arena::Collect for DragObject<'gc> {
|
|||
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 ruffle_core::{
|
||||
backend::audio::{AudioBackend, NullAudioBackend},
|
||||
Letterbox, Player,
|
||||
config::Letterbox,
|
||||
Player,
|
||||
};
|
||||
use ruffle_render_wgpu::WgpuRenderBackend;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
|
@ -316,8 +316,6 @@ export class RufflePlayer extends HTMLElement {
|
|||
this.container,
|
||||
this,
|
||||
this.allowScriptAccess,
|
||||
config.upgradeToHttps !== false &&
|
||||
window.location.protocol === "https:",
|
||||
config
|
||||
);
|
||||
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::storage::MemoryStorageBackend;
|
||||
use ruffle_core::backend::storage::StorageBackend;
|
||||
use ruffle_core::config::Letterbox;
|
||||
use ruffle_core::context::UpdateContext;
|
||||
use ruffle_core::events::{KeyCode, MouseWheelDelta};
|
||||
use ruffle_core::external::{
|
||||
|
@ -28,7 +29,7 @@ use ruffle_core::external::{
|
|||
};
|
||||
use ruffle_core::property_map::PropertyMap;
|
||||
use ruffle_core::tag_utils::SwfMovie;
|
||||
use ruffle_core::{Letterbox, PlayerEvent};
|
||||
use ruffle_core::PlayerEvent;
|
||||
use ruffle_web_common::JsResult;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -110,10 +111,22 @@ struct JavascriptInterface {
|
|||
js_player: JavascriptPlayer,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(default = "Default::default")]
|
||||
pub struct Config {
|
||||
#[serde(default)]
|
||||
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.
|
||||
|
@ -130,7 +143,6 @@ impl Ruffle {
|
|||
parent: HtmlElement,
|
||||
js_player: JavascriptPlayer,
|
||||
allow_script_access: bool,
|
||||
upgrade_to_https: bool,
|
||||
config: &JsValue,
|
||||
) -> Result<Ruffle, JsValue> {
|
||||
if RUFFLE_GLOBAL_PANIC.is_completed() {
|
||||
|
@ -142,13 +154,7 @@ impl Ruffle {
|
|||
|
||||
let config: Config = config.into_serde().unwrap_or_default();
|
||||
|
||||
Ruffle::new_internal(
|
||||
parent,
|
||||
js_player,
|
||||
allow_script_access,
|
||||
upgrade_to_https,
|
||||
config,
|
||||
)
|
||||
Ruffle::new_internal(parent, js_player, allow_script_access, config)
|
||||
.map_err(|_| "Error creating player".into())
|
||||
}
|
||||
|
||||
|
@ -314,7 +320,6 @@ impl Ruffle {
|
|||
parent: HtmlElement,
|
||||
js_player: JavascriptPlayer,
|
||||
allow_script_access: bool,
|
||||
upgrade_to_https: bool,
|
||||
config: Config,
|
||||
) -> Result<Ruffle, Box<dyn Error>> {
|
||||
let _ = console_log::init_with_level(log::Level::Trace);
|
||||
|
@ -328,7 +333,7 @@ impl Ruffle {
|
|||
.into_js_result()?;
|
||||
|
||||
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 locale = Box::new(WebLocaleBackend::new());
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ impl WebNavigatorBackend {
|
|||
let window = web_sys::window().expect("window()");
|
||||
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 {
|
||||
start_time: performance.now(),
|
||||
performance,
|
||||
|
|
Loading…
Reference in New Issue