Commit 30f6403d authored by apavlov@chromium.org's avatar apavlov@chromium.org

Make F12 close an undocked DevTools window rather than open another DevTools window for this one.

BUG=139581

Review URL: https://chromiumcodereview.appspot.com/10824089

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149396 0039d316-1c4b-4281-b951-d872f2087c98
parent e6fbecf2
...@@ -103,15 +103,7 @@ TabContents* DevToolsWindow::GetDevToolsContents(WebContents* inspected_tab) { ...@@ -103,15 +103,7 @@ TabContents* DevToolsWindow::GetDevToolsContents(WebContents* inspected_tab) {
// static // static
bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) {
if (g_instances == NULL) return AsDevToolsWindow(window_rvh) != NULL;
return false;
DevToolsWindowList& instances = g_instances.Get();
for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
if ((*it)->tab_contents_->web_contents()->GetRenderViewHost() == window_rvh)
return true;
}
return false;
} }
// static // static
...@@ -614,6 +606,14 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( ...@@ -614,6 +606,14 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
RenderViewHost* inspected_rvh, RenderViewHost* inspected_rvh,
bool force_open, bool force_open,
DevToolsToggleAction action) { DevToolsToggleAction action) {
if (!force_open) {
DevToolsWindow* currentDevToolsWindow = AsDevToolsWindow(inspected_rvh);
if (currentDevToolsWindow) {
chrome::CloseAllTabs(currentDevToolsWindow->browser());
return currentDevToolsWindow;
}
}
DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost(
inspected_rvh); inspected_rvh);
DevToolsManager* manager = DevToolsManager::GetInstance(); DevToolsManager* manager = DevToolsManager::GetInstance();
...@@ -658,6 +658,19 @@ DevToolsWindow* DevToolsWindow::AsDevToolsWindow( ...@@ -658,6 +658,19 @@ DevToolsWindow* DevToolsWindow::AsDevToolsWindow(
return NULL; return NULL;
} }
// static
DevToolsWindow* DevToolsWindow::AsDevToolsWindow(RenderViewHost* rvh) {
if (g_instances == NULL)
return NULL;
DevToolsWindowList& instances = g_instances.Get();
for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
if ((*it)->tab_contents_->web_contents()->GetRenderViewHost() == rvh)
return *it;
}
return NULL;
}
void DevToolsWindow::ActivateWindow() { void DevToolsWindow::ActivateWindow() {
if (!docked_) { if (!docked_) {
if (!browser_->window()->IsActive()) { if (!browser_->window()->IsActive()) {
......
...@@ -132,6 +132,7 @@ class DevToolsWindow : private content::NotificationObserver, ...@@ -132,6 +132,7 @@ class DevToolsWindow : private content::NotificationObserver,
bool force_open, bool force_open,
DevToolsToggleAction action); DevToolsToggleAction action);
static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*); static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*);
static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
// content::DevToolsClientHandlerDelegate overrides. // content::DevToolsClientHandlerDelegate overrides.
virtual void ActivateWindow() OVERRIDE; virtual void ActivateWindow() OVERRIDE;
......
...@@ -730,7 +730,8 @@ void RenderViewContextMenu::AppendDeveloperItems() { ...@@ -730,7 +730,8 @@ void RenderViewContextMenu::AppendDeveloperItems() {
bool show_developer_items = !IsDevToolsURL(params_.page_url); bool show_developer_items = !IsDevToolsURL(params_.page_url);
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDebugDevToolsFrontend)) if (command_line.HasSwitch(switches::kDebugDevToolsFrontend) ||
command_line.HasSwitch(switches::kDebugDevTools))
show_developer_items = true; show_developer_items = true;
#if defined(DEBUG_DEVTOOLS) #if defined(DEBUG_DEVTOOLS)
......
...@@ -220,6 +220,10 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads"; ...@@ -220,6 +220,10 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads";
// other threads are not responsive. // other threads are not responsive.
const char kCrashOnLive[] = "crash-on-live"; const char kCrashOnLive[] = "crash-on-live";
// Enables recursive devtools frontend debugging by enforcing the
// "Inspect Element" context menu item in devtools windows.
const char kDebugDevTools[] = "debug-devtools";
// Path to the inspector files on disk (allows reloading of devtool files // Path to the inspector files on disk (allows reloading of devtool files
// without having to restart the browser). // without having to restart the browser).
const char kDebugDevToolsFrontend[] = "debug-devtools-frontend"; const char kDebugDevToolsFrontend[] = "debug-devtools-frontend";
......
...@@ -70,6 +70,7 @@ extern const char kCountry[]; ...@@ -70,6 +70,7 @@ extern const char kCountry[];
extern const char kCrashOnHangSeconds[]; extern const char kCrashOnHangSeconds[];
extern const char kCrashOnHangThreads[]; extern const char kCrashOnHangThreads[];
extern const char kCrashOnLive[]; extern const char kCrashOnLive[];
extern const char kDebugDevTools[];
extern const char kDebugDevToolsFrontend[]; extern const char kDebugDevToolsFrontend[];
extern const char kDebugEnableFrameToggle[]; extern const char kDebugEnableFrameToggle[];
extern const char kDebugPrint[]; extern const char kDebugPrint[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment