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..98be0377adf1e75933967f65a36c0df1b0098a2d 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: -------------------- |
@@ -373,11 +379,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(); |
+ } 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 +434,42 @@ base::DictionaryValue* CreateInputMethodsEntry( |
return input_method.release(); |
} |
+void NetworkScreenHandler::OnInitialized() { |
+ LOG(ERROR) << "------NetworkScreenHandler::OnInitialized"; |
Seigo Nonaka
2014/03/07 07:50:05
Please remove debug code.
Shu Chen
2014/03/07 08:25:32
Done.
|
+ input_method::InputMethodManager* manager = |
+ input_method::InputMethodManager::Get(); |
+ manager->SetInputMethodLoginDefault(); |
+ LOG(ERROR) << "------NetworkScreenHandler::OnInitialized, set login layouts"; |
+ |
+ base::DictionaryValue localized_strings; |
+ static_cast<OobeUI*>(this->web_ui()->GetController()) |
+ ->GetLocalizedStrings(&localized_strings); |
+ this->core_oobe_actor_->ReloadContent(localized_strings); |
Seigo Nonaka
2014/03/07 07:50:05
Question: does ReloadContent cause display blink a
Shu Chen
2014/03/07 08:25:32
ReloadContent() methods will just call a JS functi
|
+ LOG(ERROR) << "------NetworkScreenHandler::OnInitialized, reload content"; |
+ |
+ // Buttons are recreated, updated "Continue" button state. |
+ this->EnableContinue(this->is_continue_enabled_); |
+} |
+ |
// 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(); |
const std::vector<std::string>& hardware_login_input_methods = |
util->GetHardwareLoginInputMethodIds(); |
std::set<std::string> input_methods_added; |
@@ -447,14 +478,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 +492,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 +503,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 = |
+ extension_ime_util::GetInputMethodIDByKeyboardLayout(kUSlayout); |
+ if (input_methods_added.count(us_keyboard_id) == 0) { |
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; |