Commit f5a1c26a authored by alemate's avatar alemate Committed by Commit bot

ash::ImeController should not crash if IME is not initialized yet

BUG=571940
TEST=manual

Review URL: https://codereview.chromium.org/1544243002

Cr-Commit-Position: refs/heads/master@{#367072}
parent 2510e003
...@@ -59,8 +59,16 @@ ui::Accelerator ImeController::RemapAccelerator( ...@@ -59,8 +59,16 @@ ui::Accelerator ImeController::RemapAccelerator(
bool ImeController::UsingFrenchInputMethod() const { bool ImeController::UsingFrenchInputMethod() const {
chromeos::input_method::InputMethodManager* manager = chromeos::input_method::InputMethodManager* manager =
chromeos::input_method::InputMethodManager::Get(); chromeos::input_method::InputMethodManager::Get();
const chromeos::input_method::InputMethodManager::State* state =
manager->GetActiveIMEState().get();
// KeyEvent can come before default user profile is initialized, so IM is
// still in global default state "en_US".
if (!state)
return false;
const chromeos::input_method::InputMethodDescriptor& descriptor = const chromeos::input_method::InputMethodDescriptor& descriptor =
manager->GetActiveIMEState()->GetCurrentInputMethod(); state->GetCurrentInputMethod();
const std::string& layout = descriptor.id(); const std::string& layout = descriptor.id();
return (layout == "xkb:fr::fra" || layout == "xkb:be::fra"); return (layout == "xkb:fr::fra" || layout == "xkb:be::fra");
} }
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