Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index b4ebea10f8c574b402a25f7c50f13c169dbac6cc..289c4d56df089f3f6a4fee06b14fa9333e01bb47 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -856,36 +856,10 @@ bool AcceleratorController::IsReservedAccelerator( |
bool AcceleratorController::PerformAction(int action, |
const ui::Accelerator& accelerator) { |
ash::Shell* shell = ash::Shell::GetInstance(); |
- if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && |
- actions_allowed_at_login_screen_.find(action) == |
- actions_allowed_at_login_screen_.end()) { |
- return false; |
- } |
- if (shell->session_state_delegate()->IsScreenLocked() && |
- actions_allowed_at_lock_screen_.find(action) == |
- actions_allowed_at_lock_screen_.end()) { |
- return false; |
- } |
- if (shell->IsSystemModalWindowOpen() && |
- actions_allowed_at_modal_window_.find(action) == |
- actions_allowed_at_modal_window_.end()) { |
- // Note: we return true. This indicates the shortcut is handled |
- // and will not be passed to the modal window. This is important |
- // for things like Alt+Tab that would cause an undesired effect |
- // in the modal window by cycling through its window elements. |
- return true; |
- } |
- if (shell->delegate()->IsRunningInForcedAppMode() && |
- actions_allowed_in_app_mode_.find(action) == |
- actions_allowed_in_app_mode_.end()) { |
- return false; |
- } |
- if (MruWindowTracker::BuildWindowList(false).empty() && |
- actions_needing_window_.find(action) != actions_needing_window_.end()) { |
- Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( |
- A11Y_ALERT_WINDOW_NEEDED); |
- return true; |
- } |
+ AcceleratorProcessingRestriction restriction = |
+ GetAcceleratorProcessingRestriction(action); |
+ if (restriction != RESTRICTION_NONE) |
+ return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
const ui::KeyboardCode key_code = accelerator.key_code(); |
// PerformAction() is performed from gesture controllers and passes |
@@ -1142,6 +1116,47 @@ bool AcceleratorController::PerformAction(int action, |
return false; |
} |
+AcceleratorController::AcceleratorProcessingRestriction |
+AcceleratorController::GetCurrentAcceleratorRestriction() { |
+ return GetAcceleratorProcessingRestriction(-1); |
+} |
+ |
+AcceleratorController::AcceleratorProcessingRestriction |
+AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
+ ash::Shell* shell = ash::Shell::GetInstance(); |
+ if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && |
+ actions_allowed_at_login_screen_.find(action) == |
+ actions_allowed_at_login_screen_.end()) { |
+ return RESTRICTION_PREVENT_PROCESSING; |
+ } |
+ if (shell->session_state_delegate()->IsScreenLocked() && |
+ actions_allowed_at_lock_screen_.find(action) == |
+ actions_allowed_at_lock_screen_.end()) { |
+ return RESTRICTION_PREVENT_PROCESSING; |
+ } |
+ if (shell->IsSystemModalWindowOpen() && |
+ actions_allowed_at_modal_window_.find(action) == |
+ actions_allowed_at_modal_window_.end()) { |
+ // Note we prevent the shortcut from propagating so it will not |
+ // be passed to the modal window. This is important for things like |
+ // Alt+Tab that would cause an undesired effect in the modal window by |
+ // cycling through its window elements. |
+ return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
+ } |
+ if (shell->delegate()->IsRunningInForcedAppMode() && |
+ actions_allowed_in_app_mode_.find(action) == |
+ actions_allowed_in_app_mode_.end()) { |
+ return RESTRICTION_PREVENT_PROCESSING; |
+ } |
+ if (MruWindowTracker::BuildWindowList(false).empty() && |
+ actions_needing_window_.find(action) != actions_needing_window_.end()) { |
+ Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( |
+ A11Y_ALERT_WINDOW_NEEDED); |
+ return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
+ } |
+ return RESTRICTION_NONE; |
+} |
+ |
void AcceleratorController::SetBrightnessControlDelegate( |
scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { |
brightness_control_delegate_ = brightness_control_delegate.Pass(); |