| 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 #include <utility> | 10 #include <utility> |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 for (size_t i = 0; i < kReservedActionsLength; ++i) | 914 for (size_t i = 0; i < kReservedActionsLength; ++i) |
| 915 reserved_actions_.insert(kReservedActions[i]); | 915 reserved_actions_.insert(kReservedActions[i]); |
| 916 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) | 916 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) |
| 917 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); | 917 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); |
| 918 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) | 918 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) |
| 919 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); | 919 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); |
| 920 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) | 920 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) |
| 921 actions_needing_window_.insert(kActionsNeedingWindow[i]); | 921 actions_needing_window_.insert(kActionsNeedingWindow[i]); |
| 922 for (size_t i = 0; i < kActionsKeepingMenuOpenLength; ++i) | 922 for (size_t i = 0; i < kActionsKeepingMenuOpenLength; ++i) |
| 923 actions_keeping_menu_open_.insert(kActionsKeepingMenuOpen[i]); | 923 actions_keeping_menu_open_.insert(kActionsKeepingMenuOpen[i]); |
| 924 for (size_t i = 0; i < kActionsAllowedInPinnedModeLength; ++i) |
| 925 actions_allowed_in_pinned_mode_.insert(kActionsAllowedInPinnedMode[i]); |
| 924 | 926 |
| 925 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); | 927 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
| 926 | 928 |
| 927 RegisterDeprecatedAccelerators(); | 929 RegisterDeprecatedAccelerators(); |
| 928 | 930 |
| 929 if (debug::DebugAcceleratorsEnabled()) { | 931 if (debug::DebugAcceleratorsEnabled()) { |
| 930 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); | 932 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); |
| 931 // All debug accelerators are reserved. | 933 // All debug accelerators are reserved. |
| 932 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 934 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
| 933 reserved_actions_.insert(kDebugAcceleratorData[i].action); | 935 reserved_actions_.insert(kDebugAcceleratorData[i].action); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 } | 1394 } |
| 1393 | 1395 |
| 1394 bool AcceleratorController::ShouldActionConsumeKeyEvent( | 1396 bool AcceleratorController::ShouldActionConsumeKeyEvent( |
| 1395 AcceleratorAction action) { | 1397 AcceleratorAction action) { |
| 1396 // Adding new exceptions is *STRONGLY* discouraged. | 1398 // Adding new exceptions is *STRONGLY* discouraged. |
| 1397 return true; | 1399 return true; |
| 1398 } | 1400 } |
| 1399 | 1401 |
| 1400 AcceleratorController::AcceleratorProcessingRestriction | 1402 AcceleratorController::AcceleratorProcessingRestriction |
| 1401 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 1403 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
| 1404 if (WmShell::Get()->IsPinned() && |
| 1405 actions_allowed_in_pinned_mode_.find(action) == |
| 1406 actions_allowed_in_pinned_mode_.end() && |
| 1407 actions_allowed_in_app_mode_.find(action) == |
| 1408 actions_allowed_in_app_mode_.end()) { |
| 1409 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1410 } |
| 1402 ash::Shell* shell = ash::Shell::GetInstance(); | 1411 ash::Shell* shell = ash::Shell::GetInstance(); |
| 1403 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && | 1412 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && |
| 1404 actions_allowed_at_login_screen_.find(action) == | 1413 actions_allowed_at_login_screen_.find(action) == |
| 1405 actions_allowed_at_login_screen_.end()) { | 1414 actions_allowed_at_login_screen_.end()) { |
| 1406 return RESTRICTION_PREVENT_PROCESSING; | 1415 return RESTRICTION_PREVENT_PROCESSING; |
| 1407 } | 1416 } |
| 1408 if (shell->session_state_delegate()->IsScreenLocked() && | 1417 if (shell->session_state_delegate()->IsScreenLocked() && |
| 1409 actions_allowed_at_lock_screen_.find(action) == | 1418 actions_allowed_at_lock_screen_.find(action) == |
| 1410 actions_allowed_at_lock_screen_.end()) { | 1419 actions_allowed_at_lock_screen_.end()) { |
| 1411 return RESTRICTION_PREVENT_PROCESSING; | 1420 return RESTRICTION_PREVENT_PROCESSING; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1434 } | 1443 } |
| 1435 | 1444 |
| 1436 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1445 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
| 1437 std::unique_ptr<KeyboardBrightnessControlDelegate> | 1446 std::unique_ptr<KeyboardBrightnessControlDelegate> |
| 1438 keyboard_brightness_control_delegate) { | 1447 keyboard_brightness_control_delegate) { |
| 1439 keyboard_brightness_control_delegate_ = | 1448 keyboard_brightness_control_delegate_ = |
| 1440 std::move(keyboard_brightness_control_delegate); | 1449 std::move(keyboard_brightness_control_delegate); |
| 1441 } | 1450 } |
| 1442 | 1451 |
| 1443 } // namespace ash | 1452 } // namespace ash |
| OLD | NEW |