| 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 "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void NetworkScreenHandler::RegisterMessages() { | 127 void NetworkScreenHandler::RegisterMessages() { |
| 128 AddCallback(kJsApiNetworkOnExit, &NetworkScreenHandler::HandleOnExit); | 128 AddCallback(kJsApiNetworkOnExit, &NetworkScreenHandler::HandleOnExit); |
| 129 AddCallback(kJsApiNetworkOnLanguageChanged, | 129 AddCallback(kJsApiNetworkOnLanguageChanged, |
| 130 &NetworkScreenHandler::HandleOnLanguageChanged); | 130 &NetworkScreenHandler::HandleOnLanguageChanged); |
| 131 AddCallback(kJsApiNetworkOnInputMethodChanged, | 131 AddCallback(kJsApiNetworkOnInputMethodChanged, |
| 132 &NetworkScreenHandler::HandleOnInputMethodChanged); | 132 &NetworkScreenHandler::HandleOnInputMethodChanged); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // NetworkScreenHandler, private: ---------------------------------------------- | 135 // NetworkScreenHandler, private: ---------------------------------------------- |
| 136 | 136 |
| 137 void NetworkScreenHandler::HandleOnExit(const ListValue* args) { | 137 void NetworkScreenHandler::HandleOnExit() { |
| 138 ClearErrors(); | 138 ClearErrors(); |
| 139 if (screen_) | 139 if (screen_) |
| 140 screen_->OnContinuePressed(); | 140 screen_->OnContinuePressed(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void NetworkScreenHandler::HandleOnLanguageChanged(const ListValue* args) { | 143 void NetworkScreenHandler::HandleOnLanguageChanged(const std::string& locale) { |
| 144 DCHECK(args->GetSize() == 1); | |
| 145 std::string locale; | |
| 146 if (!args->GetString(0, &locale)) | |
| 147 NOTREACHED(); | |
| 148 | |
| 149 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 144 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 150 if (app_locale == locale) | 145 if (app_locale == locale) |
| 151 return; | 146 return; |
| 152 | 147 |
| 153 // TODO(altimofeev): make language change async. | 148 // TODO(altimofeev): make language change async. |
| 154 LanguageSwitchMenu::SwitchLanguageAndEnableKeyboardLayouts(locale); | 149 LanguageSwitchMenu::SwitchLanguageAndEnableKeyboardLayouts(locale); |
| 155 | 150 |
| 156 DictionaryValue localized_strings; | 151 DictionaryValue localized_strings; |
| 157 static_cast<OobeUI*>(web_ui()->GetController())->GetLocalizedStrings( | 152 static_cast<OobeUI*>(web_ui()->GetController())->GetLocalizedStrings( |
| 158 &localized_strings); | 153 &localized_strings); |
| 159 CallJS("cr.ui.Oobe.reloadContent", localized_strings); | 154 CallJS("cr.ui.Oobe.reloadContent", localized_strings); |
| 160 // Buttons are recreated, updated "Continue" button state. | 155 // Buttons are recreated, updated "Continue" button state. |
| 161 EnableContinue(is_continue_enabled_); | 156 EnableContinue(is_continue_enabled_); |
| 162 } | 157 } |
| 163 | 158 |
| 164 void NetworkScreenHandler::HandleOnInputMethodChanged(const ListValue* args) { | 159 void NetworkScreenHandler::HandleOnInputMethodChanged(const std::string& id) { |
| 165 DCHECK(args->GetSize() == 1); | |
| 166 std::string id; | |
| 167 if (!args->GetString(0, &id)) | |
| 168 NOTREACHED(); | |
| 169 input_method::GetInputMethodManager()->ChangeInputMethod(id); | 160 input_method::GetInputMethodManager()->ChangeInputMethod(id); |
| 170 } | 161 } |
| 171 | 162 |
| 172 ListValue* NetworkScreenHandler::GetLanguageList() { | 163 ListValue* NetworkScreenHandler::GetLanguageList() { |
| 173 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 164 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 174 input_method::InputMethodManager* manager = | 165 input_method::InputMethodManager* manager = |
| 175 input_method::GetInputMethodManager(); | 166 input_method::GetInputMethodManager(); |
| 176 // GetSupportedInputMethods() never returns NULL. | 167 // GetSupportedInputMethods() never returns NULL. |
| 177 scoped_ptr<input_method::InputMethodDescriptors> descriptors( | 168 scoped_ptr<input_method::InputMethodDescriptors> descriptors( |
| 178 manager->GetSupportedInputMethods()); | 169 manager->GetSupportedInputMethods()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 "title", | 209 "title", |
| 219 util->GetInputMethodLongName(input_methods->at(i))); | 210 util->GetInputMethodLongName(input_methods->at(i))); |
| 220 input_method->SetBoolean("selected", | 211 input_method->SetBoolean("selected", |
| 221 ime_id == current_input_method_id); | 212 ime_id == current_input_method_id); |
| 222 input_methods_list->Append(input_method); | 213 input_methods_list->Append(input_method); |
| 223 } | 214 } |
| 224 return input_methods_list; | 215 return input_methods_list; |
| 225 } | 216 } |
| 226 | 217 |
| 227 } // namespace chromeos | 218 } // namespace chromeos |
| OLD | NEW |