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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 case Profile::CREATE_STATUS_INITIALIZED: | 543 case Profile::CREATE_STATUS_INITIALIZED: |
544 break; | 544 break; |
545 case Profile::CREATE_STATUS_CREATED: { | 545 case Profile::CREATE_STATUS_CREATED: { |
546 if (UserManager::Get()->IsCurrentUserNew()) | 546 if (UserManager::Get()->IsCurrentUserNew()) |
547 SetFirstLoginPrefs(user_profile->GetPrefs()); | 547 SetFirstLoginPrefs(user_profile->GetPrefs()); |
548 // Make sure that the google service username is properly set (we do this | 548 // Make sure that the google service username is properly set (we do this |
549 // on every sign in, not just the first login, to deal with existing | 549 // on every sign in, not just the first login, to deal with existing |
550 // profiles that might not have it set yet). | 550 // profiles that might not have it set yet). |
551 StringPrefMember google_services_username; | 551 StringPrefMember google_services_username; |
552 google_services_username.Init(prefs::kGoogleServicesUsername, | 552 google_services_username.Init(prefs::kGoogleServicesUsername, |
553 user_profile->GetPrefs(), NULL); | 553 user_profile->GetPrefs()); |
554 google_services_username.SetValue( | 554 google_services_username.SetValue( |
555 UserManager::Get()->GetLoggedInUser()->display_email()); | 555 UserManager::Get()->GetLoggedInUser()->display_email()); |
556 // Make sure we flip every profile to not share proxies if the user hasn't | 556 // Make sure we flip every profile to not share proxies if the user hasn't |
557 // specified so explicitly. | 557 // specified so explicitly. |
558 const PrefService::Preference* use_shared_proxies_pref = | 558 const PrefService::Preference* use_shared_proxies_pref = |
559 user_profile->GetPrefs()->FindPreference(prefs::kUseSharedProxies); | 559 user_profile->GetPrefs()->FindPreference(prefs::kUseSharedProxies); |
560 if (use_shared_proxies_pref->IsDefaultValue()) | 560 if (use_shared_proxies_pref->IsDefaultValue()) |
561 user_profile->GetPrefs()->SetBoolean(prefs::kUseSharedProxies, false); | 561 user_profile->GetPrefs()->SetBoolean(prefs::kUseSharedProxies, false); |
562 policy::NetworkConfigurationUpdater* network_configuration_updater = | 562 policy::NetworkConfigurationUpdater* network_configuration_updater = |
563 g_browser_process->browser_policy_connector()-> | 563 g_browser_process->browser_policy_connector()-> |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 867 |
868 // First, we'll set kLanguagePreloadEngines. | 868 // First, we'll set kLanguagePreloadEngines. |
869 input_method::InputMethodManager* manager = | 869 input_method::InputMethodManager* manager = |
870 input_method::InputMethodManager::GetInstance(); | 870 input_method::InputMethodManager::GetInstance(); |
871 std::vector<std::string> input_method_ids; | 871 std::vector<std::string> input_method_ids; |
872 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( | 872 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( |
873 locale, manager->GetCurrentInputMethod(), &input_method_ids); | 873 locale, manager->GetCurrentInputMethod(), &input_method_ids); |
874 // Save the input methods in the user's preferences. | 874 // Save the input methods in the user's preferences. |
875 StringPrefMember language_preload_engines; | 875 StringPrefMember language_preload_engines; |
876 language_preload_engines.Init(prefs::kLanguagePreloadEngines, | 876 language_preload_engines.Init(prefs::kLanguagePreloadEngines, |
877 prefs, NULL); | 877 prefs); |
878 language_preload_engines.SetValue(JoinString(input_method_ids, ',')); | 878 language_preload_engines.SetValue(JoinString(input_method_ids, ',')); |
879 btl->AddLoginTimeMarker("IMEStarted", false); | 879 btl->AddLoginTimeMarker("IMEStarted", false); |
880 | 880 |
881 // Second, we'll set kLanguagePreferredLanguages. | 881 // Second, we'll set kLanguagePreferredLanguages. |
882 std::vector<std::string> language_codes; | 882 std::vector<std::string> language_codes; |
883 // The current locale should be on the top. | 883 // The current locale should be on the top. |
884 language_codes.push_back(locale); | 884 language_codes.push_back(locale); |
885 | 885 |
886 // Add input method IDs based on the input methods, as there may be | 886 // Add input method IDs based on the input methods, as there may be |
887 // input methods that are unrelated to the current locale. Example: the | 887 // input methods that are unrelated to the current locale. Example: the |
888 // hardware keyboard layout xkb:us::eng is used for logging in, but the | 888 // hardware keyboard layout xkb:us::eng is used for logging in, but the |
889 // UI language is set to French. In this case, we should set "fr,en" | 889 // UI language is set to French. In this case, we should set "fr,en" |
890 // to the preferred languages preference. | 890 // to the preferred languages preference. |
891 std::vector<std::string> candidates; | 891 std::vector<std::string> candidates; |
892 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( | 892 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( |
893 input_method_ids, &candidates); | 893 input_method_ids, &candidates); |
894 for (size_t i = 0; i < candidates.size(); ++i) { | 894 for (size_t i = 0; i < candidates.size(); ++i) { |
895 const std::string& candidate = candidates[i]; | 895 const std::string& candidate = candidates[i]; |
896 // Skip if it's already in language_codes. | 896 // Skip if it's already in language_codes. |
897 if (std::count(language_codes.begin(), language_codes.end(), | 897 if (std::count(language_codes.begin(), language_codes.end(), |
898 candidate) == 0) { | 898 candidate) == 0) { |
899 language_codes.push_back(candidate); | 899 language_codes.push_back(candidate); |
900 } | 900 } |
901 } | 901 } |
902 // Save the preferred languages in the user's preferences. | 902 // Save the preferred languages in the user's preferences. |
903 StringPrefMember language_preferred_languages; | 903 StringPrefMember language_preferred_languages; |
904 language_preferred_languages.Init(prefs::kLanguagePreferredLanguages, | 904 language_preferred_languages.Init(prefs::kLanguagePreferredLanguages, |
905 prefs, NULL); | 905 prefs); |
906 language_preferred_languages.SetValue(JoinString(language_codes, ',')); | 906 language_preferred_languages.SetValue(JoinString(language_codes, ',')); |
907 } | 907 } |
908 | 908 |
909 scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator( | 909 scoped_refptr<Authenticator> LoginUtilsImpl::CreateAuthenticator( |
910 LoginStatusConsumer* consumer) { | 910 LoginStatusConsumer* consumer) { |
911 // Screen locker needs new Authenticator instance each time. | 911 // Screen locker needs new Authenticator instance each time. |
912 if (ScreenLocker::default_screen_locker()) { | 912 if (ScreenLocker::default_screen_locker()) { |
913 if (authenticator_) | 913 if (authenticator_) |
914 authenticator_->SetConsumer(NULL); | 914 authenticator_->SetConsumer(NULL); |
915 authenticator_ = NULL; | 915 authenticator_ = NULL; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1250 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1251 CrosSettings* cros_settings = CrosSettings::Get(); | 1251 CrosSettings* cros_settings = CrosSettings::Get(); |
1252 bool allow_new_user = false; | 1252 bool allow_new_user = false; |
1253 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1253 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1254 if (allow_new_user) | 1254 if (allow_new_user) |
1255 return true; | 1255 return true; |
1256 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1256 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1257 } | 1257 } |
1258 | 1258 |
1259 } // namespace chromeos | 1259 } // namespace chromeos |
OLD | NEW |