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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 void AcceleratorController::SetImeControlDelegate( | 713 void AcceleratorController::SetImeControlDelegate( |
714 scoped_ptr<ImeControlDelegate> ime_control_delegate) { | 714 scoped_ptr<ImeControlDelegate> ime_control_delegate) { |
715 ime_control_delegate_ = ime_control_delegate.Pass(); | 715 ime_control_delegate_ = ime_control_delegate.Pass(); |
716 } | 716 } |
717 | 717 |
718 void AcceleratorController::SetScreenshotDelegate( | 718 void AcceleratorController::SetScreenshotDelegate( |
719 scoped_ptr<ScreenshotDelegate> screenshot_delegate) { | 719 scoped_ptr<ScreenshotDelegate> screenshot_delegate) { |
720 screenshot_delegate_ = screenshot_delegate.Pass(); | 720 screenshot_delegate_ = screenshot_delegate.Pass(); |
721 } | 721 } |
722 | 722 |
723 bool AcceleratorController::ShouldCloseMenuAndRepostAccelerator( | |
724 const ui::Accelerator& accelerator) const { | |
725 auto itr = accelerators_.find(accelerator); | |
726 if (itr == accelerators_.end()) | |
727 return false; // Menu shouldn't be closed for an invalid accelerator. | |
728 | |
729 AcceleratorAction action = itr->second; | |
730 if (actions_keeping_menu_open_.count(action)) | |
pkotwicz
2015/08/27 17:19:55
How about:
return actions_keeping_menu_open_.count
afakhry
2015/08/28 01:24:41
Much better! Done. Thanks! :)
| |
731 return false; | |
732 | |
733 return true; | |
734 } | |
735 | |
723 //////////////////////////////////////////////////////////////////////////////// | 736 //////////////////////////////////////////////////////////////////////////////// |
724 // AcceleratorController, ui::AcceleratorTarget implementation: | 737 // AcceleratorController, ui::AcceleratorTarget implementation: |
725 | 738 |
726 bool AcceleratorController::AcceleratorPressed( | 739 bool AcceleratorController::AcceleratorPressed( |
727 const ui::Accelerator& accelerator) { | 740 const ui::Accelerator& accelerator) { |
728 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it = | 741 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it = |
729 accelerators_.find(accelerator); | 742 accelerators_.find(accelerator); |
730 DCHECK(it != accelerators_.end()); | 743 DCHECK(it != accelerators_.end()); |
731 AcceleratorAction action = it->second; | 744 AcceleratorAction action = it->second; |
732 if (CanPerformAction(action, accelerator)) { | 745 if (CanPerformAction(action, accelerator)) { |
(...skipping 24 matching lines...) Expand all Loading... | |
757 for (size_t i = 0; i < kPreferredActionsLength; ++i) | 770 for (size_t i = 0; i < kPreferredActionsLength; ++i) |
758 preferred_actions_.insert(kPreferredActions[i]); | 771 preferred_actions_.insert(kPreferredActions[i]); |
759 for (size_t i = 0; i < kReservedActionsLength; ++i) | 772 for (size_t i = 0; i < kReservedActionsLength; ++i) |
760 reserved_actions_.insert(kReservedActions[i]); | 773 reserved_actions_.insert(kReservedActions[i]); |
761 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) | 774 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) |
762 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); | 775 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); |
763 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) | 776 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) |
764 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); | 777 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); |
765 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) | 778 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) |
766 actions_needing_window_.insert(kActionsNeedingWindow[i]); | 779 actions_needing_window_.insert(kActionsNeedingWindow[i]); |
780 for (size_t i = 0; i < kActionsKeepingMenuOpenLength; ++i) | |
781 actions_keeping_menu_open_.insert(kActionsKeepingMenuOpen[i]); | |
767 | 782 |
768 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); | 783 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
769 | 784 |
770 if (debug::DebugAcceleratorsEnabled()) { | 785 if (debug::DebugAcceleratorsEnabled()) { |
771 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); | 786 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); |
772 // All debug accelerators are reserved. | 787 // All debug accelerators are reserved. |
773 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 788 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
774 reserved_actions_.insert(kDebugAcceleratorData[i].action); | 789 reserved_actions_.insert(kDebugAcceleratorData[i].action); |
775 } | 790 } |
776 | 791 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1256 } | 1271 } |
1257 | 1272 |
1258 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1273 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
1259 scoped_ptr<KeyboardBrightnessControlDelegate> | 1274 scoped_ptr<KeyboardBrightnessControlDelegate> |
1260 keyboard_brightness_control_delegate) { | 1275 keyboard_brightness_control_delegate) { |
1261 keyboard_brightness_control_delegate_ = | 1276 keyboard_brightness_control_delegate_ = |
1262 keyboard_brightness_control_delegate.Pass(); | 1277 keyboard_brightness_control_delegate.Pass(); |
1263 } | 1278 } |
1264 | 1279 |
1265 } // namespace ash | 1280 } // namespace ash |
OLD | NEW |