summaryrefslogtreecommitdiffstats
path: root/chrome/browser/debugger/devtools_manager.cc
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 07:50:04 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 07:50:04 +0000
commit10fb687b87f5fde62b3df3e2dd5c5d6f5533d715 (patch)
tree32440c96aec4e6fc8f4e9e11f036e599f3e73388 /chrome/browser/debugger/devtools_manager.cc
parentbb965d182303371fece6ca3254689d73a25e5548 (diff)
downloadchromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.zip
chromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.tar.gz
chromium_src-10fb687b87f5fde62b3df3e2dd5c5d6f5533d715.tar.bz2
DevTools: Introduce docked version of DevTools.
Review URL: http://codereview.chromium.org/149071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger/devtools_manager.cc')
-rw-r--r--chrome/browser/debugger/devtools_manager.cc83
1 files changed, 67 insertions, 16 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 40dfbb8..605553a 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/site_instance.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/devtools_messages.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -56,18 +57,9 @@ void DevToolsManager::RegisterDevToolsClientHostFor(
void DevToolsManager::ForwardToDevToolsAgent(
RenderViewHost* client_rvh,
const IPC::Message& message) {
- for (InspectedRvhToClientHostMap::iterator it =
- inspected_rvh_to_client_host_.begin();
- it != inspected_rvh_to_client_host_.end();
- ++it) {
- DevToolsWindow* win = it->second->AsDevToolsWindow();
- if (!win) {
- continue;
- }
- if (client_rvh == win->GetRenderViewHost()) {
- ForwardToDevToolsAgent(win, message);
- return;
- }
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (client_host) {
+ ForwardToDevToolsAgent(client_host, message);
}
}
@@ -96,11 +88,34 @@ void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh,
client_host->SendMessageToClient(message);
}
-void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
+void DevToolsManager::CloseWindow(RenderViewHost* client_rvh) {
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (!client_host) {
+ return;
+ }
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ SendDetachToAgent(inspected_rvh);
+
+ UnregisterDevToolsClientHostFor(inspected_rvh);
+}
+
+void DevToolsManager::DockWindow(RenderViewHost* client_rvh) {
+ ReopenWindow(client_rvh, true);
+}
+
+void DevToolsManager::UndockWindow(RenderViewHost* client_rvh) {
+ ReopenWindow(client_rvh, false);
+}
+
+void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh,
+ bool docked) {
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
- host = new DevToolsWindow(
- inspected_rvh->site_instance()->browsing_instance()->profile());
+ host = DevToolsWindow::CreateDevToolsWindow(
+ inspected_rvh->site_instance()->browsing_instance()->profile(),
+ inspected_rvh,
+ docked);
RegisterDevToolsClientHostFor(inspected_rvh, host);
}
DevToolsWindow* window = host->AsDevToolsWindow();
@@ -147,12 +162,14 @@ void DevToolsManager::UnregisterDevToolsClientHostFor(
if (!host) {
return;
}
- host->InspectedTabClosing();
inspected_rvh_to_client_host_.erase(inspected_rvh);
client_host_to_inspected_rvh_.erase(host);
if (inspected_rvh_for_reopen_ == inspected_rvh) {
inspected_rvh_for_reopen_ = NULL;
}
+
+ // Issue tab closing event post unbound.
+ host->InspectedTabClosing();
}
void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh,
@@ -214,3 +231,37 @@ void DevToolsManager::ForceReopenWindow() {
OpenDevToolsWindow(inspected_rvn);
}
}
+
+DevToolsClientHost* DevToolsManager::FindOnwerDevToolsClientHost(
+ RenderViewHost* client_rvh) {
+ for (InspectedRvhToClientHostMap::iterator it =
+ inspected_rvh_to_client_host_.begin();
+ it != inspected_rvh_to_client_host_.end();
+ ++it) {
+ DevToolsWindow* win = it->second->AsDevToolsWindow();
+ if (!win) {
+ continue;
+ }
+ if (client_rvh == win->GetRenderViewHost()) {
+ return it->second;
+ }
+ }
+ return NULL;
+}
+
+void DevToolsManager::ReopenWindow(RenderViewHost* client_rvh, bool docked) {
+ DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
+ if (!client_host) {
+ return;
+ }
+ DevToolsWindow* window = client_host->AsDevToolsWindow();
+ DCHECK(window);
+ if (window->is_docked() == docked) {
+ return;
+ }
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ SendDetachToAgent(inspected_rvh);
+ UnregisterDevToolsClientHostFor(inspected_rvh);
+ OpenDevToolsWindow(inspected_rvh, docked);
+}