Chromium Code Reviews| Index: chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc |
| diff --git a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc |
| index a976a3737499a4df4722832230dc1ab84f7ad0ab..608991c4b8572df446e0b2f3715758c7415809ea 100644 |
| --- a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc |
| +++ b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc |
| @@ -85,11 +85,17 @@ NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor) |
| weak_ptr_factory_(this) { |
| DCHECK(core_oobe_actor_); |
| SetupTimeouts(); |
| + |
| + input_method::InputMethodManager::Get()-> |
| + GetComponentExtensionIMEManager()->AddObserver(this); |
| } |
| NetworkScreenHandler::~NetworkScreenHandler() { |
| if (screen_) |
| screen_->OnActorDestroyed(this); |
| + |
| + input_method::InputMethodManager::Get()-> |
| + GetComponentExtensionIMEManager()->RemoveObserver(this); |
| } |
| // NetworkScreenHandler, NetworkScreenActor implementation: -------------------- |
| @@ -246,8 +252,13 @@ void NetworkScreenHandler::OnLanguageChangedCallback( |
| } |
| void NetworkScreenHandler::HandleOnLanguageChanged(const std::string& locale) { |
| + HandleOnLanguageChangedInternal(locale, false); |
| +} |
| + |
| +void NetworkScreenHandler::HandleOnLanguageChangedInternal( |
| + const std::string& locale, bool force_refresh) { |
| const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| - if (app_locale == locale) |
| + if (app_locale == locale && !force_refresh) |
| return; |
| base::WeakPtr<NetworkScreenHandler> weak_self = |
| @@ -373,11 +384,17 @@ base::ListValue* NetworkScreenHandler::GetLanguageList() { |
| const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| input_method::InputMethodManager* manager = |
| input_method::InputMethodManager::Get(); |
| - // GetSupportedInputMethods() never returns NULL. |
| - scoped_ptr<input_method::InputMethodDescriptors> descriptors( |
| - manager->GetSupportedInputMethods()); |
| + ComponentExtensionIMEManager* comp_manager = |
| + manager->GetComponentExtensionIMEManager(); |
| + input_method::InputMethodDescriptors descriptors; |
| + if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) { |
| + if (comp_manager->IsInitialized()) |
| + descriptors = comp_manager->GetXkbIMEAsInputMethodDescriptor(); |
|
Seigo Nonaka
2014/03/07 07:21:21
What's happened if component extension manager is
Shu Chen
2014/03/07 07:30:29
If it's not initialized, descriptors will be an em
|
| + } else { |
| + descriptors = *(manager->GetSupportedInputMethods()); |
| + } |
| base::ListValue* languages_list = |
| - options::CrosLanguageOptionsHandler::GetUILanguageList(*descriptors); |
| + options::CrosLanguageOptionsHandler::GetUILanguageList(descriptors); |
| for (size_t i = 0; i < languages_list->GetSize(); ++i) { |
| base::DictionaryValue* language_info = NULL; |
| if (!languages_list->GetDictionary(i, &language_info)) |
| @@ -422,23 +439,31 @@ base::DictionaryValue* CreateInputMethodsEntry( |
| return input_method.release(); |
| } |
| +void NetworkScreenHandler::OnInitialized() { |
| + // Refreshes the whole UI. |
| + HandleOnLanguageChangedInternal( |
| + g_browser_process->GetApplicationLocale(), true); |
| +} |
| + |
| // static |
| base::ListValue* NetworkScreenHandler::GetInputMethods() { |
| base::ListValue* input_methods_list = new base::ListValue; |
| input_method::InputMethodManager* manager = |
| input_method::InputMethodManager::Get(); |
| input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
| + ComponentExtensionIMEManager* comp_manager = |
| + manager->GetComponentExtensionIMEManager(); |
| + if (!comp_manager->IsInitialized()) { |
| + input_method::InputMethodDescriptor fallback = |
| + util->GetFallbackInputMethodDescriptor(); |
| + input_methods_list->Append( |
| + CreateInputMethodsEntry(fallback, fallback.id())); |
| + return input_methods_list; |
| + } |
| + |
| scoped_ptr<input_method::InputMethodDescriptors> input_methods( |
| manager->GetActiveInputMethods()); |
| - // Uses extension_ime_util::MaybeGetLegacyXkbId() to make sure the input |
| - // method id is in legacy xkb id format (e.g. xkb:us::eng), instead of |
| - // extension based xkd id format (e.g. _comp_ime_...xkb:us::eng). |
| - // Same for the rests. |
| - // TODO(shuchen): support wait for component extension loading, and then show |
| - // OOBE window. So that extension_ime_util::MaybeGetLegacyXkbId() can be |
| - // removed. |
| - std::string current_input_method_id = extension_ime_util::MaybeGetLegacyXkbId( |
| - manager->GetCurrentInputMethod().id()); |
| + std::string current_input_method_id = manager->GetCurrentInputMethod().id(); |
|
Yuki
2014/03/07 07:47:04
nit: Use a const reference for |current_input_meth
Shu Chen
2014/03/07 08:24:09
Done.
|
| const std::vector<std::string>& hardware_login_input_methods = |
| util->GetHardwareLoginInputMethodIds(); |
| std::set<std::string> input_methods_added; |
| @@ -447,14 +472,12 @@ base::ListValue* NetworkScreenHandler::GetInputMethods() { |
| hardware_login_input_methods.begin(); |
| i != hardware_login_input_methods.end(); |
| ++i) { |
| - // Makes sure the id is in legacy xkb id format. |
| - const std::string id = extension_ime_util::MaybeGetLegacyXkbId(*i); |
| - input_methods_added.insert(id); |
| const input_method::InputMethodDescriptor* ime = |
| - util->GetInputMethodDescriptorFromId(id); |
| + util->GetInputMethodDescriptorFromId(*i); |
| DCHECK(ime != NULL); |
| // Do not crash in case of misconfiguration. |
| if (ime != NULL) { |
| + input_methods_added.insert(*i); |
| input_methods_list->Append( |
| CreateInputMethodsEntry(*ime, current_input_method_id)); |
| } |
| @@ -463,8 +486,7 @@ base::ListValue* NetworkScreenHandler::GetInputMethods() { |
| bool optgroup_added = false; |
| for (size_t i = 0; i < input_methods->size(); ++i) { |
| // Makes sure the id is in legacy xkb id format. |
| - const std::string& ime_id = extension_ime_util::MaybeGetLegacyXkbId( |
| - (*input_methods)[i].id()); |
| + const std::string& ime_id = (*input_methods)[i].id(); |
| if (!InsertString(ime_id, input_methods_added)) |
| continue; |
| if (!optgroup_added) { |
| @@ -475,9 +497,11 @@ base::ListValue* NetworkScreenHandler::GetInputMethods() { |
| CreateInputMethodsEntry((*input_methods)[i], current_input_method_id)); |
| } |
| // "xkb:us::eng" should always be in the list of available layouts. |
| - if (input_methods_added.count(kUSlayout) == 0) { |
| + std::string us_keyboard_id = |
|
Yuki
2014/03/07 07:47:04
nit: Use a const reference.
Shu Chen
2014/03/07 08:24:09
Done.
|
| + extension_ime_util::GetInputMethodIDByKeyboardLayout(kUSlayout); |
|
Yuki
2014/03/07 07:47:04
nit: kUsLayout or kUSLayout. L in Layout must be
Shu Chen
2014/03/07 08:24:09
Done.
|
| + if (input_methods_added.count(us_keyboard_id) == 0) { |
|
Yuki
2014/03/07 07:47:04
nit: Use find() rather than count() if the number
Shu Chen
2014/03/07 08:24:09
Done.
|
| const input_method::InputMethodDescriptor* us_eng_descriptor = |
| - util->GetInputMethodDescriptorFromId(kUSlayout); |
| + util->GetInputMethodDescriptorFromId(us_keyboard_id); |
| DCHECK(us_eng_descriptor != NULL); |
| if (!optgroup_added) { |
| optgroup_added = true; |