Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index b18d0a01a1af496ea7a3b0be59fe3279badddfaa..3c37e993f6b9859dbd4ce3abb4c888753581bf5e 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -253,33 +253,38 @@ void HandleNewWindow() { |
} |
bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate, |
- const ui::Accelerator& previous_accelerator) { |
- // We only allow next IME to be triggered if the previous is accelerator key |
- // is ONLY either Shift, Alt, Enter or Space. |
- // The first two cases to avoid conflicting accelerators that contain |
- // Alt+Shift (like Alt+Shift+Tab or Alt+Shift+S) to trigger next IME when the |
- // wrong order of key sequences is pressed. crbug.com/527154. |
- // The latter two cases are needed for CJK IME users who tend to press Enter |
- // (or Space) and Shift+Alt almost at the same time to commit an IME string |
- // and then switch from the IME to the English layout. This allows these users |
- // to trigger NEXT_IME even if they press Shift+Alt before releasing Enter. |
- // crbug.com/139556. |
- // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way. |
- const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
- switch (previous_key_code) { |
- case ui::VKEY_SHIFT: |
- case ui::VKEY_LSHIFT: |
- case ui::VKEY_RSHIFT: |
- case ui::VKEY_MENU: |
- case ui::VKEY_LMENU: |
- case ui::VKEY_RMENU: |
- case ui::VKEY_RETURN: |
- case ui::VKEY_SPACE: |
- return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
- |
- default: |
- return false; |
+ const ui::Accelerator& previous_accelerator, |
+ bool current_accelerator_is_deprecated) { |
+ if (current_accelerator_is_deprecated) { |
+ // We only allow next IME to be triggered if the previous is accelerator key |
+ // is ONLY either Shift, Alt, Enter or Space. |
+ // The first six cases below are to avoid conflicting accelerators that |
+ // contain Alt+Shift (like Alt+Shift+Tab or Alt+Shift+S) to trigger next IME |
+ // when the wrong order of key sequences is pressed. crbug.com/527154. |
+ // The latter two cases are needed for CJK IME users who tend to press Enter |
+ // (or Space) and Shift+Alt almost at the same time to commit an IME string |
+ // and then switch from the IME to the English layout. This allows these |
+ // users to trigger NEXT_IME even if they press Shift+Alt before releasing |
+ // Enter. crbug.com/139556. |
+ // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way. |
+ const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
+ switch (previous_key_code) { |
+ case ui::VKEY_SHIFT: |
+ case ui::VKEY_LSHIFT: |
+ case ui::VKEY_RSHIFT: |
+ case ui::VKEY_MENU: |
+ case ui::VKEY_LMENU: |
+ case ui::VKEY_RMENU: |
+ case ui::VKEY_RETURN: |
+ case ui::VKEY_SPACE: |
+ break; |
+ |
+ default: |
+ return false; |
+ } |
} |
+ |
+ return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
} |
void HandleNextIme(ImeControlDelegate* ime_control_delegate) { |
@@ -913,17 +918,19 @@ void AcceleratorController::RegisterAccelerators( |
void AcceleratorController::RegisterDeprecatedAccelerators() { |
#if defined(OS_CHROMEOS) |
+ for (size_t i = 0; i < kDeprecatedAcceleratorsDataLength; ++i) { |
+ const DeprecatedAcceleratorData* data = &kDeprecatedAcceleratorsData[i]; |
+ actions_with_deprecations_[data->action] = data; |
+ } |
+ |
for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { |
- const DeprecatedAcceleratorData* data = &kDeprecatedAccelerators[i]; |
- const AcceleratorAction action = data->deprecated_accelerator.action; |
+ const AcceleratorData& accelerator_data = kDeprecatedAccelerators[i]; |
const ui::Accelerator deprecated_accelerator = |
- CreateAccelerator(data->deprecated_accelerator.keycode, |
- data->deprecated_accelerator.modifiers, |
- data->deprecated_accelerator.trigger_on_press); |
+ CreateAccelerator(accelerator_data.keycode, accelerator_data.modifiers, |
+ accelerator_data.trigger_on_press); |
Register(deprecated_accelerator, this); |
- actions_with_deprecations_[action] = data; |
- accelerators_[deprecated_accelerator] = action; |
+ accelerators_[deprecated_accelerator] = accelerator_data.action; |
deprecated_accelerators_.insert(deprecated_accelerator); |
} |
#endif // defined(OS_CHROMEOS) |
@@ -964,9 +971,18 @@ bool AcceleratorController::CanPerformAction( |
return CanHandleMagnifyScreen(); |
case NEW_INCOGNITO_WINDOW: |
return CanHandleNewIncognitoWindow(); |
- case NEXT_IME: |
- return CanHandleNextIme(ime_control_delegate_.get(), |
- previous_accelerator); |
+ case NEXT_IME: { |
+#if defined(OS_CHROMEOS) |
+ bool accelerator_is_deprecated = |
+ (deprecated_accelerators_.count(accelerator) != 0); |
+#else |
+ // On non-chromeos, the NEXT_IME deprecated accelerators are always used. |
+ bool accelerator_is_deprecated = true; |
+#endif // defined(OS_CHROMEOS) |
+ |
+ return CanHandleNextIme(ime_control_delegate_.get(), previous_accelerator, |
+ accelerator_is_deprecated); |
+ } |
case PREVIOUS_IME: |
return CanHandlePreviousIme(ime_control_delegate_.get()); |
case SCALE_UI_RESET: |