 Chromium Code Reviews
 Chromium Code Reviews Issue 148093003:
  xkb:us::eng is now always in list of available input methods at OOBE.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 148093003:
  xkb:us::eng is now always in list of available input methods at OOBE.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" | 
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" | 
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" | 
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 | 267 | 
| 268 // static | 268 // static | 
| 269 base::ListValue* NetworkScreenHandler::GetInputMethods() { | 269 base::ListValue* NetworkScreenHandler::GetInputMethods() { | 
| 270 base::ListValue* input_methods_list = new base::ListValue; | 270 base::ListValue* input_methods_list = new base::ListValue; | 
| 271 input_method::InputMethodManager* manager = | 271 input_method::InputMethodManager* manager = | 
| 272 input_method::InputMethodManager::Get(); | 272 input_method::InputMethodManager::Get(); | 
| 273 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 273 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 
| 274 scoped_ptr<input_method::InputMethodDescriptors> input_methods( | 274 scoped_ptr<input_method::InputMethodDescriptors> input_methods( | 
| 275 manager->GetActiveInputMethods()); | 275 manager->GetActiveInputMethods()); | 
| 276 std::string current_input_method_id = manager->GetCurrentInputMethod().id(); | 276 std::string current_input_method_id = manager->GetCurrentInputMethod().id(); | 
| 277 bool default_us_layout_added = false; | |
| 278 static const std::string kUSlayout("xkb:us::eng"); // Global default | |
| 
Nikita (slow)
2014/01/27 15:22:10
nit: Please extract constant.
 | |
| 277 for (size_t i = 0; i < input_methods->size(); ++i) { | 279 for (size_t i = 0; i < input_methods->size(); ++i) { | 
| 278 const std::string ime_id = input_methods->at(i).id(); | 280 const std::string ime_id = input_methods->at(i).id(); | 
| 281 | |
| 282 if (ime_id == kUSlayout) | |
| 283 default_us_layout_added = true; | |
| 284 | |
| 279 base::DictionaryValue* input_method = new base::DictionaryValue; | 285 base::DictionaryValue* input_method = new base::DictionaryValue; | 
| 280 input_method->SetString("value", ime_id); | 286 input_method->SetString("value", ime_id); | 
| 281 input_method->SetString( | 287 input_method->SetString( | 
| 282 "title", | 288 "title", | 
| 283 util->GetInputMethodLongName(input_methods->at(i))); | 289 util->GetInputMethodLongName(input_methods->at(i))); | 
| 284 input_method->SetBoolean("selected", | 290 input_method->SetBoolean("selected", | 
| 285 ime_id == current_input_method_id); | 291 ime_id == current_input_method_id); | 
| 286 input_methods_list->Append(input_method); | 292 input_methods_list->Append(input_method); | 
| 287 } | 293 } | 
| 294 if (!default_us_layout_added) { | |
| 295 const input_method::InputMethodDescriptor* us_eng_descriptor = | |
| 296 util->GetInputMethodDescriptorFromId(kUSlayout); | |
| 297 DCHECK(us_eng_descriptor != NULL); | |
| 298 base::DictionaryValue* input_method = new base::DictionaryValue; | |
| 299 input_method->SetString("value", kUSlayout); | |
| 300 input_method->SetString("title", | |
| 301 util->GetInputMethodLongName(*us_eng_descriptor)); | |
| 302 input_methods_list->Append(input_method); | |
| 303 } | |
| 288 return input_methods_list; | 304 return input_methods_list; | 
| 289 } | 305 } | 
| 290 | 306 | 
| 291 // static | 307 // static | 
| 292 base::ListValue* NetworkScreenHandler::GetTimezoneList() { | 308 base::ListValue* NetworkScreenHandler::GetTimezoneList() { | 
| 293 std::string current_timezone_id; | 309 std::string current_timezone_id; | 
| 294 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 310 CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); | 
| 295 | 311 | 
| 296 scoped_ptr<base::ListValue> timezone_list(new base::ListValue); | 312 scoped_ptr<base::ListValue> timezone_list(new base::ListValue); | 
| 297 scoped_ptr<base::ListValue> timezones = system::GetTimezoneList().Pass(); | 313 scoped_ptr<base::ListValue> timezones = system::GetTimezoneList().Pass(); | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 310 timezone_option->SetString("value", timezone_id); | 326 timezone_option->SetString("value", timezone_id); | 
| 311 timezone_option->SetString("title", timezone_name); | 327 timezone_option->SetString("title", timezone_name); | 
| 312 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 328 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 
| 313 timezone_list->Append(timezone_option.release()); | 329 timezone_list->Append(timezone_option.release()); | 
| 314 } | 330 } | 
| 315 | 331 | 
| 316 return timezone_list.release(); | 332 return timezone_list.release(); | 
| 317 } | 333 } | 
| 318 | 334 | 
| 319 } // namespace chromeos | 335 } // namespace chromeos | 
| OLD | NEW |