summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 14:17:49 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 14:17:49 +0000
commit3061ccf369ee2642d4d18ac396b6758acebc3509 (patch)
treef0b7fbf512ec6c7d4f5e11add080de841ecbe8bb /chrome/browser
parent66d3b79bcf21a71326b99b5a222a04d78db594bc (diff)
downloadchromium_src-3061ccf369ee2642d4d18ac396b6758acebc3509.zip
chromium_src-3061ccf369ee2642d4d18ac396b6758acebc3509.tar.gz
chromium_src-3061ccf369ee2642d4d18ac396b6758acebc3509.tar.bz2
DevTools: Toggle docked devtools window on shortcut.
Review URL: http://codereview.chromium.org/149527 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/browser.h2
-rw-r--r--chrome/browser/debugger/devtools_manager.cc68
-rw-r--r--chrome/browser/debugger/devtools_manager.h6
4 files changed, 55 insertions, 27 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 3a294e5..6568032 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1075,9 +1075,9 @@ void Browser::OpenCreateShortcutsDialog() {
#endif
}
-void Browser::OpenJavaScriptConsole() {
+void Browser::ToggleJavaScriptConsole() {
UserMetrics::RecordAction(L"ShowJSConsole", profile_);
- DevToolsManager::GetInstance()->OpenDevToolsWindow(
+ DevToolsManager::GetInstance()->ToggleDevToolsWindow(
GetSelectedTabContents()->render_view_host());
}
@@ -1357,7 +1357,7 @@ void Browser::ExecuteCommandWithDisposition(
// Show various bits of UI
case IDC_OPEN_FILE: OpenFile(); break;
case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break;
- case IDC_JS_CONSOLE: OpenJavaScriptConsole(); break;
+ case IDC_JS_CONSOLE: ToggleJavaScriptConsole(); break;
case IDC_TASK_MANAGER: OpenTaskManager(); break;
case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break;
case IDC_NEW_PROFILE: OpenNewProfileDialog(); break;
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 4d84df7..b581f40 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -351,7 +351,7 @@ class Browser : public TabStripModelDelegate,
// Show various bits of UI
void OpenFile();
void OpenCreateShortcutsDialog();
- void OpenJavaScriptConsole();
+ void ToggleJavaScriptConsole();
void OpenTaskManager();
void OpenSelectProfileDialog();
void OpenNewProfileDialog();
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 04c8e92..8cc56d0 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -105,14 +105,9 @@ void DevToolsManager::ActivateWindow(RenderViewHost* client_rvh) {
void DevToolsManager::CloseWindow(RenderViewHost* client_rvh) {
DevToolsClientHost* client_host = FindOnwerDevToolsClientHost(client_rvh);
- if (!client_host) {
- return;
+ if (client_host) {
+ CloseWindow(client_host);
}
- RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
- DCHECK(inspected_rvh);
- SendDetachToAgent(inspected_rvh);
-
- UnregisterDevToolsClientHostFor(inspected_rvh);
}
void DevToolsManager::DockWindow(RenderViewHost* client_rvh) {
@@ -124,22 +119,11 @@ void DevToolsManager::UndockWindow(RenderViewHost* client_rvh) {
}
void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) {
- DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
- if (!host) {
- bool docked = inspected_rvh->process()->profile()->GetPrefs()->
- GetBoolean(prefs::kDevToolsOpenDocked);
- host = new DevToolsWindow(
- inspected_rvh->site_instance()->browsing_instance()->profile(),
- inspected_rvh,
- docked);
- RegisterDevToolsClientHostFor(inspected_rvh, host);
- }
- DevToolsWindow* window = host->AsDevToolsWindow();
- if (window) {
- in_initial_show_ = true;
- window->Show();
- in_initial_show_ = false;
- }
+ ToggleDevToolsWindow(inspected_rvh, true);
+}
+
+void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh) {
+ ToggleDevToolsWindow(inspected_rvh, false);
}
void DevToolsManager::InspectElement(RenderViewHost* inspected_rvh,
@@ -279,3 +263,41 @@ void DevToolsManager::ReopenWindow(RenderViewHost* client_rvh, bool docked) {
DCHECK(window);
window->SetDocked(docked);
}
+
+void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh,
+ bool force_open) {
+ bool do_open = force_open;
+ DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
+ if (!host) {
+ bool docked = inspected_rvh->process()->profile()->GetPrefs()->
+ GetBoolean(prefs::kDevToolsOpenDocked);
+ host = new DevToolsWindow(
+ inspected_rvh->site_instance()->browsing_instance()->profile(),
+ inspected_rvh,
+ docked);
+ RegisterDevToolsClientHostFor(inspected_rvh, host);
+ do_open = true;
+ }
+ DevToolsWindow* window = host->AsDevToolsWindow();
+ if (!window) {
+ return;
+ }
+
+ // If window is docked and visible, we hide it on toggle. If window is
+ // undocked, we show (activate) it.
+ if (!window->is_docked() || do_open) {
+ in_initial_show_ = true;
+ window->Show();
+ in_initial_show_ = false;
+ } else {
+ CloseWindow(host);
+ }
+}
+
+void DevToolsManager::CloseWindow(DevToolsClientHost* client_host) {
+ RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(client_host);
+ DCHECK(inspected_rvh);
+ SendDetachToAgent(inspected_rvh);
+
+ UnregisterDevToolsClientHostFor(inspected_rvh);
+}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 5b6261c..27ab730 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -54,6 +54,8 @@ class DevToolsManager : public DevToolsClientHost::CloseListener,
void OpenDevToolsWindow(RenderViewHost* inspected_rvh);
+ void ToggleDevToolsWindow(RenderViewHost* inspected_rvh);
+
// Starts element inspection in the devtools client.
// Creates one by means of OpenDevToolsWindow if no client
// exists.
@@ -83,8 +85,12 @@ private:
DevToolsClientHost* FindOnwerDevToolsClientHost(RenderViewHost* client_rvh);
+ void ToggleDevToolsWindow(RenderViewHost* inspected_rvh, bool force_open);
+
void ReopenWindow(RenderViewHost* client_rvh, bool docked);
+ void CloseWindow(DevToolsClientHost* client_host);
+
// These two maps are for tracking dependencies between inspected tabs and
// their DevToolsClientHosts. They are usful for routing devtools messages
// and allow us to have at most one devtools client host per tab. We use