summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 16:46:29 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-06 16:46:29 +0000
commit7c44ec5eac469803e7531e7e604673e536d50753 (patch)
tree47fcaf7a7665cd99cc5b9da6c530fbe8c1b32128
parentab9fb2953e2744a74a5ce3b8e1c830a3bd692543 (diff)
downloadchromium_src-7c44ec5eac469803e7531e7e604673e536d50753.zip
chromium_src-7c44ec5eac469803e7531e7e604673e536d50753.tar.gz
chromium_src-7c44ec5eac469803e7531e7e604673e536d50753.tar.bz2
Pressing Alt once should focus the app menu, but pressing it again should
restore focus back to the previous location. BUG=53906 BUG=51574 TEST=manual Review URL: http://codereview.chromium.org/3618005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61656 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/frame/browser_view.cc12
-rw-r--r--chrome/browser/views/toolbar_view.cc4
-rw-r--r--chrome/browser/views/toolbar_view.h3
3 files changed, 15 insertions, 4 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 8c2eea6..4cd42ba 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -903,12 +903,16 @@ void BrowserView::FocusAppMenu() {
// Chrome doesn't have a traditional menu bar, but it has a menu button in the
// main toolbar that plays the same role. If the user presses a key that
// would typically focus the menu bar, tell the toolbar to focus the menu
- // button. Pass it the storage id of the view where focus should be returned
- // if the user presses escape.
+ // button. If the user presses the key again, return focus to the previous
+ // location.
//
// Not used on the Mac, which has a normal menu bar.
- SaveFocusedView();
- toolbar_->SetToolbarFocusAndFocusAppMenu(last_focused_view_storage_id_);
+ if (toolbar_->IsAppMenuFocused()) {
+ RestoreFocus();
+ } else {
+ SaveFocusedView();
+ toolbar_->SetToolbarFocusAndFocusAppMenu(last_focused_view_storage_id_);
+ }
}
void BrowserView::RotatePaneFocus(bool forwards) {
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 0bd1e1e..1876f0a1 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -210,6 +210,10 @@ void ToolbarView::SetToolbarFocusAndFocusAppMenu(int view_storage_id) {
SetToolbarFocus(view_storage_id, app_menu_);
}
+bool ToolbarView::IsAppMenuFocused() {
+ return app_menu_->HasFocus();
+}
+
void ToolbarView::AddMenuListener(views::MenuListener* listener) {
menu_listeners_.push_back(listener);
}
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index 1cb8fd0..e757f2d 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -65,6 +65,9 @@ class ToolbarView : public AccessibleToolbarView,
// to the ViewStorage with id |view_storage_id| if the user escapes.
void SetToolbarFocusAndFocusAppMenu(int view_storage_id);
+ // Returns true if the app menu is focused.
+ bool IsAppMenuFocused();
+
// Add a listener to receive a callback when the menu opens.
void AddMenuListener(views::MenuListener* listener);