| Index: ash/accelerators/accelerator_controller.cc
|
| diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
|
| index 789059b65e59b661ee936a128796670c73f86cc2..6b9336da3fde20273256ac2106206f2e81a27fc4 100644
|
| --- a/ash/accelerators/accelerator_controller.cc
|
| +++ b/ash/accelerators/accelerator_controller.cc
|
| @@ -12,7 +12,7 @@
|
| #include "ash/accessibility_delegate.h"
|
| #include "ash/accessibility_types.h"
|
| #include "ash/focus_cycler.h"
|
| -#include "ash/ime/ime_switch_type.h"
|
| +#include "ash/ime_control_delegate.h"
|
| #include "ash/media_controller.h"
|
| #include "ash/multi_profile_uma.h"
|
| #include "ash/new_window_controller.h"
|
| @@ -68,7 +68,6 @@
|
| namespace {
|
|
|
| using base::UserMetricsAction;
|
| -using chromeos::input_method::InputMethodManager;
|
| using message_center::Notification;
|
|
|
| // Identifier for the high contrast toggle accelerator notification.
|
| @@ -172,11 +171,6 @@
|
| histogram->Add(sample);
|
| }
|
|
|
| -void RecordImeSwitchByAccelerator() {
|
| - UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeSwitch",
|
| - ImeSwitchType::kAccelerator, ImeSwitchType::kCount);
|
| -}
|
| -
|
| void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) {
|
| if (accelerator.key_code() == ui::VKEY_TAB)
|
| base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab"));
|
| @@ -257,15 +251,8 @@
|
| Shell::Get()->new_window_controller()->NewWindow(false /* is_incognito */);
|
| }
|
|
|
| -bool CanCycleInputMethod() {
|
| - InputMethodManager* manager = InputMethodManager::Get();
|
| - DCHECK(manager);
|
| - if (!manager->GetActiveIMEState()) {
|
| - LOG(WARNING) << "Cannot cycle through input methods as they are not "
|
| - "initialized yet.";
|
| - return false;
|
| - }
|
| - return manager->GetActiveIMEState()->CanCycleInputMethod();
|
| +bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) {
|
| + return ime_control_delegate && ime_control_delegate->CanCycleIme();
|
| }
|
|
|
| bool CanHandleCycleMru(const ui::Accelerator& accelerator) {
|
| @@ -280,10 +267,9 @@
|
| return !(keyboard_controller && keyboard_controller->keyboard_visible());
|
| }
|
|
|
| -void HandleNextIme() {
|
| +void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
|
| base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
|
| - RecordImeSwitchByAccelerator();
|
| - InputMethodManager::Get()->GetActiveIMEState()->SwitchToNextInputMethod();
|
| + ime_control_delegate->HandleNextIme();
|
| }
|
|
|
| void HandleOpenFeedbackPage() {
|
| @@ -291,14 +277,15 @@
|
| Shell::Get()->new_window_controller()->OpenFeedbackPage();
|
| }
|
|
|
| -void HandlePreviousIme(const ui::Accelerator& accelerator) {
|
| +bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) {
|
| + return ime_control_delegate && ime_control_delegate->CanCycleIme();
|
| +}
|
| +
|
| +void HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
|
| + const ui::Accelerator& accelerator) {
|
| base::RecordAction(UserMetricsAction("Accel_Previous_Ime"));
|
| - if (accelerator.key_state() == ui::Accelerator::KeyState::PRESSED) {
|
| - RecordImeSwitchByAccelerator();
|
| - InputMethodManager::Get()
|
| - ->GetActiveIMEState()
|
| - ->SwitchToPreviousInputMethod();
|
| - }
|
| + if (accelerator.key_state() == ui::Accelerator::KeyState::PRESSED)
|
| + ime_control_delegate->HandlePreviousIme();
|
| // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything.
|
| }
|
|
|
| @@ -365,22 +352,16 @@
|
| Shell::Get()->new_window_controller()->ShowTaskManager();
|
| }
|
|
|
| -bool CanHandleSwitchIme(const ui::Accelerator& accelerator) {
|
| - InputMethodManager* manager = InputMethodManager::Get();
|
| - DCHECK(manager);
|
| - if (!manager->GetActiveIMEState()) {
|
| - LOG(WARNING) << "Cannot switch input methods as they are not "
|
| - "initialized yet.";
|
| - return false;
|
| - }
|
| - return manager->GetActiveIMEState()->CanSwitchInputMethod(accelerator);
|
| -}
|
| -
|
| -void HandleSwitchIme(const ui::Accelerator& accelerator) {
|
| +bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate,
|
| + const ui::Accelerator& accelerator) {
|
| + return ime_control_delegate &&
|
| + ime_control_delegate->CanSwitchIme(accelerator);
|
| +}
|
| +
|
| +void HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
|
| + const ui::Accelerator& accelerator) {
|
| base::RecordAction(UserMetricsAction("Accel_Switch_Ime"));
|
| - RecordImeSwitchByAccelerator();
|
| - InputMethodManager::Get()->GetActiveIMEState()->SwitchInputMethod(
|
| - accelerator);
|
| + ime_control_delegate->HandleSwitchIme(accelerator);
|
| }
|
|
|
| bool CanHandleToggleAppList(const ui::Accelerator& accelerator,
|
| @@ -752,6 +733,11 @@
|
| AcceleratorController::AcceleratorProcessingRestriction
|
| AcceleratorController::GetCurrentAcceleratorRestriction() {
|
| return GetAcceleratorProcessingRestriction(-1);
|
| +}
|
| +
|
| +void AcceleratorController::SetImeControlDelegate(
|
| + std::unique_ptr<ImeControlDelegate> ime_control_delegate) {
|
| + ime_control_delegate_ = std::move(ime_control_delegate);
|
| }
|
|
|
| bool AcceleratorController::ShouldCloseMenuAndRepostAccelerator(
|
| @@ -926,15 +912,15 @@
|
| case NEW_INCOGNITO_WINDOW:
|
| return CanHandleNewIncognitoWindow();
|
| case NEXT_IME:
|
| - return CanCycleInputMethod();
|
| + return CanHandleNextIme(ime_control_delegate_.get());
|
| case PREVIOUS_IME:
|
| - return CanCycleInputMethod();
|
| + return CanHandlePreviousIme(ime_control_delegate_.get());
|
| case SHOW_MESSAGE_CENTER_BUBBLE:
|
| return CanHandleShowMessageCenterBubble();
|
| case SHOW_STYLUS_TOOLS:
|
| return CanHandleShowStylusTools();
|
| case SWITCH_IME:
|
| - return CanHandleSwitchIme(accelerator);
|
| + return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator);
|
| case SWITCH_TO_PREVIOUS_USER:
|
| case SWITCH_TO_NEXT_USER:
|
| return CanHandleCycleUser();
|
| @@ -1125,7 +1111,7 @@
|
| HandleNewWindow();
|
| break;
|
| case NEXT_IME:
|
| - HandleNextIme();
|
| + HandleNextIme(ime_control_delegate_.get());
|
| break;
|
| case OPEN_CROSH:
|
| HandleCrosh();
|
| @@ -1140,7 +1126,7 @@
|
| HandleGetHelp();
|
| break;
|
| case PREVIOUS_IME:
|
| - HandlePreviousIme(accelerator);
|
| + HandlePreviousIme(ime_control_delegate_.get(), accelerator);
|
| break;
|
| case PRINT_UI_HIERARCHIES:
|
| debug::PrintUIHierarchies();
|
| @@ -1173,7 +1159,7 @@
|
| HandleSuspend();
|
| break;
|
| case SWITCH_IME:
|
| - HandleSwitchIme(accelerator);
|
| + HandleSwitchIme(ime_control_delegate_.get(), accelerator);
|
| break;
|
| case SWITCH_TO_NEXT_USER:
|
| HandleCycleUser(CycleUserDirection::NEXT);
|
|
|