| 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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 &command_line); | 724 &command_line); |
| 725 | 725 |
| 726 RestartChrome(cmd_line_str); | 726 RestartChrome(cmd_line_str); |
| 727 } | 727 } |
| 728 | 728 |
| 729 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { | 729 void LoginUtilsImpl::SetFirstLoginPrefs(PrefService* prefs) { |
| 730 VLOG(1) << "Setting first login prefs"; | 730 VLOG(1) << "Setting first login prefs"; |
| 731 BootTimesLoader* btl = BootTimesLoader::Get(); | 731 BootTimesLoader* btl = BootTimesLoader::Get(); |
| 732 std::string locale = g_browser_process->GetApplicationLocale(); | 732 std::string locale = g_browser_process->GetApplicationLocale(); |
| 733 | 733 |
| 734 // First, we'll set kLanguagePreloadEngines. | 734 // First, we'll set kLanguagePreloadEnginesLocal. |
| 735 input_method::InputMethodManager* manager = | 735 input_method::InputMethodManager* manager = |
| 736 input_method::InputMethodManager::Get(); | 736 input_method::InputMethodManager::Get(); |
| 737 std::vector<std::string> input_method_ids; | 737 std::vector<std::string> input_method_ids; |
| 738 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( | 738 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( |
| 739 locale, manager->GetCurrentInputMethod(), &input_method_ids); | 739 locale, manager->GetCurrentInputMethod(), &input_method_ids); |
| 740 // Save the input methods in the user's preferences. | 740 // Save the input methods in the user's preferences. |
| 741 StringPrefMember language_preload_engines; | 741 StringPrefMember language_preload_engines_local; |
| 742 language_preload_engines.Init(prefs::kLanguagePreloadEngines, | 742 language_preload_engines_local.Init(prefs::kLanguagePreloadEnginesLocal, |
| 743 prefs); | 743 prefs); |
| 744 language_preload_engines.SetValue(JoinString(input_method_ids, ',')); | 744 language_preload_engines_local.SetValue(JoinString(input_method_ids, ',')); |
| 745 btl->AddLoginTimeMarker("IMEStarted", false); | 745 btl->AddLoginTimeMarker("IMEStarted", false); |
| 746 | 746 |
| 747 // Second, we'll set kLanguagePreferredLanguages. | 747 // Second, we'll set kLanguagePreferredLanguagesLocal. |
| 748 std::vector<std::string> language_codes; | 748 std::vector<std::string> language_codes; |
| 749 // The current locale should be on the top. | 749 // The current locale should be on the top. |
| 750 language_codes.push_back(locale); | 750 language_codes.push_back(locale); |
| 751 | 751 |
| 752 // Add input method IDs based on the input methods, as there may be | 752 // Add input method IDs based on the input methods, as there may be |
| 753 // input methods that are unrelated to the current locale. Example: the | 753 // input methods that are unrelated to the current locale. Example: the |
| 754 // hardware keyboard layout xkb:us::eng is used for logging in, but the | 754 // hardware keyboard layout xkb:us::eng is used for logging in, but the |
| 755 // UI language is set to French. In this case, we should set "fr,en" | 755 // UI language is set to French. In this case, we should set "fr,en" |
| 756 // to the preferred languages preference. | 756 // to the preferred languages preference. |
| 757 std::vector<std::string> candidates; | 757 std::vector<std::string> candidates; |
| 758 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( | 758 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( |
| 759 input_method_ids, &candidates); | 759 input_method_ids, &candidates); |
| 760 for (size_t i = 0; i < candidates.size(); ++i) { | 760 for (size_t i = 0; i < candidates.size(); ++i) { |
| 761 const std::string& candidate = candidates[i]; | 761 const std::string& candidate = candidates[i]; |
| 762 // Skip if it's already in language_codes. | 762 // Skip if it's already in language_codes. |
| 763 if (std::count(language_codes.begin(), language_codes.end(), | 763 if (std::count(language_codes.begin(), language_codes.end(), |
| 764 candidate) == 0) { | 764 candidate) == 0) { |
| 765 language_codes.push_back(candidate); | 765 language_codes.push_back(candidate); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 // Save the preferred languages in the user's preferences. | 768 // Save the preferred languages in the user's preferences. |
| 769 StringPrefMember language_preferred_languages; | 769 StringPrefMember language_preferred_languages_local; |
| 770 language_preferred_languages.Init(prefs::kLanguagePreferredLanguages, | 770 language_preferred_languages_local.Init( |
| 771 prefs); | 771 prefs::kLanguagePreferredLanguagesLocal, prefs); |
| 772 language_preferred_languages.SetValue(JoinString(language_codes, ',')); | 772 language_preferred_languages_local.SetValue(JoinString(language_codes, ',')); |
| 773 } | 773 } |
| 774 | 774 |
| 775 scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator( | 775 scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator( |
| 776 LoginStatusConsumer* consumer) { | 776 LoginStatusConsumer* consumer) { |
| 777 // Screen locker needs new Authenticator instance each time. | 777 // Screen locker needs new Authenticator instance each time. |
| 778 if (ScreenLocker::default_screen_locker()) { | 778 if (ScreenLocker::default_screen_locker()) { |
| 779 if (authenticator_.get()) | 779 if (authenticator_.get()) |
| 780 authenticator_->SetConsumer(NULL); | 780 authenticator_->SetConsumer(NULL); |
| 781 authenticator_ = NULL; | 781 authenticator_ = NULL; |
| 782 } | 782 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 CrosSettings* cros_settings = CrosSettings::Get(); | 953 CrosSettings* cros_settings = CrosSettings::Get(); |
| 954 bool allow_new_user = false; | 954 bool allow_new_user = false; |
| 955 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 955 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 956 if (allow_new_user) | 956 if (allow_new_user) |
| 957 return true; | 957 return true; |
| 958 return cros_settings->FindEmailInList( | 958 return cros_settings->FindEmailInList( |
| 959 kAccountsPrefUsers, username, wildcard_match); | 959 kAccountsPrefUsers, username, wildcard_match); |
| 960 } | 960 } |
| 961 | 961 |
| 962 } // namespace chromeos | 962 } // namespace chromeos |
| OLD | NEW |