Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow embedders to provide user agent string #25672

Closed
wants to merge 8 commits into from

Fix constellation

  • Loading branch information
mediremi committed Feb 1, 2020
commit 6e434345a8eda1fa2eee6b942b20470f375e9370
@@ -160,7 +160,7 @@ use servo_config::{opts, pref};
use servo_rand::{random, Rng, ServoRng, SliceRandom};
use servo_remutex::ReentrantMutex;
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use std::borrow::ToOwned;
use std::borrow::{Cow, ToOwned};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet, VecDeque};
use std::marker::PhantomData;
@@ -491,6 +491,9 @@ pub struct Constellation<Message, LTF, STF> {

/// Pipeline ID of the active media session.
active_media_session: Option<PipelineId>,

/// User agent string
pub user_agent: Cow<'static, str>
}

/// State needed to construct a constellation.
@@ -547,6 +550,9 @@ pub struct InitialConstellationState {

/// Mechanism to force the compositor to process events.
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,

/// User agent string
pub user_agent: Cow<'static, str>
}

/// Data needed for webdriver
@@ -980,6 +986,7 @@ where
player_context: state.player_context,
event_loop_waker: state.event_loop_waker,
active_media_session: None,
user_agent: state.user_agent,
};

constellation.run();
@@ -1227,6 +1234,7 @@ where
webxr_registry: self.webxr_registry.clone(),
player_context: self.player_context.clone(),
event_loop_waker: self.event_loop_waker.as_ref().map(|w| (*w).clone_box()),
user_agent: self.user_agent.clone()
});

let pipeline = match result {
@@ -40,6 +40,7 @@ use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData};
use servo_config::opts::{self, Opts};
use servo_config::{prefs, prefs::PrefValue};
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
#[cfg(not(windows))]
use std::env;
@@ -204,6 +205,9 @@ pub struct InitialPipelineState {

/// Mechanism to force the compositor to process events.
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,

/// User agent string
pub user_agent: Cow<'static, str>
}

pub struct NewPipeline {
@@ -307,6 +311,7 @@ impl Pipeline {
webvr_chan: state.webvr_chan,
webxr_registry: state.webxr_registry,
player_context: state.player_context,
user_agent: state.user_agent
};

// Spawn the child process.
@@ -514,6 +519,7 @@ pub struct UnprivilegedPipelineContent {
webvr_chan: Option<IpcSender<WebVRMsg>>,
webxr_registry: webxr_api::Registry,
player_context: WindowGLContext,
user_agent: Cow<'static, str>
}

impl UnprivilegedPipelineContent {
@@ -570,6 +576,7 @@ impl UnprivilegedPipelineContent {
layout_is_busy: layout_thread_busy_flag.clone(),
player_context: self.player_context.clone(),
event_loop_waker,
user_agent: self.user_agent
},
self.load_data.clone(),
self.opts.profile_script_events,
@@ -582,7 +589,6 @@ impl UnprivilegedPipelineContent {
self.opts.userscripts,
self.opts.headless,
self.opts.replace_surrogates,
self.opts.user_agent,
);

LTF::create(
@@ -741,7 +741,6 @@ impl ScriptThreadFactory for ScriptThread {
userscripts_path: Option<String>,
headless: bool,
replace_surrogates: bool,
user_agent: Cow<'static, str>,
) -> (Sender<message::Msg>, Receiver<message::Msg>) {
let (script_chan, script_port) = unbounded();

@@ -763,6 +762,7 @@ impl ScriptThreadFactory for ScriptThread {
let mem_profiler_chan = state.mem_profiler_chan.clone();
let window_size = state.window_size;
let layout_is_busy = state.layout_is_busy.clone();
let user_agent = state.user_agent.clone();

let script_thread = ScriptThread::new(
state,
@@ -704,7 +704,6 @@ pub trait ScriptThreadFactory {
userscripts_path: Option<String>,
headless: bool,
replace_surrogates: bool,
user_agent: Cow<'static, str>,
) -> (Sender<Self::Message>, Receiver<Self::Message>);
}

@@ -862,7 +861,7 @@ pub struct WorkerGlobalScopeInit {
pub origin: ImmutableOrigin,
/// True if headless mode
pub is_headless: bool,
/// An optional string allowing the user agnet to be set for testing.
/// User agent string
pub user_agent: Cow<'static, str>,
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.