summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/frame/browser_view.cc
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 15:33:01 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 15:33:01 +0000
commitcc8243726aa110ed22194e7ebde5ea69430b6ab4 (patch)
tree455cce5da51deeb47c962ea7c2cb62331e896973 /chrome/browser/views/frame/browser_view.cc
parent3c5f059a2881b0d990e49cbc2b1e5a3dd4e9df7f (diff)
downloadchromium_src-cc8243726aa110ed22194e7ebde5ea69430b6ab4.zip
chromium_src-cc8243726aa110ed22194e7ebde5ea69430b6ab4.tar.gz
chromium_src-cc8243726aa110ed22194e7ebde5ea69430b6ab4.tar.bz2
Keyboard accessibility for the page and app menus.
Works on Windows, and on Linux with toolkit_views. The goal is to make Chrome behave more like a standard Windows application, for users who rely on the keyboard and expect standard keyboard accelerators to work. Pressing F10, or pressing and releasing Alt, will set focus to the Page menu, as if it was the first item in a menu bar. Pressing enter, space, up arrow, or down arrow will open the focused menu. Once a menu is opened, pressing left and right arrows will switch between the two menus. Pressing escape will return focus to the title of the previously open menu. A new UI test attempts to select something from the menus using only the keyboard. It works on Linux (with toolkit_views) and on Windows. BUG=none TEST=New keyboard accessibility interactive ui test. Review URL: http://codereview.chromium.org/660323 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame/browser_view.cc')
-rw-r--r--chrome/browser/views/frame/browser_view.cc34
1 files changed, 24 insertions, 10 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 66bf142..93ab8f4 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -638,10 +638,10 @@ void BrowserView::TraverseNextAccessibleToolbar(bool forward) {
// TODO(mohamed) This needs to be smart, that applies to all toolbars.
// Currently it just traverses between bookmarks and toolbar.
if (!forward && toolbar_->IsVisible() && toolbar_->IsEnabled()) {
- toolbar_->InitiateTraversal(last_focused_view_storage_id_);
+ toolbar_->RequestFocus();
} else if (forward && bookmark_bar_view_->IsVisible() &&
bookmark_bar_view_->IsEnabled()) {
- bookmark_bar_view_->InitiateTraversal(last_focused_view_storage_id_);
+ bookmark_bar_view_->RequestFocus();
}
}
@@ -850,17 +850,31 @@ void BrowserView::UpdateToolbar(TabContents* contents,
}
void BrowserView::FocusToolbar() {
- // Remove existing views in the storage, traversal should be restarted.
+ // Start the traversal within the main toolbar, passing it the storage id
+ // of the view where focus should be returned if the user exits the toolbar.
+ SaveFocusedView();
+ toolbar_->InitiateTraversal(last_focused_view_storage_id_);
+}
+
+void BrowserView::FocusPageAndAppMenus() {
+ // Chrome doesn't have a traditional menu bar, but it has menu buttons in
+ // the main toolbar that play the same role. If the user presses a key
+ // that would typically focus the menu bar, tell the toolbar to focus
+ // the first menu button. Pass it the storage id of the view where
+ // focus should be returned if the user presses escape.
+ //
+ // Not used on the Mac, which has a normal menu bar.
+ SaveFocusedView();
+ toolbar_->EnterMenuBarEmulationMode(last_focused_view_storage_id_, NULL);
+}
+
+void BrowserView::SaveFocusedView() {
views::ViewStorage* view_storage = views::ViewStorage::GetSharedInstance();
if (view_storage->RetrieveView(last_focused_view_storage_id_))
view_storage->RemoveView(last_focused_view_storage_id_);
-
- // Store the last focused view into the storage, to handle existing traversal.
- view_storage->StoreView(last_focused_view_storage_id_,
- GetRootView()->GetFocusedView());
-
- // Start the traversal within the main toolbar.
- toolbar_->InitiateTraversal(last_focused_view_storage_id_);
+ views::View* focused_view = GetRootView()->GetFocusedView();
+ if (focused_view)
+ view_storage->StoreView(last_focused_view_storage_id_, focused_view);
}
void BrowserView::DestroyBrowser() {