Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 1138523006: Enable keyboard accelerators while a menu is open (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed OnTouchEvent() Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/chrome_views_delegate.cc
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 0fc0bbbb98df196ca4925383202f154e24ff0bdd..78eee3a82793ce038acb390f4dc765da623f8d8e 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -21,6 +21,7 @@
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/screen.h"
+#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/widget.h"
@@ -52,6 +53,7 @@
#endif
#if defined(USE_ASH)
+#include "ash/accelerators/accelerator_controller.h"
#include "ash/shell.h"
#include "ash/wm/window_state.h"
#include "chrome/browser/ui/ash/ash_init.h"
@@ -126,6 +128,14 @@ int GetAppbarAutohideEdgesOnWorkerThread(HMONITOR monitor) {
}
#endif
+#if defined(USE_ASH)
+void ProcessAcceleratorNow(const ui::Accelerator& accelerator) {
+ // TODO(afakhry): See if we need here to send the accelerator to the
+ // FocusManager of the active window in a follow-up CL.
+ ash::Shell::GetInstance()->accelerator_controller()->Process(accelerator);
+}
+#endif // defined(USE_ASH)
+
} // namespace
@@ -220,6 +230,30 @@ void ChromeViewsDelegate::NotifyAccessibilityEvent(
#endif
}
+views::ViewsDelegate::ProcessMenuAcceleratorResult
+ChromeViewsDelegate::ProcessAcceleratorWhileMenuShowing(
+ const ui::Accelerator& accelerator) {
+#if defined(USE_ASH)
+ ash::AcceleratorController* accelerator_controller =
+ ash::Shell::GetInstance()->accelerator_controller();
+
+ accelerator_controller->accelerator_history()->StoreCurrentAccelerator(
+ accelerator);
+ if (accelerator_controller->ShouldCloseMenuAndRepostAccelerator(
+ accelerator)) {
+ base::MessageLoopForUI::current()->PostTask(
+ FROM_HERE,
+ base::Bind(ProcessAcceleratorNow, accelerator));
+ return views::ViewsDelegate::ProcessMenuAcceleratorResult::CLOSE_MENU;
+ }
+
+ ProcessAcceleratorNow(accelerator);
+ return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN;
+#else
+ return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN;
+#endif // defined(USE_ASH)
+}
+
#if defined(OS_WIN)
HICON ChromeViewsDelegate::GetDefaultWindowIcon() const {
return GetAppIcon();
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698