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

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

Issue 2769213005: Adds kWillProcessAccelerator_KeyEventProperty (Closed)
Patch Set: cleanup Created 3 years, 9 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/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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 673
674 void AcceleratorController::Unregister(const ui::Accelerator& accelerator, 674 void AcceleratorController::Unregister(const ui::Accelerator& accelerator,
675 ui::AcceleratorTarget* target) { 675 ui::AcceleratorTarget* target) {
676 accelerator_manager_->Unregister(accelerator, target); 676 accelerator_manager_->Unregister(accelerator, target);
677 } 677 }
678 678
679 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) { 679 void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) {
680 accelerator_manager_->UnregisterAll(target); 680 accelerator_manager_->UnregisterAll(target);
681 } 681 }
682 682
683 bool AcceleratorController::IsActionForAcceleratorEnabled(
684 const ui::Accelerator& accelerator) const {
685 std::map<ui::Accelerator, AcceleratorAction>::const_iterator it =
686 accelerators_.find(accelerator);
687 return it != accelerators_.end() && CanPerformAction(it->second, accelerator);
688 }
689
683 bool AcceleratorController::Process(const ui::Accelerator& accelerator) { 690 bool AcceleratorController::Process(const ui::Accelerator& accelerator) {
684 return accelerator_manager_->Process(accelerator); 691 return accelerator_manager_->Process(accelerator);
685 } 692 }
686 693
687 bool AcceleratorController::IsRegistered( 694 bool AcceleratorController::IsRegistered(
688 const ui::Accelerator& accelerator) const { 695 const ui::Accelerator& accelerator) const {
689 return accelerator_manager_->IsRegistered(accelerator); 696 return accelerator_manager_->IsRegistered(accelerator);
690 } 697 }
691 698
692 bool AcceleratorController::IsPreferred( 699 bool AcceleratorController::IsPreferred(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 868
862 ui_accelerators.push_back(deprecated_accelerator); 869 ui_accelerators.push_back(deprecated_accelerator);
863 accelerators_[deprecated_accelerator] = accelerator_data.action; 870 accelerators_[deprecated_accelerator] = accelerator_data.action;
864 deprecated_accelerators_.insert(deprecated_accelerator); 871 deprecated_accelerators_.insert(deprecated_accelerator);
865 } 872 }
866 Register(ui_accelerators, this); 873 Register(ui_accelerators, this);
867 } 874 }
868 875
869 bool AcceleratorController::CanPerformAction( 876 bool AcceleratorController::CanPerformAction(
870 AcceleratorAction action, 877 AcceleratorAction action,
871 const ui::Accelerator& accelerator) { 878 const ui::Accelerator& accelerator) const {
872 if (accelerator.IsRepeat() && !repeatable_actions_.count(action)) 879 if (accelerator.IsRepeat() && !repeatable_actions_.count(action))
873 return false; 880 return false;
874 881
875 AcceleratorProcessingRestriction restriction = 882 AcceleratorProcessingRestriction restriction =
876 GetAcceleratorProcessingRestriction(action); 883 GetAcceleratorProcessingRestriction(action);
877 if (restriction != RESTRICTION_NONE) 884 if (restriction != RESTRICTION_NONE)
878 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 885 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
879 886
880 const ui::Accelerator& previous_accelerator = 887 const ui::Accelerator& previous_accelerator =
881 accelerator_history_->previous_accelerator(); 888 accelerator_history_->previous_accelerator();
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1218 }
1212 } 1219 }
1213 1220
1214 bool AcceleratorController::ShouldActionConsumeKeyEvent( 1221 bool AcceleratorController::ShouldActionConsumeKeyEvent(
1215 AcceleratorAction action) { 1222 AcceleratorAction action) {
1216 // Adding new exceptions is *STRONGLY* discouraged. 1223 // Adding new exceptions is *STRONGLY* discouraged.
1217 return true; 1224 return true;
1218 } 1225 }
1219 1226
1220 AcceleratorController::AcceleratorProcessingRestriction 1227 AcceleratorController::AcceleratorProcessingRestriction
1221 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { 1228 AcceleratorController::GetAcceleratorProcessingRestriction(int action) const {
1222 WmShell* wm_shell = WmShell::Get(); 1229 WmShell* wm_shell = WmShell::Get();
1223 if (wm_shell->IsPinned() && 1230 if (wm_shell->IsPinned() &&
1224 actions_allowed_in_pinned_mode_.find(action) == 1231 actions_allowed_in_pinned_mode_.find(action) ==
1225 actions_allowed_in_pinned_mode_.end()) { 1232 actions_allowed_in_pinned_mode_.end()) {
1226 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1233 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1227 } 1234 }
1228 if (!Shell::Get()->session_controller()->IsActiveUserSessionStarted() && 1235 if (!Shell::Get()->session_controller()->IsActiveUserSessionStarted() &&
1229 actions_allowed_at_login_screen_.find(action) == 1236 actions_allowed_at_login_screen_.find(action) ==
1230 actions_allowed_at_login_screen_.end()) { 1237 actions_allowed_at_login_screen_.end()) {
1231 return RESTRICTION_PREVENT_PROCESSING; 1238 return RESTRICTION_PREVENT_PROCESSING;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 data->uma_histogram_name, data->notification_message_id, 1297 data->uma_histogram_name, data->notification_message_id,
1291 data->old_shortcut_id, data->new_shortcut_id); 1298 data->old_shortcut_id, data->new_shortcut_id);
1292 1299
1293 if (!data->deprecated_enabled) 1300 if (!data->deprecated_enabled)
1294 return AcceleratorProcessingStatus::STOP; 1301 return AcceleratorProcessingStatus::STOP;
1295 1302
1296 return AcceleratorProcessingStatus::PROCEED; 1303 return AcceleratorProcessingStatus::PROCEED;
1297 } 1304 }
1298 1305
1299 } // namespace ash 1306 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698