OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 kActionsAllowedAtLoginOrLockScreen[i]); | 330 kActionsAllowedAtLoginOrLockScreen[i]); |
331 } | 331 } |
332 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) | 332 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) |
333 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); | 333 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); |
334 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) | 334 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) |
335 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); | 335 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); |
336 for (size_t i = 0; i < kReservedActionsLength; ++i) | 336 for (size_t i = 0; i < kReservedActionsLength; ++i) |
337 reserved_actions_.insert(kReservedActions[i]); | 337 reserved_actions_.insert(kReservedActions[i]); |
338 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) | 338 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) |
339 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); | 339 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); |
| 340 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) |
| 341 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); |
340 | 342 |
341 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); | 343 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
342 | 344 |
343 if (DebugShortcutsEnabled()) | 345 if (DebugShortcutsEnabled()) |
344 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); | 346 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); |
345 | 347 |
346 #if defined(OS_CHROMEOS) | 348 #if defined(OS_CHROMEOS) |
347 keyboard_brightness_control_delegate_.reset( | 349 keyboard_brightness_control_delegate_.reset( |
348 new KeyboardBrightnessController()); | 350 new KeyboardBrightnessController()); |
349 #endif | 351 #endif |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 412 } |
411 if (shell->IsSystemModalWindowOpen() && | 413 if (shell->IsSystemModalWindowOpen() && |
412 actions_allowed_at_modal_window_.find(action) == | 414 actions_allowed_at_modal_window_.find(action) == |
413 actions_allowed_at_modal_window_.end()) { | 415 actions_allowed_at_modal_window_.end()) { |
414 // Note: we return true. This indicates the shortcut is handled | 416 // Note: we return true. This indicates the shortcut is handled |
415 // and will not be passed to the modal window. This is important | 417 // and will not be passed to the modal window. This is important |
416 // for things like Alt+Tab that would cause an undesired effect | 418 // for things like Alt+Tab that would cause an undesired effect |
417 // in the modal window by cycling through its window elements. | 419 // in the modal window by cycling through its window elements. |
418 return true; | 420 return true; |
419 } | 421 } |
| 422 if (shell->delegate()->IsRunningInForcedAppMode() && |
| 423 actions_allowed_in_app_mode_.find(action) == |
| 424 actions_allowed_in_app_mode_.end()) { |
| 425 return false; |
| 426 } |
| 427 |
420 const ui::KeyboardCode key_code = accelerator.key_code(); | 428 const ui::KeyboardCode key_code = accelerator.key_code(); |
421 // PerformAction() is performed from gesture controllers and passes | 429 // PerformAction() is performed from gesture controllers and passes |
422 // empty Accelerator() instance as the second argument. Such events | 430 // empty Accelerator() instance as the second argument. Such events |
423 // should never be suspended. | 431 // should never be suspended. |
424 const bool gesture_event = key_code == ui::VKEY_UNKNOWN; | 432 const bool gesture_event = key_code == ui::VKEY_UNKNOWN; |
425 | 433 |
426 // Ignore accelerators invoked as repeated (while holding a key for a long | 434 // Ignore accelerators invoked as repeated (while holding a key for a long |
427 // time, if their handling is nonrepeatable. | 435 // time, if their handling is nonrepeatable. |
428 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && | 436 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && |
429 context_.repeated() && !gesture_event) { | 437 context_.repeated() && !gesture_event) { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 keyboard_brightness_control_delegate) { | 866 keyboard_brightness_control_delegate) { |
859 keyboard_brightness_control_delegate_ = | 867 keyboard_brightness_control_delegate_ = |
860 keyboard_brightness_control_delegate.Pass(); | 868 keyboard_brightness_control_delegate.Pass(); |
861 } | 869 } |
862 | 870 |
863 bool AcceleratorController::CanHandleAccelerators() const { | 871 bool AcceleratorController::CanHandleAccelerators() const { |
864 return true; | 872 return true; |
865 } | 873 } |
866 | 874 |
867 } // namespace ash | 875 } // namespace ash |
OLD | NEW |