| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 namespace chromeos { | 77 namespace chromeos { |
| 78 | 78 |
| 79 // NetworkScreenHandler, public: ----------------------------------------------- | 79 // NetworkScreenHandler, public: ----------------------------------------------- |
| 80 | 80 |
| 81 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor) | 81 NetworkScreenHandler::NetworkScreenHandler(CoreOobeActor* core_oobe_actor) |
| 82 : BaseScreenHandler(kJsScreenPath), | 82 : BaseScreenHandler(kJsScreenPath), |
| 83 screen_(NULL), | 83 screen_(NULL), |
| 84 core_oobe_actor_(core_oobe_actor), | 84 core_oobe_actor_(core_oobe_actor), |
| 85 is_continue_enabled_(false), | 85 is_continue_enabled_(false), |
| 86 show_on_init_(false), | 86 show_on_init_(false), |
| 87 should_reinitialize_language_keyboard_list_(false), |
| 87 weak_ptr_factory_(this) { | 88 weak_ptr_factory_(this) { |
| 88 DCHECK(core_oobe_actor_); | 89 DCHECK(core_oobe_actor_); |
| 89 SetupTimeouts(); | 90 SetupTimeouts(); |
| 90 | 91 |
| 91 input_method::InputMethodManager* manager = | 92 input_method::InputMethodManager* manager = |
| 92 input_method::InputMethodManager::Get(); | 93 input_method::InputMethodManager::Get(); |
| 93 manager->SetInputMethodLoginDefault(); | 94 manager->SetInputMethodLoginDefault(); |
| 94 manager->GetComponentExtensionIMEManager()->AddObserver(this); | 95 manager->GetComponentExtensionIMEManager()->AddObserver(this); |
| 95 } | 96 } |
| 96 | 97 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 138 } |
| 138 | 139 |
| 139 void NetworkScreenHandler::ClearErrors() { | 140 void NetworkScreenHandler::ClearErrors() { |
| 140 if (page_is_ready()) | 141 if (page_is_ready()) |
| 141 core_oobe_actor_->ClearErrors(); | 142 core_oobe_actor_->ClearErrors(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 void NetworkScreenHandler::ShowConnectingStatus( | 145 void NetworkScreenHandler::ShowConnectingStatus( |
| 145 bool connecting, | 146 bool connecting, |
| 146 const base::string16& network_id) { | 147 const base::string16& network_id) { |
| 147 // base::string16 connecting_label = | |
| 148 // l10n_util::GetStringFUTF16(IDS_NETWORK_SELECTION_CONNECTING, | |
| 149 // network_id); | |
| 150 // CallJS("cr.ui.Oobe.showConnectingStatus", | |
| 151 // base::FundamentalValue(connecting), | |
| 152 // base::StringValue(network_id), | |
| 153 // base::StringValue(connecting_label_value)); | |
| 154 } | 148 } |
| 155 | 149 |
| 156 void NetworkScreenHandler::EnableContinue(bool enabled) { | 150 void NetworkScreenHandler::EnableContinue(bool enabled) { |
| 157 is_continue_enabled_ = enabled; | 151 is_continue_enabled_ = enabled; |
| 158 if (page_is_ready()) | 152 if (page_is_ready()) |
| 159 CallJS("enableContinueButton", enabled); | 153 CallJS("enableContinueButton", enabled); |
| 160 } | 154 } |
| 161 | 155 |
| 162 // NetworkScreenHandler, BaseScreenHandler implementation: -------------------- | 156 // NetworkScreenHandler, BaseScreenHandler implementation: -------------------- |
| 163 | 157 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 186 dict->Set("timezoneList", GetTimezoneList()); | 180 dict->Set("timezoneList", GetTimezoneList()); |
| 187 } | 181 } |
| 188 | 182 |
| 189 void NetworkScreenHandler::Initialize() { | 183 void NetworkScreenHandler::Initialize() { |
| 190 EnableContinue(is_continue_enabled_); | 184 EnableContinue(is_continue_enabled_); |
| 191 if (show_on_init_) { | 185 if (show_on_init_) { |
| 192 show_on_init_ = false; | 186 show_on_init_ = false; |
| 193 Show(); | 187 Show(); |
| 194 } | 188 } |
| 195 | 189 |
| 190 if (should_reinitialize_language_keyboard_list_) { |
| 191 should_reinitialize_language_keyboard_list_ = false; |
| 192 ReloadLocalizedContent(); |
| 193 } |
| 194 |
| 196 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver( | 195 timezone_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 197 kSystemTimezone, | 196 kSystemTimezone, |
| 198 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged, | 197 base::Bind(&NetworkScreenHandler::OnSystemTimezoneChanged, |
| 199 base::Unretained(this))); | 198 base::Unretained(this))); |
| 200 OnSystemTimezoneChanged(); | 199 OnSystemTimezoneChanged(); |
| 201 } | 200 } |
| 202 | 201 |
| 203 // NetworkScreenHandler, WebUIMessageHandler implementation: ------------------- | 202 // NetworkScreenHandler, WebUIMessageHandler implementation: ------------------- |
| 204 | 203 |
| 205 void NetworkScreenHandler::RegisterMessages() { | 204 void NetworkScreenHandler::RegisterMessages() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // static | 240 // static |
| 242 void NetworkScreenHandler::OnLanguageChangedCallback( | 241 void NetworkScreenHandler::OnLanguageChangedCallback( |
| 243 scoped_ptr<NetworkScreenHandlerOnLanguageChangedCallbackData> context, | 242 scoped_ptr<NetworkScreenHandlerOnLanguageChangedCallbackData> context, |
| 244 const std::string& /*requested locale*/, | 243 const std::string& /*requested locale*/, |
| 245 const std::string& /*loaded_locale*/, | 244 const std::string& /*loaded_locale*/, |
| 246 const bool /*success*/) { | 245 const bool /*success*/) { |
| 247 if (!context or !context->handler_) | 246 if (!context or !context->handler_) |
| 248 return; | 247 return; |
| 249 | 248 |
| 250 NetworkScreenHandler* const self = context->handler_.get(); | 249 NetworkScreenHandler* const self = context->handler_.get(); |
| 251 | 250 self->ReloadLocalizedContent(); |
| 252 base::DictionaryValue localized_strings; | |
| 253 static_cast<OobeUI*>(self->web_ui()->GetController()) | |
| 254 ->GetLocalizedStrings(&localized_strings); | |
| 255 self->core_oobe_actor_->ReloadContent(localized_strings); | |
| 256 | |
| 257 // Buttons are recreated, updated "Continue" button state. | |
| 258 self->EnableContinue(self->is_continue_enabled_); | |
| 259 | 251 |
| 260 AccessibilityManager::Get()->OnLocaleChanged(); | 252 AccessibilityManager::Get()->OnLocaleChanged(); |
| 261 } | 253 } |
| 262 | 254 |
| 263 void NetworkScreenHandler::HandleOnLanguageChanged(const std::string& locale) { | 255 void NetworkScreenHandler::HandleOnLanguageChanged(const std::string& locale) { |
| 264 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 256 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 265 if (app_locale == locale) | 257 if (app_locale == locale) |
| 266 return; | 258 return; |
| 267 | 259 |
| 268 base::WeakPtr<NetworkScreenHandler> weak_self = | 260 base::WeakPtr<NetworkScreenHandler> weak_self = |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 input_method->SetString("title", util->GetInputMethodLongName(method)); | 433 input_method->SetString("title", util->GetInputMethodLongName(method)); |
| 442 input_method->SetBoolean("selected", ime_id == current_input_method_id); | 434 input_method->SetBoolean("selected", ime_id == current_input_method_id); |
| 443 return input_method.release(); | 435 return input_method.release(); |
| 444 } | 436 } |
| 445 | 437 |
| 446 void NetworkScreenHandler::OnImeComponentExtensionInitialized() { | 438 void NetworkScreenHandler::OnImeComponentExtensionInitialized() { |
| 447 input_method::InputMethodManager::Get()->SetInputMethodLoginDefault(); | 439 input_method::InputMethodManager::Get()->SetInputMethodLoginDefault(); |
| 448 | 440 |
| 449 // Refreshes the language and keyboard list once the component extension | 441 // Refreshes the language and keyboard list once the component extension |
| 450 // IMEs are initialized. | 442 // IMEs are initialized. |
| 443 if (page_is_ready()) |
| 444 ReloadLocalizedContent(); |
| 445 else |
| 446 should_reinitialize_language_keyboard_list_ = true; |
| 447 } |
| 448 |
| 449 void NetworkScreenHandler::ReloadLocalizedContent() { |
| 451 base::DictionaryValue localized_strings; | 450 base::DictionaryValue localized_strings; |
| 452 static_cast<OobeUI*>(this->web_ui()->GetController()) | 451 static_cast<OobeUI*>(web_ui()->GetController()) |
| 453 ->GetLocalizedStrings(&localized_strings); | 452 ->GetLocalizedStrings(&localized_strings); |
| 454 this->core_oobe_actor_->ReloadContent(localized_strings); | 453 core_oobe_actor_->ReloadContent(localized_strings); |
| 455 this->EnableContinue(this->is_continue_enabled_); | 454 |
| 455 // Buttons are recreated, updated "Continue" button state. |
| 456 EnableContinue(is_continue_enabled_); |
| 456 } | 457 } |
| 457 | 458 |
| 458 // static | 459 // static |
| 459 base::ListValue* NetworkScreenHandler::GetInputMethods() { | 460 base::ListValue* NetworkScreenHandler::GetInputMethods() { |
| 460 base::ListValue* input_methods_list = new base::ListValue; | 461 base::ListValue* input_methods_list = new base::ListValue; |
| 461 input_method::InputMethodManager* manager = | 462 input_method::InputMethodManager* manager = |
| 462 input_method::InputMethodManager::Get(); | 463 input_method::InputMethodManager::Get(); |
| 463 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 464 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
| 464 if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) { | 465 if (extension_ime_util::UseWrappedExtensionKeyboardLayouts()) { |
| 465 ComponentExtensionIMEManager* comp_manager = | 466 ComponentExtensionIMEManager* comp_manager = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 timezone_option->SetString("value", timezone_id); | 549 timezone_option->SetString("value", timezone_id); |
| 549 timezone_option->SetString("title", timezone_name); | 550 timezone_option->SetString("title", timezone_name); |
| 550 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 551 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); |
| 551 timezone_list->Append(timezone_option.release()); | 552 timezone_list->Append(timezone_option.release()); |
| 552 } | 553 } |
| 553 | 554 |
| 554 return timezone_list.release(); | 555 return timezone_list.release(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 } // namespace chromeos | 558 } // namespace chromeos |
| OLD | NEW |