| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/l10n_util.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 363 } |
| 364 | 364 |
| 365 language_info->SetString("value", value); | 365 language_info->SetString("value", value); |
| 366 language_info->SetString("title", display_name); | 366 language_info->SetString("title", display_name); |
| 367 if (value == selected) | 367 if (value == selected) |
| 368 language_info->SetBoolean("selected", true); | 368 language_info->SetBoolean("selected", true); |
| 369 } | 369 } |
| 370 return languages_list.Pass(); | 370 return languages_list.Pass(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 std::string FindMostRelevantLocale( |
| 374 const std::vector<std::string>* most_relevant_language_codes, |
| 375 const base::ListValue& available_locales, |
| 376 const std::string& fallback_locale) { |
| 377 if (!most_relevant_language_codes) |
| 378 return fallback_locale; |
| 379 |
| 380 for (std::vector<std::string>::const_iterator most_relevant_it = |
| 381 most_relevant_language_codes->begin(); |
| 382 most_relevant_it != most_relevant_language_codes->end(); |
| 383 ++most_relevant_it) { |
| 384 base::StringValue most_relevant_locale(*most_relevant_it); |
| 385 for (base::ListValue::const_iterator available_it = |
| 386 available_locales.begin(); |
| 387 available_it != available_locales.end(); ++available_it) { |
| 388 if (most_relevant_locale.Equals(*available_it)) |
| 389 return *most_relevant_it; |
| 390 } |
| 391 } |
| 392 |
| 393 return fallback_locale; |
| 394 } |
| 395 |
| 373 scoped_ptr<base::ListValue> GetAcceptLanguageList() { | 396 scoped_ptr<base::ListValue> GetAcceptLanguageList() { |
| 374 // Collect the language codes from the supported accept-languages. | 397 // Collect the language codes from the supported accept-languages. |
| 375 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 398 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 376 std::vector<std::string> accept_language_codes; | 399 std::vector<std::string> accept_language_codes; |
| 377 l10n_util::GetAcceptLanguagesForLocale(app_locale, &accept_language_codes); | 400 l10n_util::GetAcceptLanguagesForLocale(app_locale, &accept_language_codes); |
| 378 return GetLanguageList( | 401 return GetLanguageList( |
| 379 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), | 402 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), |
| 380 accept_language_codes, | 403 accept_language_codes, |
| 381 StartupCustomizationDocument::GetInstance()->configured_locales(), | 404 StartupCustomizationDocument::GetInstance()->configured_locales(), |
| 382 false); | 405 false); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 494 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
| 472 const input_method::InputMethodDescriptor current_input_method = | 495 const input_method::InputMethodDescriptor current_input_method = |
| 473 input_method::InputMethodManager::Get() | 496 input_method::InputMethodManager::Get() |
| 474 ->GetActiveIMEState() | 497 ->GetActiveIMEState() |
| 475 ->GetCurrentInputMethod(); | 498 ->GetCurrentInputMethod(); |
| 476 return CreateInputMethodsEntry(current_input_method, | 499 return CreateInputMethodsEntry(current_input_method, |
| 477 current_input_method.id()); | 500 current_input_method.id()); |
| 478 } | 501 } |
| 479 | 502 |
| 480 } // namespace chromeos | 503 } // namespace chromeos |
| OLD | NEW |