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

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

Issue 2130603002: ash: Explicitly enumerate repeatable accelerators. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 kActionsAllowedAtLoginOrLockScreen[i]); 897 kActionsAllowedAtLoginOrLockScreen[i]);
898 } 898 }
899 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i) 899 for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i)
900 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]); 900 actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]);
901 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i) 901 for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i)
902 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); 902 actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]);
903 for (size_t i = 0; i < kPreferredActionsLength; ++i) 903 for (size_t i = 0; i < kPreferredActionsLength; ++i)
904 preferred_actions_.insert(kPreferredActions[i]); 904 preferred_actions_.insert(kPreferredActions[i]);
905 for (size_t i = 0; i < kReservedActionsLength; ++i) 905 for (size_t i = 0; i < kReservedActionsLength; ++i)
906 reserved_actions_.insert(kReservedActions[i]); 906 reserved_actions_.insert(kReservedActions[i]);
907 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) 907 for (size_t i = 0; i < kRepeatableActionsLength; ++i)
908 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); 908 repeatable_actions_.insert(kRepeatableActions[i]);
909 for (size_t i = 0; i < kActionsAllowedInAppModeOrPinnedModeLength; ++i) { 909 for (size_t i = 0; i < kActionsAllowedInAppModeOrPinnedModeLength; ++i) {
910 actions_allowed_in_app_mode_.insert( 910 actions_allowed_in_app_mode_.insert(
911 kActionsAllowedInAppModeOrPinnedMode[i]); 911 kActionsAllowedInAppModeOrPinnedMode[i]);
912 actions_allowed_in_pinned_mode_.insert( 912 actions_allowed_in_pinned_mode_.insert(
913 kActionsAllowedInAppModeOrPinnedMode[i]); 913 kActionsAllowedInAppModeOrPinnedMode[i]);
914 } 914 }
915 for (size_t i = 0; i < kActionsAllowedInPinnedModeLength; ++i) 915 for (size_t i = 0; i < kActionsAllowedInPinnedModeLength; ++i)
916 actions_allowed_in_pinned_mode_.insert(kActionsAllowedInPinnedMode[i]); 916 actions_allowed_in_pinned_mode_.insert(kActionsAllowedInPinnedMode[i]);
917 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) 917 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i)
918 actions_needing_window_.insert(kActionsNeedingWindow[i]); 918 actions_needing_window_.insert(kActionsNeedingWindow[i]);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 Register(deprecated_accelerator, this); 964 Register(deprecated_accelerator, this);
965 accelerators_[deprecated_accelerator] = accelerator_data.action; 965 accelerators_[deprecated_accelerator] = accelerator_data.action;
966 deprecated_accelerators_.insert(deprecated_accelerator); 966 deprecated_accelerators_.insert(deprecated_accelerator);
967 } 967 }
968 #endif // defined(OS_CHROMEOS) 968 #endif // defined(OS_CHROMEOS)
969 } 969 }
970 970
971 bool AcceleratorController::CanPerformAction( 971 bool AcceleratorController::CanPerformAction(
972 AcceleratorAction action, 972 AcceleratorAction action,
973 const ui::Accelerator& accelerator) { 973 const ui::Accelerator& accelerator) {
974 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && 974 if (accelerator.IsRepeat() && !repeatable_actions_.count(action))
975 accelerator.IsRepeat()) {
976 return false; 975 return false;
977 }
978 976
979 AcceleratorProcessingRestriction restriction = 977 AcceleratorProcessingRestriction restriction =
980 GetAcceleratorProcessingRestriction(action); 978 GetAcceleratorProcessingRestriction(action);
981 if (restriction != RESTRICTION_NONE) 979 if (restriction != RESTRICTION_NONE)
982 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 980 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
983 981
984 const ui::Accelerator& previous_accelerator = 982 const ui::Accelerator& previous_accelerator =
985 accelerator_history_->previous_accelerator(); 983 accelerator_history_->previous_accelerator();
986 984
987 // True should be returned if running |action| does something. Otherwise, 985 // True should be returned if running |action| does something. Otherwise,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1438 }
1441 1439
1442 void AcceleratorController::SetKeyboardBrightnessControlDelegate( 1440 void AcceleratorController::SetKeyboardBrightnessControlDelegate(
1443 std::unique_ptr<KeyboardBrightnessControlDelegate> 1441 std::unique_ptr<KeyboardBrightnessControlDelegate>
1444 keyboard_brightness_control_delegate) { 1442 keyboard_brightness_control_delegate) {
1445 keyboard_brightness_control_delegate_ = 1443 keyboard_brightness_control_delegate_ =
1446 std::move(keyboard_brightness_control_delegate); 1444 std::move(keyboard_brightness_control_delegate);
1447 } 1445 }
1448 1446
1449 } // namespace ash 1447 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698