Commit f8c86591 authored by wzang's avatar wzang Committed by Commit bot

Check IME state in ImeController

ImeController::CanCycleIme() and ImeController::CanSwitchIme() should first
check if IME state is NULL and if it is, ignore the cycle / switch action
because it does not make sense before IME initialization.

BUG=703510

Review-Url: https://codereview.chromium.org/2806613002
Cr-Commit-Position: refs/heads/master@{#467804}
parent 19c7980b
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
bool ImeController::CanCycleIme() { bool ImeController::CanCycleIme() {
chromeos::input_method::InputMethodManager* manager = chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::InputMethodManager::Get(); chromeos::input_method::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(); return manager->GetActiveIMEState()->CanCycleInputMethod();
} }
...@@ -28,6 +34,12 @@ void ImeController::HandlePreviousIme() { ...@@ -28,6 +34,12 @@ void ImeController::HandlePreviousIme() {
bool ImeController::CanSwitchIme(const ui::Accelerator& accelerator) { bool ImeController::CanSwitchIme(const ui::Accelerator& accelerator) {
chromeos::input_method::InputMethodManager* manager = chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::InputMethodManager::Get(); chromeos::input_method::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); return manager->GetActiveIMEState()->CanSwitchInputMethod(accelerator);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment