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) {
// static
bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) {
if (g_instances == 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;
return AsDevToolsWindow(window_rvh) != NULL;
}
// static
......@@ -614,6 +606,14 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
RenderViewHost* inspected_rvh,
bool force_open,
DevToolsToggleAction action) {
if (!force_open) {
DevToolsWindow* currentDevToolsWindow = AsDevToolsWindow(inspected_rvh);
if (currentDevToolsWindow) {
chrome::CloseAllTabs(currentDevToolsWindow->browser());
return currentDevToolsWindow;
}
}
DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost(
inspected_rvh);
DevToolsManager* manager = DevToolsManager::GetInstance();
......@@ -658,6 +658,19 @@ DevToolsWindow* DevToolsWindow::AsDevToolsWindow(
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() {
if (!docked_) {
if (!browser_->window()->IsActive()) {
......
......@@ -132,6 +132,7 @@ class DevToolsWindow : private content::NotificationObserver,
bool force_open,
DevToolsToggleAction action);
static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*);
static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
// content::DevToolsClientHandlerDelegate overrides.
virtual void ActivateWindow() OVERRIDE;
......
......@@ -730,7 +730,8 @@ void RenderViewContextMenu::AppendDeveloperItems() {
bool show_developer_items = !IsDevToolsURL(params_.page_url);
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;
#if defined(DEBUG_DEVTOOLS)
......
......@@ -220,6 +220,10 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads";
// other threads are not responsive.
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
// without having to restart the browser).
const char kDebugDevToolsFrontend[] = "debug-devtools-frontend";
......
......@@ -70,6 +70,7 @@ extern const char kCountry[];
extern const char kCrashOnHangSeconds[];
extern const char kCrashOnHangThreads[];
extern const char kCrashOnLive[];
extern const char kDebugDevTools[];
extern const char kDebugDevToolsFrontend[];
extern const char kDebugEnableFrameToggle[];
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