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

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

Issue 1138523006: Enable keyboard accelerators while a menu is open (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 5 years, 3 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 (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
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 return actions_keeping_menu_open_.count(action) == 0;
731 }
732
723 //////////////////////////////////////////////////////////////////////////////// 733 ////////////////////////////////////////////////////////////////////////////////
724 // AcceleratorController, ui::AcceleratorTarget implementation: 734 // AcceleratorController, ui::AcceleratorTarget implementation:
725 735
726 bool AcceleratorController::AcceleratorPressed( 736 bool AcceleratorController::AcceleratorPressed(
727 const ui::Accelerator& accelerator) { 737 const ui::Accelerator& accelerator) {
728 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it = 738 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it =
729 accelerators_.find(accelerator); 739 accelerators_.find(accelerator);
730 DCHECK(it != accelerators_.end()); 740 DCHECK(it != accelerators_.end());
731 AcceleratorAction action = it->second; 741 AcceleratorAction action = it->second;
732 if (CanPerformAction(action, accelerator)) { 742 if (CanPerformAction(action, accelerator)) {
(...skipping 24 matching lines...) Expand all
757 for (size_t i = 0; i < kPreferredActionsLength; ++i) 767 for (size_t i = 0; i < kPreferredActionsLength; ++i)
758 preferred_actions_.insert(kPreferredActions[i]); 768 preferred_actions_.insert(kPreferredActions[i]);
759 for (size_t i = 0; i < kReservedActionsLength; ++i) 769 for (size_t i = 0; i < kReservedActionsLength; ++i)
760 reserved_actions_.insert(kReservedActions[i]); 770 reserved_actions_.insert(kReservedActions[i]);
761 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) 771 for (size_t i = 0; i < kNonrepeatableActionsLength; ++i)
762 nonrepeatable_actions_.insert(kNonrepeatableActions[i]); 772 nonrepeatable_actions_.insert(kNonrepeatableActions[i]);
763 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) 773 for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i)
764 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); 774 actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]);
765 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) 775 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i)
766 actions_needing_window_.insert(kActionsNeedingWindow[i]); 776 actions_needing_window_.insert(kActionsNeedingWindow[i]);
777 for (size_t i = 0; i < kActionsKeepingMenuOpenLength; ++i)
778 actions_keeping_menu_open_.insert(kActionsKeepingMenuOpen[i]);
767 779
768 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); 780 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength);
769 781
770 if (debug::DebugAcceleratorsEnabled()) { 782 if (debug::DebugAcceleratorsEnabled()) {
771 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); 783 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength);
772 // All debug accelerators are reserved. 784 // All debug accelerators are reserved.
773 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) 785 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
774 reserved_actions_.insert(kDebugAcceleratorData[i].action); 786 reserved_actions_.insert(kDebugAcceleratorData[i].action);
775 } 787 }
776 788
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 } 1268 }
1257 1269
1258 void AcceleratorController::SetKeyboardBrightnessControlDelegate( 1270 void AcceleratorController::SetKeyboardBrightnessControlDelegate(
1259 scoped_ptr<KeyboardBrightnessControlDelegate> 1271 scoped_ptr<KeyboardBrightnessControlDelegate>
1260 keyboard_brightness_control_delegate) { 1272 keyboard_brightness_control_delegate) {
1261 keyboard_brightness_control_delegate_ = 1273 keyboard_brightness_control_delegate_ =
1262 keyboard_brightness_control_delegate.Pass(); 1274 keyboard_brightness_control_delegate.Pass();
1263 } 1275 }
1264 1276
1265 } // namespace ash 1277 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698