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

Unified Diff: ash/accelerators/nested_accelerator_delegate.cc

Issue 312483002: More accelerator code leanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « ash/accelerators/nested_accelerator_delegate.h ('k') | ui/wm/core/accelerator_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/nested_accelerator_delegate.cc
diff --git a/ash/accelerators/nested_accelerator_delegate.cc b/ash/accelerators/nested_accelerator_delegate.cc
index f83e1ebe083947ae43a93d6b6a7cef353527f3b2..9d30f43f2b9d32b17397e15761250dace812bb54 100644
--- a/ash/accelerators/nested_accelerator_delegate.cc
+++ b/ash/accelerators/nested_accelerator_delegate.cc
@@ -16,14 +16,14 @@
namespace ash {
namespace {
-bool IsPossibleAcceleratorNotForMenu(const ui::KeyEvent& key_event) {
+bool IsPossibleAcceleratorNotForMenu(const ui::Accelerator& accelerator) {
// For shortcuts generated by Ctrl or Alt plus a letter, number or
// the tab key, we want to exit the context menu first and then
// repost the event. That allows for the shortcut execution after
// the context menu has exited.
- if (key_event.type() == ui::ET_KEY_PRESSED &&
- (key_event.flags() & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))) {
- const ui::KeyboardCode key_code = key_event.key_code();
+ if (accelerator.type() == ui::ET_KEY_PRESSED &&
+ (accelerator.modifiers() & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))) {
+ const ui::KeyboardCode key_code = accelerator.key_code();
if ((key_code >= ui::VKEY_A && key_code <= ui::VKEY_Z) ||
(key_code >= ui::VKEY_0 && key_code <= ui::VKEY_9) ||
(key_code == ui::VKEY_TAB)) {
@@ -33,17 +33,8 @@ bool IsPossibleAcceleratorNotForMenu(const ui::KeyEvent& key_event) {
return false;
}
-} // namespace
-
-NestedAcceleratorDelegate::NestedAcceleratorDelegate() {
-}
-
-NestedAcceleratorDelegate::~NestedAcceleratorDelegate() {
-}
-
-bool NestedAcceleratorDelegate::ShouldProcessEventNow(
- const ui::KeyEvent& key_event) {
- if (!IsPossibleAcceleratorNotForMenu(key_event))
+bool ShouldProcessAcceleratorNow(const ui::Accelerator& accelerator) {
+ if (!IsPossibleAcceleratorNotForMenu(accelerator))
return true;
if (views::MenuController* menu_controller =
@@ -54,22 +45,30 @@ bool NestedAcceleratorDelegate::ShouldProcessEventNow(
return true;
}
-bool NestedAcceleratorDelegate::ProcessEvent(const ui::KeyEvent& key_event) {
+} // namespace
+
+NestedAcceleratorDelegate::NestedAcceleratorDelegate() {
+}
+
+NestedAcceleratorDelegate::~NestedAcceleratorDelegate() {
+}
+
+NestedAcceleratorDelegate::Result NestedAcceleratorDelegate::ProcessAccelerator(
+ const ui::Accelerator& accelerator) {
+ if (!ShouldProcessAcceleratorNow(accelerator))
+ return RESULT_PROCESS_LATER;
+
ash::AcceleratorController* accelerator_controller =
ash::Shell::GetInstance()->accelerator_controller();
if (!accelerator_controller)
- return false;
- const int kModifierMask =
- (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN);
- ui::Accelerator accelerator(key_event.key_code(),
- key_event.flags() & kModifierMask);
- if (key_event.type() == ui::ET_KEY_RELEASED)
- accelerator.set_type(ui::ET_KEY_RELEASED);
+ return RESULT_NOT_PROCESSED;
+
// Fill out context object so AcceleratorController will know what
// was the previous accelerator or if the current accelerator is repeated.
Shell::GetInstance()->accelerator_controller()->context()->UpdateContext(
accelerator);
- return accelerator_controller->Process(accelerator);
+ return accelerator_controller->Process(accelerator) ? RESULT_PROCESSED
+ : RESULT_NOT_PROCESSED;
}
} // namespace ash
« no previous file with comments | « ash/accelerators/nested_accelerator_delegate.h ('k') | ui/wm/core/accelerator_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698