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

Unified Diff: ash/accelerators/accelerator_delegate.cc

Issue 2147013003: Mark POWER key as system key so that it won't be passed to regular apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 5 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/accelerator_delegate.h ('k') | ui/wm/core/accelerator_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_delegate.cc
diff --git a/ash/accelerators/accelerator_delegate.cc b/ash/accelerators/accelerator_delegate.cc
index e7a38e6f99b9881719f6d552fd98ffa246747060..bdf16eaf009cc5e8db936801714c6f95d9634d29 100644
--- a/ash/accelerators/accelerator_delegate.cc
+++ b/ash/accelerators/accelerator_delegate.cc
@@ -14,17 +14,43 @@
namespace ash {
+namespace {
+
+// Returns true if |key_code| is a key usually handled directly by the shell.
+bool IsSystemKey(ui::KeyboardCode key_code) {
+#if defined(OS_CHROMEOS)
+ switch (key_code) {
+ case ui::VKEY_MEDIA_LAUNCH_APP2: // Fullscreen button.
+ case ui::VKEY_MEDIA_LAUNCH_APP1: // Overview button.
+ case ui::VKEY_BRIGHTNESS_DOWN:
+ case ui::VKEY_BRIGHTNESS_UP:
+ case ui::VKEY_KBD_BRIGHTNESS_DOWN:
+ case ui::VKEY_KBD_BRIGHTNESS_UP:
+ case ui::VKEY_VOLUME_MUTE:
+ case ui::VKEY_VOLUME_DOWN:
+ case ui::VKEY_VOLUME_UP:
+ case ui::VKEY_POWER:
+ return true;
+ default:
+ return false;
+ }
+#endif // defined(OS_CHROMEOS)
+ return false;
+}
+
+} // namespace
+
AcceleratorDelegate::AcceleratorDelegate() {}
AcceleratorDelegate::~AcceleratorDelegate() {}
-bool AcceleratorDelegate::ProcessAccelerator(const ui::KeyEvent& key_event,
- const ui::Accelerator& accelerator,
- KeyType key_type) {
+bool AcceleratorDelegate::ProcessAccelerator(
+ const ui::KeyEvent& key_event,
+ const ui::Accelerator& accelerator) {
// Special hardware keys like brightness and volume are handled in
// special way. However, some windows can override this behavior
// (e.g. Chrome v1 apps by default and Chrome v2 apps with
// permission) by setting a window property.
- if (key_type == KEY_TYPE_SYSTEM && !CanConsumeSystemKeys(key_event)) {
+ if (IsSystemKey(key_event.key_code()) && !CanConsumeSystemKeys(key_event)) {
// System keys are always consumed regardless of whether they trigger an
// accelerator to prevent windows from seeing unexpected key up events.
Shell::GetInstance()->accelerator_controller()->Process(accelerator);
« no previous file with comments | « ash/accelerators/accelerator_delegate.h ('k') | ui/wm/core/accelerator_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698