Chromium Code Reviews| 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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_commands.h" | 9 #include "ash/common/accelerators/accelerator_commands.h" |
| 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 AcceleratorControllerDelegate* delegate, | 542 AcceleratorControllerDelegate* delegate, |
| 543 ui::AcceleratorManagerDelegate* manager_delegate) | 543 ui::AcceleratorManagerDelegate* manager_delegate) |
| 544 : delegate_(delegate), | 544 : delegate_(delegate), |
| 545 accelerator_manager_(new ui::AcceleratorManager(manager_delegate)), | 545 accelerator_manager_(new ui::AcceleratorManager(manager_delegate)), |
| 546 accelerator_history_(new ui::AcceleratorHistory) { | 546 accelerator_history_(new ui::AcceleratorHistory) { |
| 547 Init(); | 547 Init(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 AcceleratorController::~AcceleratorController() {} | 550 AcceleratorController::~AcceleratorController() {} |
| 551 | 551 |
| 552 void AcceleratorController::Register(const ui::Accelerator& accelerator, | 552 void AcceleratorController::Register( |
| 553 ui::AcceleratorTarget* target) { | 553 const std::vector<ui::Accelerator>& accelerators, |
| 554 ui::AcceleratorTarget* target) { | |
| 554 accelerator_manager_->Register( | 555 accelerator_manager_->Register( |
| 555 accelerator, ui::AcceleratorManager::kNormalPriority, target); | 556 accelerators, ui::AcceleratorManager::kNormalPriority, target); |
| 556 } | 557 } |
| 557 | 558 |
| 558 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, | 559 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, |
| 559 ui::AcceleratorTarget* target) { | 560 ui::AcceleratorTarget* target) { |
| 560 accelerator_manager_->Unregister(accelerator, target); | 561 accelerator_manager_->Unregister(accelerator, target); |
| 561 } | 562 } |
| 562 | 563 |
| 563 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { | 564 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { |
| 564 accelerator_manager_->UnregisterAll(target); | 565 accelerator_manager_->UnregisterAll(target); |
| 565 } | 566 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 kDeveloperAcceleratorDataLength); | 740 kDeveloperAcceleratorDataLength); |
| 740 // Developer accelerators are also reserved. | 741 // Developer accelerators are also reserved. |
| 741 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) | 742 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 742 reserved_actions_.insert(kDeveloperAcceleratorData[i].action); | 743 reserved_actions_.insert(kDeveloperAcceleratorData[i].action); |
| 743 } | 744 } |
| 744 } | 745 } |
| 745 | 746 |
| 746 void AcceleratorController::RegisterAccelerators( | 747 void AcceleratorController::RegisterAccelerators( |
| 747 const AcceleratorData accelerators[], | 748 const AcceleratorData accelerators[], |
| 748 size_t accelerators_length) { | 749 size_t accelerators_length) { |
| 750 std::vector<ui::Accelerator> ui_accelerators; | |
| 749 for (size_t i = 0; i < accelerators_length; ++i) { | 751 for (size_t i = 0; i < accelerators_length; ++i) { |
| 750 ui::Accelerator accelerator = | 752 ui::Accelerator accelerator = |
| 751 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, | 753 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, |
| 752 accelerators[i].trigger_on_press); | 754 accelerators[i].trigger_on_press); |
| 753 Register(accelerator, this); | 755 ui_accelerators.push_back(accelerator); |
| 754 accelerators_.insert(std::make_pair(accelerator, accelerators[i].action)); | 756 accelerators_.insert(std::make_pair(accelerator, accelerators[i].action)); |
| 755 } | 757 } |
| 758 Register(ui_accelerators, this); | |
| 756 } | 759 } |
| 757 | 760 |
| 758 void AcceleratorController::RegisterDeprecatedAccelerators() { | 761 void AcceleratorController::RegisterDeprecatedAccelerators() { |
| 759 #if defined(OS_CHROMEOS) | 762 #if defined(OS_CHROMEOS) |
| 760 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { | 763 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { |
| 761 const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; | 764 const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; |
| 762 actions_with_deprecations_[data->action] = data; | 765 actions_with_deprecations_[data->action] = data; |
| 763 } | 766 } |
| 764 | 767 |
| 768 std::vector<ui::Accelerator> accelerators; | |
|
mfomitchev
2017/01/26 23:13:57
nit: ui_accelerators for consistency
thanhph1
2017/01/27 16:18:20
Done.
| |
| 765 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { | 769 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { |
| 766 const AcceleratorData& accelerator_data = kDeprecatedAccelerators[i]; | 770 const AcceleratorData& accelerator_data = kDeprecatedAccelerators[i]; |
| 767 const ui::Accelerator deprecated_accelerator = | 771 const ui::Accelerator deprecated_accelerator = |
| 768 CreateAccelerator(accelerator_data.keycode, accelerator_data.modifiers, | 772 CreateAccelerator(accelerator_data.keycode, accelerator_data.modifiers, |
| 769 accelerator_data.trigger_on_press); | 773 accelerator_data.trigger_on_press); |
| 770 | 774 |
| 771 Register(deprecated_accelerator, this); | 775 accelerators.push_back(deprecated_accelerator); |
| 772 accelerators_[deprecated_accelerator] = accelerator_data.action; | 776 accelerators_[deprecated_accelerator] = accelerator_data.action; |
| 773 deprecated_accelerators_.insert(deprecated_accelerator); | 777 deprecated_accelerators_.insert(deprecated_accelerator); |
| 774 } | 778 } |
| 779 Register(accelerators, this); | |
| 775 #endif // defined(OS_CHROMEOS) | 780 #endif // defined(OS_CHROMEOS) |
| 776 } | 781 } |
| 777 | 782 |
| 778 bool AcceleratorController::CanPerformAction( | 783 bool AcceleratorController::CanPerformAction( |
| 779 AcceleratorAction action, | 784 AcceleratorAction action, |
| 780 const ui::Accelerator& accelerator) { | 785 const ui::Accelerator& accelerator) { |
| 781 if (accelerator.IsRepeat() && !repeatable_actions_.count(action)) | 786 if (accelerator.IsRepeat() && !repeatable_actions_.count(action)) |
| 782 return false; | 787 return false; |
| 783 | 788 |
| 784 AcceleratorProcessingRestriction restriction = | 789 AcceleratorProcessingRestriction restriction = |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1172 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
| 1168 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1173 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 1169 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1174 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 1170 A11Y_ALERT_WINDOW_NEEDED); | 1175 A11Y_ALERT_WINDOW_NEEDED); |
| 1171 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1176 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1172 } | 1177 } |
| 1173 return RESTRICTION_NONE; | 1178 return RESTRICTION_NONE; |
| 1174 } | 1179 } |
| 1175 | 1180 |
| 1176 } // namespace ash | 1181 } // namespace ash |
| OLD | NEW |