diff options
author | caseq@google.com <caseq@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 08:36:28 +0000 |
---|---|---|
committer | caseq@google.com <caseq@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 08:36:28 +0000 |
commit | a3563a2798200556946598043164e3ff666c160d (patch) | |
tree | 979c9848b381622b010c4ad663aa6602d6403525 /chrome/browser/debugger | |
parent | 2dc383ce26fed9d2964fd75c9364d76f678753a6 (diff) | |
download | chromium_src-a3563a2798200556946598043164e3ff666c160d.zip chromium_src-a3563a2798200556946598043164e3ff666c160d.tar.gz chromium_src-a3563a2798200556946598043164e3ff666c160d.tar.bz2 |
Switch to inspected page tab when opening DevTools in docked mode.
Open, not toggle, DevTools upon click on active view on chrome://extensions
BUG=http://crbug.com/57217
TEST=none
Review URL: http://codereview.chromium.org/3570018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r-- | chrome/browser/debugger/devtools_window.cc | 36 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_window.h | 1 |
2 files changed, 26 insertions, 11 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index bdbdf61..b4a3181 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -124,13 +124,19 @@ void DevToolsWindow::InspectedTabClosing() { void DevToolsWindow::Show(DevToolsToggleAction action) { if (docked_) { - // Just tell inspected browser to update splitter. - BrowserWindow* inspected_window = GetInspectedBrowserWindow(); - if (inspected_window) { + Browser* inspected_browser; + int inspected_tab_index; + // Tell inspected browser to update splitter and switch to inspected panel. + if (FindInspectedBrowserAndTabIndex(&inspected_browser, + &inspected_tab_index)) { + BrowserWindow* inspected_window = inspected_browser->window(); tab_contents_->set_delegate(this); inspected_window->UpdateDevTools(); SetAttachedWindow(); tab_contents_->view()->SetInitialFocus(); + inspected_window->Show(); + TabStripModel* tabstrip_model = inspected_browser->tabstrip_model(); + tabstrip_model->SelectTabContentsAt(inspected_tab_index, true); ScheduleAction(action); return; } else { @@ -228,18 +234,26 @@ void DevToolsWindow::CreateDevToolsBrowser() { TabStripModel::ADD_SELECTED); } -BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { +bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, + int* tab) { + const NavigationController& controller = inspected_tab_->controller(); for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { - Browser* browser = *it; - for (int i = 0; i < browser->tab_count(); ++i) { - TabContents* tab_contents = browser->GetTabContentsAt(i); - if (tab_contents == inspected_tab_) { - return browser->window(); - } + int tab_index = (*it)->GetIndexOfController(&controller); + if (tab_index != TabStripModel::kNoTab) { + *browser = *it; + *tab = tab_index; + return true; } } - return NULL; + return false; +} + +BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { + Browser* browser = NULL; + int tab; + return FindInspectedBrowserAndTabIndex(&browser, &tab) ? + browser->window() : NULL; } void DevToolsWindow::SetAttachedWindow() { diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index 89914a6..85d7e84 100644 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -54,6 +54,7 @@ class DevToolsWindow private: void CreateDevToolsBrowser(); + bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); BrowserWindow* GetInspectedBrowserWindow(); void SetAttachedWindow(); |