return true;
}
-bool HandleNextIme(ImeControlDelegate* ime_control_delegate,
+void HandleNextIme(ImeControlDelegate* ime_control_delegate,
ui::EventType previous_event_type,
ui::KeyboardCode previous_key_code) {
// This check is necessary e.g. not to process the Shift+Alt+
previous_key_code != ui::VKEY_SPACE) {
// We totally ignore this accelerator.
// TODO(mazda): Fix crbug.com/158217
- return false;
+ return;
}
base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
if (ime_control_delegate)
- return ime_control_delegate->HandleNextIme();
- return false;
+ ime_control_delegate->HandleNextIme();
}
bool HandleOpenFeedbackPage() {
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
case SHOW_TASK_MANAGER:
return HandleShowTaskManager();
case NEXT_IME:
- return HandleNextIme(
+ HandleNextIme(
ime_control_delegate_.get(), previous_event_type, previous_key_code);
+ // NEXT_IME is bound to Alt-Shift key up event. To be consistent with
+ // Windows behavior, do not consume the key event here.
+ return false;
case PREVIOUS_IME:
return HandlePreviousIme(ime_control_delegate_.get(), accelerator);
case PRINT_UI_HIERARCHIES:
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();