summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 17:33:53 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 17:33:53 +0000
commit45437aaa3aba09a6d2c2ed1e4d4fadc550ffc6d4 (patch)
tree6cb88ac4afd5e80ece1e3420b121382944b277c8 /chrome/browser
parent4d1218e091dae7e30ad59150bfeb4acaade10c0f (diff)
downloadchromium_src-45437aaa3aba09a6d2c2ed1e4d4fadc550ffc6d4.zip
chromium_src-45437aaa3aba09a6d2c2ed1e4d4fadc550ffc6d4.tar.gz
chromium_src-45437aaa3aba09a6d2c2ed1e4d4fadc550ffc6d4.tar.bz2
Focus last focused view when DevTools window is being closed or undocked.
Review URL: http://codereview.chromium.org/155345 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/frame/browser_view.cc25
-rw-r--r--chrome/browser/views/frame/browser_view.h6
2 files changed, 28 insertions, 3 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 937a79a5..53b869b 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -64,6 +64,7 @@
#endif
#include "views/controls/single_split_view.h"
#include "views/fill_layout.h"
+#include "views/focus/external_focus_tracker.h"
#include "views/view.h"
#include "views/widget/root_view.h"
#include "views/window/dialog_delegate.h"
@@ -1624,14 +1625,32 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) {
void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) {
TabContents* devtools_contents =
DevToolsWindow::GetDevToolsContents(tab_contents);
+
+ bool should_show = devtools_contents && !devtools_container_->IsVisible();
+ bool should_hide = !devtools_contents && devtools_container_->IsVisible();
+
devtools_container_->ChangeTabContents(devtools_contents);
- if (!devtools_contents && devtools_container_->IsVisible()) {
+
+ if (should_show) {
+ if (!devtools_focus_tracker_.get()) {
+ // Install devtools focus tracker when dev tools window is shown for the
+ // first time.
+ devtools_focus_tracker_.reset(
+ new views::ExternalFocusTracker(devtools_container_,
+ GetFocusManager()));
+ }
+ devtools_container_->SetVisible(true);
+ contents_split_->Layout();
+ } else if (should_hide) {
// Store split offset when hiding devtools window only.
g_browser_process->local_state()->SetInteger(
prefs::kDevToolsSplitLocation, contents_split_->divider_offset());
+ // Restore focus to the last focused view when hiding devtools window.
+ devtools_focus_tracker_->FocusLastFocusedExternalView();
+
+ devtools_container_->SetVisible(false);
+ contents_split_->Layout();
}
- devtools_container_->SetVisible(devtools_contents != NULL);
- contents_split_->Layout();
}
void BrowserView::UpdateUIForContents(TabContents* contents) {
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 3aaf547..fdb5f86 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -45,6 +45,7 @@ class ToolbarView;
class ZoomMenuModel;
namespace views {
+class ExternalFocusTracker;
class Menu;
class SingleSplitView;
}
@@ -420,6 +421,11 @@ class BrowserView : public BrowserWindow,
// Split view containing the contents container and devtools container.
views::SingleSplitView* contents_split_;
+ // Tracks and stores the last focused view which is not the
+ // devtools_container_ or any of its children. Used to restore focus once
+ // the devtools_container_ is hidden.
+ scoped_ptr<views::ExternalFocusTracker> devtools_focus_tracker_;
+
// The Status information bubble that appears at the bottom of the window.
scoped_ptr<StatusBubbleViews> status_bubble_;