Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc

Issue 389913002: Moving IME manifests to chrome resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modified per comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 namespace chromeos { 87 namespace chromeos {
88 88
89 // NetworkScreenHandler, public: ----------------------------------------------- 89 // NetworkScreenHandler, public: -----------------------------------------------
90 90
91 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor) 91 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor)
92 : BaseScreenHandler(kJsScreenPath), 92 : BaseScreenHandler(kJsScreenPath),
93 screen_(NULL), 93 screen_(NULL),
94 core_oobe_actor_(core_oobe_actor), 94 core_oobe_actor_(core_oobe_actor),
95 is_continue_enabled_(false), 95 is_continue_enabled_(false),
96 show_on_init_(false), 96 show_on_init_(false),
97 should_reinitialize_language_keyboard_list_(false),
98 weak_ptr_factory_(this) { 97 weak_ptr_factory_(this) {
99 DCHECK(core_oobe_actor_); 98 DCHECK(core_oobe_actor_);
100 99
101 input_method::InputMethodManager* manager = 100 input_method::InputMethodManager* manager =
102 input_method::InputMethodManager::Get(); 101 input_method::InputMethodManager::Get();
103 manager->AddObserver(this); 102 manager->AddObserver(this);
104 manager->GetComponentExtensionIMEManager()->AddObserver(this);
105 } 103 }
106 104
107 NetworkScreenHandler::~NetworkScreenHandler() { 105 NetworkScreenHandler::~NetworkScreenHandler() {
108 if (screen_) 106 if (screen_)
109 screen_->OnActorDestroyed(this); 107 screen_->OnActorDestroyed(this);
110 108
111 input_method::InputMethodManager* manager = 109 input_method::InputMethodManager* manager =
112 input_method::InputMethodManager::Get(); 110 input_method::InputMethodManager::Get();
113 manager->RemoveObserver(this); 111 manager->RemoveObserver(this);
114 manager->GetComponentExtensionIMEManager()->RemoveObserver(this);
115 } 112 }
116 113
117 // NetworkScreenHandler, NetworkScreenActor implementation: -------------------- 114 // NetworkScreenHandler, NetworkScreenActor implementation: --------------------
118 115
119 void NetworkScreenHandler::SetDelegate(NetworkScreenActor::Delegate* screen) { 116 void NetworkScreenHandler::SetDelegate(NetworkScreenActor::Delegate* screen) {
120 screen_ = screen; 117 screen_ = screen;
121 } 118 }
122 119
123 void NetworkScreenHandler::PrepareToShow() { 120 void NetworkScreenHandler::PrepareToShow() {
124 } 121 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 dict->Set("timezoneList", GetTimezoneList()); 213 dict->Set("timezoneList", GetTimezoneList());
217 } 214 }
218 215
219 void NetworkScreenHandler::Initialize() { 216 void NetworkScreenHandler::Initialize() {
220 EnableContinue(is_continue_enabled_); 217 EnableContinue(is_continue_enabled_);
221 if (show_on_init_) { 218 if (show_on_init_) {
222 show_on_init_ = false; 219 show_on_init_ = false;
223 Show(); 220 Show();
224 } 221 }
225 222
226 if (should_reinitialize_language_keyboard_list_) {
227 should_reinitialize_language_keyboard_list_ = false;
228 ReloadLocalizedContent();
229 }
230
231 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver( 223 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver(
232 kSystemTimezone, 224 kSystemTimezone,
233 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged, 225 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged,
234 base::Unretained(this))); 226 base::Unretained(this)));
235 OnSystemTimezoneChanged(); 227 OnSystemTimezoneChanged();
236 } 228 }
237 229
238 // NetworkScreenHandler, WebUIMessageHandler implementation: ------------------- 230 // NetworkScreenHandler, WebUIMessageHandler implementation: -------------------
239 231
240 void NetworkScreenHandler::RegisterMessages() { 232 void NetworkScreenHandler::RegisterMessages() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id); 331 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id);
340 CallJS("setTimezone", current_timezone_id); 332 CallJS("setTimezone", current_timezone_id);
341 } 333 }
342 334
343 base::ListValue* NetworkScreenHandler::GetLanguageList() { 335 base::ListValue* NetworkScreenHandler::GetLanguageList() {
344 const std::string app_locale = g_browser_process->GetApplicationLocale(); 336 const std::string app_locale = g_browser_process->GetApplicationLocale();
345 input_method::InputMethodManager* manager = 337 input_method::InputMethodManager* manager =
346 input_method::InputMethodManager::Get(); 338 input_method::InputMethodManager::Get();
347 ComponentExtensionIMEManager* comp_manager = 339 ComponentExtensionIMEManager* comp_manager =
348 manager->GetComponentExtensionIMEManager(); 340 manager->GetComponentExtensionIMEManager();
349 input_method::InputMethodDescriptors descriptors; 341 input_method::InputMethodDescriptors descriptors =
350 if (comp_manager->IsInitialized()) 342 comp_manager->GetXkbIMEAsInputMethodDescriptor();
351 descriptors = comp_manager->GetXkbIMEAsInputMethodDescriptor();
352 base::ListValue* languages_list = 343 base::ListValue* languages_list =
353 options::CrosLanguageOptionsHandler::GetUILanguageList(descriptors); 344 options::CrosLanguageOptionsHandler::GetUILanguageList(descriptors);
354 for (size_t i = 0; i < languages_list->GetSize(); ++i) { 345 for (size_t i = 0; i < languages_list->GetSize(); ++i) {
355 base::DictionaryValue* language_info = NULL; 346 base::DictionaryValue* language_info = NULL;
356 if (!languages_list->GetDictionary(i, &language_info)) 347 if (!languages_list->GetDictionary(i, &language_info))
357 NOTREACHED(); 348 NOTREACHED();
358 349
359 std::string value; 350 std::string value;
360 language_info->GetString("code", &value); 351 language_info->GetString("code", &value);
361 std::string display_name; 352 std::string display_name;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 input_method::InputMethodUtil* util = 385 input_method::InputMethodUtil* util =
395 input_method::InputMethodManager::Get()->GetInputMethodUtil(); 386 input_method::InputMethodManager::Get()->GetInputMethodUtil();
396 const std::string& ime_id = method.id(); 387 const std::string& ime_id = method.id();
397 scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue); 388 scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue);
398 input_method->SetString("value", ime_id); 389 input_method->SetString("value", ime_id);
399 input_method->SetString("title", util->GetInputMethodLongName(method)); 390 input_method->SetString("title", util->GetInputMethodLongName(method));
400 input_method->SetBoolean("selected", ime_id == current_input_method_id); 391 input_method->SetBoolean("selected", ime_id == current_input_method_id);
401 return input_method.release(); 392 return input_method.release();
402 } 393 }
403 394
404 void NetworkScreenHandler::OnImeComponentExtensionInitialized() {
405 // Refreshes the language and keyboard list once the component extension
406 // IMEs are initialized.
407 if (page_is_ready())
408 ReloadLocalizedContent();
409 else
410 should_reinitialize_language_keyboard_list_ = true;
411 }
412
413 void NetworkScreenHandler::InputMethodChanged( 395 void NetworkScreenHandler::InputMethodChanged(
414 input_method::InputMethodManager* manager, bool show_message) { 396 input_method::InputMethodManager* manager, bool show_message) {
415 CallJS("setInputMethod", manager->GetCurrentInputMethod().id()); 397 CallJS("setInputMethod", manager->GetCurrentInputMethod().id());
416 } 398 }
417 399
418 void NetworkScreenHandler::ReloadLocalizedContent() { 400 void NetworkScreenHandler::ReloadLocalizedContent() {
419 base::DictionaryValue localized_strings; 401 base::DictionaryValue localized_strings;
420 static_cast<OobeUI*>(web_ui()->GetController()) 402 static_cast<OobeUI*>(web_ui()->GetController())
421 ->GetLocalizedStrings(&localized_strings); 403 ->GetLocalizedStrings(&localized_strings);
422 core_oobe_actor_->ReloadContent(localized_strings); 404 core_oobe_actor_->ReloadContent(localized_strings);
423 405
424 // Buttons are recreated, updated "Continue" button state. 406 // Buttons are recreated, updated "Continue" button state.
425 EnableContinue(is_continue_enabled_); 407 EnableContinue(is_continue_enabled_);
426 } 408 }
427 409
428 // static 410 // static
429 base::ListValue* NetworkScreenHandler::GetInputMethods() { 411 base::ListValue* NetworkScreenHandler::GetInputMethods() {
430 base::ListValue* input_methods_list = new base::ListValue; 412 base::ListValue* input_methods_list = new base::ListValue;
431 input_method::InputMethodManager* manager = 413 input_method::InputMethodManager* manager =
432 input_method::InputMethodManager::Get(); 414 input_method::InputMethodManager::Get();
433 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 415 input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
434 ComponentExtensionIMEManager* comp_manager =
435 manager->GetComponentExtensionIMEManager();
436 if (!comp_manager->IsInitialized()) {
437 input_method::InputMethodDescriptor fallback =
438 util->GetFallbackInputMethodDescriptor();
439 input_methods_list->Append(
440 CreateInputMethodsEntry(fallback, fallback.id()));
441 return input_methods_list;
442 }
443 416
444 const std::vector<std::string>& hardware_login_input_methods = 417 const std::vector<std::string>& hardware_login_input_methods =
445 util->GetHardwareLoginInputMethodIds(); 418 util->GetHardwareLoginInputMethodIds();
446 manager->EnableLoginLayouts(g_browser_process->GetApplicationLocale(), 419 manager->EnableLoginLayouts(g_browser_process->GetApplicationLocale(),
447 hardware_login_input_methods); 420 hardware_login_input_methods);
448 421
449 scoped_ptr<input_method::InputMethodDescriptors> input_methods( 422 scoped_ptr<input_method::InputMethodDescriptors> input_methods(
450 manager->GetActiveInputMethods()); 423 manager->GetActiveInputMethods());
451 const std::string current_input_method_id = 424 const std::string current_input_method_id =
452 manager->GetCurrentInputMethod().id(); 425 manager->GetCurrentInputMethod().id();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 timezone_option->SetString("value", timezone_id); 492 timezone_option->SetString("value", timezone_id);
520 timezone_option->SetString("title", timezone_name); 493 timezone_option->SetString("title", timezone_name);
521 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); 494 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id);
522 timezone_list->Append(timezone_option.release()); 495 timezone_list->Append(timezone_option.release());
523 } 496 }
524 497
525 return timezone_list.release(); 498 return timezone_list.release();
526 } 499 }
527 500
528 } // namespace chromeos 501 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698