Return real page titles and URLs for devtools tab choices.

Fixes #4167.
This commit is contained in:
Greg Weng 2014-12-04 23:09:57 -08:00 committed by Ms2ger
parent 914f27263d
commit a477893ab3
3 changed files with 37 additions and 15 deletions

View file

@ -35,7 +35,7 @@ use actors::root::RootActor;
use actors::tab::TabActor;
use protocol::JsonPacketStream;
use devtools_traits::{ServerExitMsg, DevtoolsControlMsg, NewGlobal, DevtoolScriptControlMsg};
use devtools_traits::{ServerExitMsg, DevtoolsControlMsg, NewGlobal, DevtoolScriptControlMsg, DevtoolsPageInfo};
use servo_msg::constellation_msg::PipelineId;
use servo_util::task::spawn_named;
@ -127,7 +127,8 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
fn handle_new_global(actors: Arc<Mutex<ActorRegistry>>,
pipeline: PipelineId,
sender: Sender<DevtoolScriptControlMsg>,
actor_pipelines: &mut HashMap<PipelineId, String>) {
actor_pipelines: &mut HashMap<PipelineId, String>,
page_info: DevtoolsPageInfo) {
let mut actors = actors.lock();
//TODO: move all this actor creation into a constructor method on TabActor
@ -146,11 +147,12 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
script_chan: sender,
pipeline: pipeline,
};
//TODO: send along the current page title and URL
let DevtoolsPageInfo { title, url } = page_info;
let tab = TabActor {
name: actors.new_name("tab"),
title: "".to_string(),
url: "about:blank".to_string(),
title: title,
url: url.serialize(),
console: console.name(),
inspector: inspector.name(),
};
@ -177,7 +179,7 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
Err(ref e) if e.kind == TimedOut => {
match receiver.try_recv() {
Ok(ServerExitMsg) | Err(Disconnected) => break,
Ok(NewGlobal(id, sender)) => handle_new_global(actors.clone(), id, sender, &mut actor_pipelines),
Ok(NewGlobal(id, sender, pageinfo)) => handle_new_global(actors.clone(), id, sender, &mut actor_pipelines, pageinfo),
Err(Empty) => acceptor.set_timeout(Some(POLL_TIMEOUT)),
}
}