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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 } | 552 } |
| 553 | 553 |
| 554 AcceleratorController::~AcceleratorController() {} | 554 AcceleratorController::~AcceleratorController() {} |
| 555 | 555 |
| 556 void AcceleratorController::Register(const ui::Accelerator& accelerator, | 556 void AcceleratorController::Register(const ui::Accelerator& accelerator, |
| 557 ui::AcceleratorTarget* target) { | 557 ui::AcceleratorTarget* target) { |
| 558 accelerator_manager_->Register( | 558 accelerator_manager_->Register( |
| 559 accelerator, ui::AcceleratorManager::kNormalPriority, target); | 559 accelerator, ui::AcceleratorManager::kNormalPriority, target); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void AcceleratorController::Registers( | |
| 563 std::vector<ui::Accelerator>& ui_accelerators) { | |
| 564 accelerator_manager_->Registers(ui_accelerators); | |
| 565 } | |
| 566 | |
| 562 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, | 567 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, |
| 563 ui::AcceleratorTarget* target) { | 568 ui::AcceleratorTarget* target) { |
| 564 accelerator_manager_->Unregister(accelerator, target); | 569 accelerator_manager_->Unregister(accelerator, target); |
| 565 } | 570 } |
| 566 | 571 |
| 567 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { | 572 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { |
| 568 accelerator_manager_->UnregisterAll(target); | 573 accelerator_manager_->UnregisterAll(target); |
| 569 } | 574 } |
| 570 | 575 |
| 571 bool AcceleratorController::Process(const ui::Accelerator& accelerator) { | 576 bool AcceleratorController::Process(const ui::Accelerator& accelerator) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 kDeveloperAcceleratorDataLength); | 748 kDeveloperAcceleratorDataLength); |
| 744 // Developer accelerators are also reserved. | 749 // Developer accelerators are also reserved. |
| 745 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) | 750 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 746 reserved_actions_.insert(kDeveloperAcceleratorData[i].action); | 751 reserved_actions_.insert(kDeveloperAcceleratorData[i].action); |
| 747 } | 752 } |
| 748 } | 753 } |
| 749 | 754 |
| 750 void AcceleratorController::RegisterAccelerators( | 755 void AcceleratorController::RegisterAccelerators( |
| 751 const AcceleratorData accelerators[], | 756 const AcceleratorData accelerators[], |
| 752 size_t accelerators_length) { | 757 size_t accelerators_length) { |
| 758 std::vector<ui::Accelerator> ui_accelerators; | |
| 753 for (size_t i = 0; i < accelerators_length; ++i) { | 759 for (size_t i = 0; i < accelerators_length; ++i) { |
| 754 ui::Accelerator accelerator = | 760 ui::Accelerator accelerator = |
| 755 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, | 761 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, |
| 756 accelerators[i].trigger_on_press); | 762 accelerators[i].trigger_on_press); |
| 757 Register(accelerator, this); | 763 Register(accelerator, this); |
|
mfomitchev
2016/12/20 03:10:26
I am not sure what are you trying to do here. You
thanhph
2016/12/20 20:46:14
Thanks. I go with the approach "pass an array of a
| |
| 764 ui_accelerators.push_back(accelerator); | |
| 758 accelerators_.insert(std::make_pair(accelerator, accelerators[i].action)); | 765 accelerators_.insert(std::make_pair(accelerator, accelerators[i].action)); |
| 759 } | 766 } |
| 767 Registers(ui_accelerators); | |
| 760 } | 768 } |
| 761 | 769 |
| 762 void AcceleratorController::RegisterDeprecatedAccelerators() { | 770 void AcceleratorController::RegisterDeprecatedAccelerators() { |
| 763 #if defined(OS_CHROMEOS) | 771 #if defined(OS_CHROMEOS) |
| 764 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { | 772 for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { |
| 765 const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; | 773 const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; |
| 766 actions_with_deprecations_[data->action] = data; | 774 actions_with_deprecations_[data->action] = data; |
| 767 } | 775 } |
| 768 | 776 |
| 769 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { | 777 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1176 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
| 1169 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1177 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 1170 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1178 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 1171 A11Y_ALERT_WINDOW_NEEDED); | 1179 A11Y_ALERT_WINDOW_NEEDED); |
| 1172 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1180 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1173 } | 1181 } |
| 1174 return RESTRICTION_NONE; | 1182 return RESTRICTION_NONE; |
| 1175 } | 1183 } |
| 1176 | 1184 |
| 1177 } // namespace ash | 1185 } // namespace ash |
| OLD | NEW |