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

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: . 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 namespace chromeos { 88 namespace chromeos {
89 89
90 // NetworkScreenHandler, public: ----------------------------------------------- 90 // NetworkScreenHandler, public: -----------------------------------------------
91 91
92 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor) 92 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor)
93 : BaseScreenHandler(kJsScreenPath), 93 : BaseScreenHandler(kJsScreenPath),
94 screen_(NULL), 94 screen_(NULL),
95 core_oobe_actor_(core_oobe_actor), 95 core_oobe_actor_(core_oobe_actor),
96 is_continue_enabled_(false), 96 is_continue_enabled_(false),
97 show_on_init_(false), 97 show_on_init_(false),
98 should_reinitialize_language_keyboard_list_(false),
99 weak_ptr_factory_(this) { 98 weak_ptr_factory_(this) {
100 DCHECK(core_oobe_actor_); 99 DCHECK(core_oobe_actor_);
101 100
102 input_method::InputMethodManager* manager = 101 input_method::InputMethodManager* manager =
103 input_method::InputMethodManager::Get(); 102 input_method::InputMethodManager::Get();
104 manager->AddObserver(this); 103 manager->AddObserver(this);
105 manager->GetComponentExtensionIMEManager()->AddObserver(this);
106 } 104 }
107 105
108 NetworkScreenHandler::~NetworkScreenHandler() { 106 NetworkScreenHandler::~NetworkScreenHandler() {
109 if (screen_) 107 if (screen_)
110 screen_->OnActorDestroyed(this); 108 screen_->OnActorDestroyed(this);
111 109
112 input_method::InputMethodManager* manager = 110 input_method::InputMethodManager* manager =
113 input_method::InputMethodManager::Get(); 111 input_method::InputMethodManager::Get();
114 manager->RemoveObserver(this); 112 manager->RemoveObserver(this);
115 manager->GetComponentExtensionIMEManager()->RemoveObserver(this);
116 } 113 }
117 114
118 // NetworkScreenHandler, NetworkScreenActor implementation: -------------------- 115 // NetworkScreenHandler, NetworkScreenActor implementation: --------------------
119 116
120 void NetworkScreenHandler::SetDelegate(NetworkScreenActor::Delegate* screen) { 117 void NetworkScreenHandler::SetDelegate(NetworkScreenActor::Delegate* screen) {
121 screen_ = screen; 118 screen_ = screen;
122 } 119 }
123 120
124 void NetworkScreenHandler::PrepareToShow() { 121 void NetworkScreenHandler::PrepareToShow() {
125 } 122 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 dict->Set("timezoneList", GetTimezoneList()); 214 dict->Set("timezoneList", GetTimezoneList());
218 } 215 }
219 216
220 void NetworkScreenHandler::Initialize() { 217 void NetworkScreenHandler::Initialize() {
221 EnableContinue(is_continue_enabled_); 218 EnableContinue(is_continue_enabled_);
222 if (show_on_init_) { 219 if (show_on_init_) {
223 show_on_init_ = false; 220 show_on_init_ = false;
224 Show(); 221 Show();
225 } 222 }
226 223
227 if (should_reinitialize_language_keyboard_list_) {
228 should_reinitialize_language_keyboard_list_ = false;
229 ReloadLocalizedContent();
230 }
231
232 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver( 224 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver(
233 kSystemTimezone, 225 kSystemTimezone,
234 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged, 226 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged,
235 base::Unretained(this))); 227 base::Unretained(this)));
236 OnSystemTimezoneChanged(); 228 OnSystemTimezoneChanged();
237 } 229 }
238 230
239 // NetworkScreenHandler, WebUIMessageHandler implementation: ------------------- 231 // NetworkScreenHandler, WebUIMessageHandler implementation: -------------------
240 232
241 void NetworkScreenHandler::RegisterMessages() { 233 void NetworkScreenHandler::RegisterMessages() {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id); 337 CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id);
346 CallJS("setTimezone", current_timezone_id); 338 CallJS("setTimezone", current_timezone_id);
347 } 339 }
348 340
349 base::ListValue* NetworkScreenHandler::GetLanguageList() { 341 base::ListValue* NetworkScreenHandler::GetLanguageList() {
350 const std::string app_locale = g_browser_process->GetApplicationLocale(); 342 const std::string app_locale = g_browser_process->GetApplicationLocale();
351 input_method::InputMethodManager* manager = 343 input_method::InputMethodManager* manager =
352 input_method::InputMethodManager::Get(); 344 input_method::InputMethodManager::Get();
353 ComponentExtensionIMEManager* comp_manager = 345 ComponentExtensionIMEManager* comp_manager =
354 manager->GetComponentExtensionIMEManager(); 346 manager->GetComponentExtensionIMEManager();
355 input_method::InputMethodDescriptors descriptors; 347 input_method::InputMethodDescriptors descriptors =
356 if (comp_manager->IsInitialized()) 348 comp_manager->GetXkbIMEAsInputMethodDescriptor();
357 descriptors = comp_manager->GetXkbIMEAsInputMethodDescriptor();
358 base::ListValue* languages_list = 349 base::ListValue* languages_list =
359 options::CrosLanguageOptionsHandler::GetUILanguageList(descriptors); 350 options::CrosLanguageOptionsHandler::GetUILanguageList(descriptors);
360 for (size_t i = 0; i < languages_list->GetSize(); ++i) { 351 for (size_t i = 0; i < languages_list->GetSize(); ++i) {
361 base::DictionaryValue* language_info = NULL; 352 base::DictionaryValue* language_info = NULL;
362 if (!languages_list->GetDictionary(i, &language_info)) 353 if (!languages_list->GetDictionary(i, &language_info))
363 NOTREACHED(); 354 NOTREACHED();
364 355
365 std::string value; 356 std::string value;
366 language_info->GetString("code", &value); 357 language_info->GetString("code", &value);
367 std::string display_name; 358 std::string display_name;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 input_method::InputMethodUtil* util = 391 input_method::InputMethodUtil* util =
401 input_method::InputMethodManager::Get()->GetInputMethodUtil(); 392 input_method::InputMethodManager::Get()->GetInputMethodUtil();
402 const std::string& ime_id = method.id(); 393 const std::string& ime_id = method.id();
403 scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue); 394 scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue);
404 input_method->SetString("value", ime_id); 395 input_method->SetString("value", ime_id);
405 input_method->SetString("title", util->GetInputMethodLongName(method)); 396 input_method->SetString("title", util->GetInputMethodLongName(method));
406 input_method->SetBoolean("selected", ime_id == current_input_method_id); 397 input_method->SetBoolean("selected", ime_id == current_input_method_id);
407 return input_method.release(); 398 return input_method.release();
408 } 399 }
409 400
410 void NetworkScreenHandler::OnImeComponentExtensionInitialized() {
411 // Refreshes the language and keyboard list once the component extension
412 // IMEs are initialized.
413 if (page_is_ready())
414 ReloadLocalizedContent();
415 else
416 should_reinitialize_language_keyboard_list_ = true;
417 }
418
419 void NetworkScreenHandler::InputMethodChanged( 401 void NetworkScreenHandler::InputMethodChanged(
420 input_method::InputMethodManager* manager, bool show_message) { 402 input_method::InputMethodManager* manager, bool show_message) {
421 CallJS("setInputMethod", manager->GetCurrentInputMethod().id()); 403 CallJS("setInputMethod", manager->GetCurrentInputMethod().id());
422 } 404 }
423 405
424 void NetworkScreenHandler::ReloadLocalizedContent() { 406 void NetworkScreenHandler::ReloadLocalizedContent() {
425 base::DictionaryValue localized_strings; 407 base::DictionaryValue localized_strings;
426 static_cast<OobeUI*>(web_ui()->GetController()) 408 static_cast<OobeUI*>(web_ui()->GetController())
427 ->GetLocalizedStrings(&localized_strings); 409 ->GetLocalizedStrings(&localized_strings);
428 core_oobe_actor_->ReloadContent(localized_strings); 410 core_oobe_actor_->ReloadContent(localized_strings);
429 411
430 // Buttons are recreated, updated "Continue" button state. 412 // Buttons are recreated, updated "Continue" button state.
431 EnableContinue(is_continue_enabled_); 413 EnableContinue(is_continue_enabled_);
432 } 414 }
433 415
434 // static 416 // static
435 base::ListValue* NetworkScreenHandler::GetInputMethods() { 417 base::ListValue* NetworkScreenHandler::GetInputMethods() {
436 base::ListValue* input_methods_list = new base::ListValue; 418 base::ListValue* input_methods_list = new base::ListValue;
437 input_method::InputMethodManager* manager = 419 input_method::InputMethodManager* manager =
438 input_method::InputMethodManager::Get(); 420 input_method::InputMethodManager::Get();
439 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 421 input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
440 ComponentExtensionIMEManager* comp_manager =
441 manager->GetComponentExtensionIMEManager();
442 if (!comp_manager->IsInitialized()) {
443 input_method::InputMethodDescriptor fallback =
444 util->GetFallbackInputMethodDescriptor();
445 input_methods_list->Append(
446 CreateInputMethodsEntry(fallback, fallback.id()));
447 return input_methods_list;
448 }
449 422
450 const std::vector<std::string>& hardware_login_input_methods = 423 const std::vector<std::string>& hardware_login_input_methods =
451 util->GetHardwareLoginInputMethodIds(); 424 util->GetHardwareLoginInputMethodIds();
452 manager->EnableLoginLayouts(g_browser_process->GetApplicationLocale(), 425 manager->EnableLoginLayouts(g_browser_process->GetApplicationLocale(),
453 hardware_login_input_methods); 426 hardware_login_input_methods);
454 427
455 scoped_ptr<input_method::InputMethodDescriptors> input_methods( 428 scoped_ptr<input_method::InputMethodDescriptors> input_methods(
456 manager->GetActiveInputMethods()); 429 manager->GetActiveInputMethods());
457 const std::string current_input_method_id = 430 const std::string current_input_method_id =
458 manager->GetCurrentInputMethod().id(); 431 manager->GetCurrentInputMethod().id();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 timezone_option->SetString("value", timezone_id); 498 timezone_option->SetString("value", timezone_id);
526 timezone_option->SetString("title", timezone_name); 499 timezone_option->SetString("title", timezone_name);
527 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); 500 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id);
528 timezone_list->Append(timezone_option.release()); 501 timezone_list->Append(timezone_option.release());
529 } 502 }
530 503
531 return timezone_list.release(); 504 return timezone_list.release();
532 } 505 }
533 506
534 } // namespace chromeos 507 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698