summaryrefslogtreecommitdiffstats
path: root/chrome/browser/debugger
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 12:36:21 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 12:36:21 +0000
commit2573a236ea484dd5c07a6871470475a0681722b3 (patch)
tree7c6cb20775086ec74c197b014c0f33f08fd214c8 /chrome/browser/debugger
parent87b603ad919c43e94758d36fd0ba0d3eca2382d5 (diff)
downloadchromium_src-2573a236ea484dd5c07a6871470475a0681722b3.zip
chromium_src-2573a236ea484dd5c07a6871470475a0681722b3.tar.gz
chromium_src-2573a236ea484dd5c07a6871470475a0681722b3.tar.bz2
DevTools: add support for navigating to other tab while inspecting.
Review URL: http://codereview.chromium.org/53098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r--chrome/browser/debugger/devtools_manager.cc85
-rw-r--r--chrome/browser/debugger/devtools_manager.h5
2 files changed, 71 insertions, 19 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 9f63a97..e76ca1b 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -26,20 +26,30 @@ DevToolsManager::~DevToolsManager() {
void DevToolsManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NotificationType::WEB_CONTENTS_DISCONNECTED);
+ DCHECK(type == NotificationType::WEB_CONTENTS_DISCONNECTED ||
+ type == NotificationType::WEB_CONTENTS_SWAPPED);
- Source<WebContents> src(source);
- DevToolsClientHost* client_host = GetDevToolsClientHostFor(*src.ptr());
- if (!client_host) {
- return;
- }
+ if (type == NotificationType::WEB_CONTENTS_DISCONNECTED) {
+ Source<WebContents> src(source);
+ DevToolsClientHost* client_host = GetDevToolsClientHostFor(*src.ptr());
+ if (!client_host) {
+ return;
+ }
- NavigationController* controller = src->controller();
- bool active = (controller->active_contents() == src.ptr());
- if (active) {
- // Active tab contents disconnecting from its renderer means that the tab
- // is closing.
- client_host->InspectedTabClosing();
+ NavigationController* controller = src->controller();
+ bool active = (controller->active_contents() == src.ptr());
+ if (active) {
+ // Active tab contents disconnecting from its renderer means that the tab
+ // is closing.
+ client_host->InspectedTabClosing();
+ UnregisterDevToolsClientHost(client_host, controller);
+ }
+ } else if (type == NotificationType::WEB_CONTENTS_SWAPPED) {
+ Source<WebContents> src(source);
+ DevToolsClientHost* client_host = GetDevToolsClientHostFor(*src.ptr());
+ if (client_host) {
+ SendAttachToAgent(*src.ptr());
+ }
}
}
@@ -65,6 +75,7 @@ void DevToolsManager::RegisterDevToolsClientHostFor(
client_host->set_close_listener(this);
StartListening(navigation_controller);
+ SendAttachToAgent(web_contents);
}
void DevToolsManager::ForwardToDevToolsAgent(
@@ -153,14 +164,20 @@ void DevToolsManager::InspectElement(WebContents* wc, int x, int y) {
void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) {
NavigationController* controller = GetDevToolsAgentNavigationController(
*host);
- DCHECK(controller);
-
- // This should be done before StopListening as the latter checks number of
- // alive devtools instances.
- navcontroller_to_client_host_.erase(controller);
- client_host_to_navcontroller_.erase(host);
+ if (!controller) {
+ return;
+ }
- StopListening(controller);
+ TabContents* tab_contents = controller->active_contents();
+ if (!tab_contents) {
+ return;
+ }
+ WebContents* web_contents = tab_contents->AsWebContents();
+ if (!web_contents) {
+ return;
+ }
+ SendDetachToAgent(*web_contents);
+ UnregisterDevToolsClientHost(host, controller);
}
NavigationController* DevToolsManager::GetDevToolsAgentNavigationController(
@@ -173,6 +190,14 @@ NavigationController* DevToolsManager::GetDevToolsAgentNavigationController(
return NULL;
}
+void DevToolsManager::UnregisterDevToolsClientHost(
+ DevToolsClientHost* client_host,
+ NavigationController* controller) {
+ navcontroller_to_client_host_.erase(controller);
+ client_host_to_navcontroller_.erase(client_host);
+ StopListening(controller);
+}
+
void DevToolsManager::StartListening(
NavigationController* navigation_controller) {
// TODO(yurys): add render host change listener
@@ -182,6 +207,10 @@ void DevToolsManager::StartListening(
this,
NotificationType::WEB_CONTENTS_DISCONNECTED,
NotificationService::AllSources());
+ web_contents_listeners_->Add(
+ this,
+ NotificationType::WEB_CONTENTS_SWAPPED,
+ NotificationService::AllSources());
}
}
@@ -193,3 +222,21 @@ void DevToolsManager::StopListening(
web_contents_listeners_.reset();
}
}
+
+void DevToolsManager::SendAttachToAgent(const WebContents& wc) {
+ RenderViewHost* target_host = wc.render_view_host();
+ if (target_host) {
+ IPC::Message* m = new DevToolsAgentMsg_Attach();
+ m->set_routing_id(target_host->routing_id());
+ target_host->Send(m);
+ }
+}
+
+void DevToolsManager::SendDetachToAgent(const WebContents& wc) {
+ RenderViewHost* target_host = wc.render_view_host();
+ if (target_host) {
+ IPC::Message* m = new DevToolsAgentMsg_Detach();
+ m->set_routing_id(target_host->routing_id());
+ target_host->Send(m);
+ }
+}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 1f9200f..48c887c 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -70,8 +70,13 @@ class DevToolsManager : public NotificationObserver,
NavigationController* GetDevToolsAgentNavigationController(
const DevToolsClientHost& client_host);
+ void UnregisterDevToolsClientHost(
+ DevToolsClientHost* client_host,
+ NavigationController* navigation_controller);
void StartListening(NavigationController* navigation_controller);
void StopListening(NavigationController* navigation_controller);
+ void SendAttachToAgent(const WebContents& web_contents);
+ void SendDetachToAgent(const WebContents& web_contents);
// This object is not NULL iff there is at least one registered
// DevToolsClientHost.