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

Side by Side Diff: ash/accelerators/accelerator_delegate.cc

Issue 2140843002: Allow arc app to lock screen orientation in TouchView/Tablet mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Mark POWER key as system key so that it won't be passed to regular apps. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/accelerators/accelerator_delegate.h" 5 #include "ash/accelerators/accelerator_delegate.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_state_aura.h" 10 #include "ash/wm/window_state_aura.h"
11 #include "ui/base/accelerators/accelerator.h" 11 #include "ui/base/accelerators/accelerator.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/wm/core/window_util.h" 13 #include "ui/wm/core/window_util.h"
14 14
15 namespace ash { 15 namespace ash {
16 namespace {} // namespace 16 namespace {} // namespace
17 17
18 namespace {
19
20 // Returns true if |key_code| is a key usually handled directly by the shell.
21 bool IsSystemKey(ui::KeyboardCode key_code) {
22 #if defined(OS_CHROMEOS)
23 switch (key_code) {
24 case ui::VKEY_MEDIA_LAUNCH_APP2: // Fullscreen button.
25 case ui::VKEY_MEDIA_LAUNCH_APP1: // Overview button.
26 case ui::VKEY_BRIGHTNESS_DOWN:
27 case ui::VKEY_BRIGHTNESS_UP:
28 case ui::VKEY_KBD_BRIGHTNESS_DOWN:
29 case ui::VKEY_KBD_BRIGHTNESS_UP:
30 case ui::VKEY_VOLUME_MUTE:
31 case ui::VKEY_VOLUME_DOWN:
32 case ui::VKEY_VOLUME_UP:
33 case ui::VKEY_POWER:
34 return true;
35 default:
36 return false;
37 }
38 #endif // defined(OS_CHROMEOS)
39 return false;
40 }
41
42 } // namespace
43
18 AcceleratorDelegate::AcceleratorDelegate() {} 44 AcceleratorDelegate::AcceleratorDelegate() {}
19 AcceleratorDelegate::~AcceleratorDelegate() {} 45 AcceleratorDelegate::~AcceleratorDelegate() {}
20 46
21 bool AcceleratorDelegate::ProcessAccelerator(const ui::KeyEvent& key_event, 47 bool AcceleratorDelegate::ProcessAccelerator(
22 const ui::Accelerator& accelerator, 48 const ui::KeyEvent& key_event,
23 KeyType key_type) { 49 const ui::Accelerator& accelerator) {
24 // Special hardware keys like brightness and volume are handled in 50 // Special hardware keys like brightness and volume are handled in
25 // special way. However, some windows can override this behavior 51 // special way. However, some windows can override this behavior
26 // (e.g. Chrome v1 apps by default and Chrome v2 apps with 52 // (e.g. Chrome v1 apps by default and Chrome v2 apps with
27 // permission) by setting a window property. 53 // permission) by setting a window property.
28 if (key_type == KEY_TYPE_SYSTEM && !CanConsumeSystemKeys(key_event)) { 54 if (IsSystemKey(key_event.key_code()) && !CanConsumeSystemKeys(key_event)) {
29 // System keys are always consumed regardless of whether they trigger an 55 // System keys are always consumed regardless of whether they trigger an
30 // accelerator to prevent windows from seeing unexpected key up events. 56 // accelerator to prevent windows from seeing unexpected key up events.
31 Shell::GetInstance()->accelerator_controller()->Process(accelerator); 57 Shell::GetInstance()->accelerator_controller()->Process(accelerator);
32 return true; 58 return true;
33 } 59 }
34 if (!ShouldProcessAcceleratorNow(key_event, accelerator)) 60 if (!ShouldProcessAcceleratorNow(key_event, accelerator))
35 return false; 61 return false;
36 return Shell::GetInstance()->accelerator_controller()->Process(accelerator); 62 return Shell::GetInstance()->accelerator_controller()->Process(accelerator);
37 } 63 }
38 64
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 107
82 // Handle preferred accelerators (such as ALT-TAB) before sending 108 // Handle preferred accelerators (such as ALT-TAB) before sending
83 // to the target. 109 // to the target.
84 if (shell->accelerator_controller()->IsPreferred(accelerator)) 110 if (shell->accelerator_controller()->IsPreferred(accelerator))
85 return true; 111 return true;
86 112
87 return shell->GetAppListTargetVisibility(); 113 return shell->GetAppListTargetVisibility();
88 } 114 }
89 115
90 } // namespace ash 116 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_delegate.h ('k') | chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698