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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // 3) This is the bootstrapping process for a "Slave" device. The locale & | 239 // 3) This is the bootstrapping process for a "Slave" device. The locale & |
240 // input of the "Slave" device is set up by a "Master" device. In this case we | 240 // input of the "Slave" device is set up by a "Master" device. In this case we |
241 // don't want EnableLoginLayout() to reset the input method to the hardware | 241 // don't want EnableLoginLayout() to reset the input method to the hardware |
242 // default method. | 242 // default method. |
243 const bool is_slave = g_browser_process->local_state()->GetBoolean( | 243 const bool is_slave = g_browser_process->local_state()->GetBoolean( |
244 prefs::kOobeControllerDetected); | 244 prefs::kOobeControllerDetected); |
245 | 245 |
246 const bool enable_layouts = | 246 const bool enable_layouts = |
247 !user_manager::UserManager::Get()->IsUserLoggedIn() && !is_slave; | 247 !user_manager::UserManager::Get()->IsUserLoggedIn() && !is_slave; |
248 | 248 |
249 dict->Set("languageList", language_list.release()); | 249 dict->Set("languageList", std::move(language_list)); |
250 dict->Set( | 250 dict->Set("inputMethodsList", |
251 "inputMethodsList", | 251 GetAndActivateLoginKeyboardLayouts( |
252 GetAndActivateLoginKeyboardLayouts( | 252 application_locale, selected_input_method, enable_layouts)); |
253 application_locale, selected_input_method, enable_layouts).release()); | |
254 dict->Set("timezoneList", GetTimezoneList()); | 253 dict->Set("timezoneList", GetTimezoneList()); |
255 } | 254 } |
256 | 255 |
257 void NetworkScreenHandler::Initialize() { | 256 void NetworkScreenHandler::Initialize() { |
258 if (show_on_init_) { | 257 if (show_on_init_) { |
259 show_on_init_ = false; | 258 show_on_init_ = false; |
260 Show(); | 259 Show(); |
261 } | 260 } |
262 | 261 |
263 // Reload localized strings if they are already resolved. | 262 // Reload localized strings if they are already resolved. |
264 if (screen_ && screen_->language_list()) | 263 if (screen_ && screen_->language_list()) |
265 ReloadLocalizedContent(); | 264 ReloadLocalizedContent(); |
266 } | 265 } |
267 | 266 |
268 // NetworkScreenHandler, private: ---------------------------------------------- | 267 // NetworkScreenHandler, private: ---------------------------------------------- |
269 | 268 |
270 // static | 269 // static |
271 base::ListValue* NetworkScreenHandler::GetTimezoneList() { | 270 std::unique_ptr<base::ListValue> NetworkScreenHandler::GetTimezoneList() { |
272 std::string current_timezone_id; | 271 std::string current_timezone_id; |
273 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 272 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); |
274 | 273 |
275 std::unique_ptr<base::ListValue> timezone_list(new base::ListValue); | 274 std::unique_ptr<base::ListValue> timezone_list(new base::ListValue); |
276 std::unique_ptr<base::ListValue> timezones = system::GetTimezoneList(); | 275 std::unique_ptr<base::ListValue> timezones = system::GetTimezoneList(); |
277 for (size_t i = 0; i < timezones->GetSize(); ++i) { | 276 for (size_t i = 0; i < timezones->GetSize(); ++i) { |
278 const base::ListValue* timezone = NULL; | 277 const base::ListValue* timezone = NULL; |
279 CHECK(timezones->GetList(i, &timezone)); | 278 CHECK(timezones->GetList(i, &timezone)); |
280 | 279 |
281 std::string timezone_id; | 280 std::string timezone_id; |
282 CHECK(timezone->GetString(0, &timezone_id)); | 281 CHECK(timezone->GetString(0, &timezone_id)); |
283 | 282 |
284 std::string timezone_name; | 283 std::string timezone_name; |
285 CHECK(timezone->GetString(1, &timezone_name)); | 284 CHECK(timezone->GetString(1, &timezone_name)); |
286 | 285 |
287 std::unique_ptr<base::DictionaryValue> timezone_option( | 286 std::unique_ptr<base::DictionaryValue> timezone_option( |
288 new base::DictionaryValue); | 287 new base::DictionaryValue); |
289 timezone_option->SetString("value", timezone_id); | 288 timezone_option->SetString("value", timezone_id); |
290 timezone_option->SetString("title", timezone_name); | 289 timezone_option->SetString("title", timezone_name); |
291 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 290 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); |
292 timezone_list->Append(std::move(timezone_option)); | 291 timezone_list->Append(std::move(timezone_option)); |
293 } | 292 } |
294 | 293 |
295 return timezone_list.release(); | 294 return timezone_list; |
296 } | 295 } |
297 | 296 |
298 } // namespace chromeos | 297 } // namespace chromeos |
OLD | NEW |