Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 if (UserManager::Get()->current_user_is_new()) | 782 if (UserManager::Get()->current_user_is_new()) |
| 783 SetFirstLoginPrefs(user_profile->GetPrefs()); | 783 SetFirstLoginPrefs(user_profile->GetPrefs()); |
| 784 // Make sure that the google service username is properly set (we do this | 784 // Make sure that the google service username is properly set (we do this |
| 785 // on every sign in, not just the first login, to deal with existing | 785 // on every sign in, not just the first login, to deal with existing |
| 786 // profiles that might not have it set yet). | 786 // profiles that might not have it set yet). |
| 787 StringPrefMember google_services_username; | 787 StringPrefMember google_services_username; |
| 788 google_services_username.Init(prefs::kGoogleServicesUsername, | 788 google_services_username.Init(prefs::kGoogleServicesUsername, |
| 789 user_profile->GetPrefs(), NULL); | 789 user_profile->GetPrefs(), NULL); |
| 790 google_services_username.SetValue( | 790 google_services_username.SetValue( |
| 791 UserManager::Get()->logged_in_user().display_email()); | 791 UserManager::Get()->logged_in_user().display_email()); |
| 792 // Make sure we flip every profile to not share proxies if the user hasn't | |
|
Nikita (slow)
2012/02/01 09:42:34
Seems that if Chrome crashes inside user session,
pastarmovj
2012/02/01 09:57:31
Yes, theoretically if Chrome crashes right after t
| |
| 793 // specified so explicitly. | |
| 794 const PrefService::Preference* use_shared_proxies_pref = | |
| 795 user_profile->GetPrefs()->FindPreference(prefs::kUseSharedProxies); | |
| 796 if (use_shared_proxies_pref->IsDefaultValue()) | |
| 797 user_profile->GetPrefs()->SetBoolean(prefs::kUseSharedProxies, false); | |
| 792 RespectLocalePreference(user_profile); | 798 RespectLocalePreference(user_profile); |
| 793 return; | 799 return; |
| 794 } | 800 } |
| 795 case Profile::CREATE_STATUS_FAIL: | 801 case Profile::CREATE_STATUS_FAIL: |
| 796 default: | 802 default: |
| 797 NOTREACHED(); | 803 NOTREACHED(); |
| 798 return; | 804 return; |
| 799 } | 805 } |
| 800 | 806 |
| 801 BootTimesLoader* btl = BootTimesLoader::Get(); | 807 BootTimesLoader* btl = BootTimesLoader::Get(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 oauth_fetcher_->SetAutoFetchLimit(GaiaOAuthFetcher::OAUTH1_ALL_ACCESS_TOKEN); | 890 oauth_fetcher_->SetAutoFetchLimit(GaiaOAuthFetcher::OAUTH1_ALL_ACCESS_TOKEN); |
| 885 oauth_fetcher_->StartGetOAuthTokenRequest(); | 891 oauth_fetcher_->StartGetOAuthTokenRequest(); |
| 886 } | 892 } |
| 887 | 893 |
| 888 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { | 894 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { |
| 889 std::string oauth1_token; | 895 std::string oauth1_token; |
| 890 std::string oauth1_secret; | 896 std::string oauth1_secret; |
| 891 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) | 897 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) |
| 892 return; | 898 return; |
| 893 | 899 |
| 894 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), oauth1_token, | 900 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), |
| 895 oauth1_secret); | 901 oauth1_token, oauth1_secret); |
| 896 } | 902 } |
| 897 | 903 |
| 898 void LoginUtilsImpl::StartSignedInServices( | 904 void LoginUtilsImpl::StartSignedInServices( |
| 899 Profile* user_profile, | 905 Profile* user_profile, |
| 900 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 906 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| 901 // Fetch/Create the SigninManager - this will cause the TokenService to load | 907 // Fetch/Create the SigninManager - this will cause the TokenService to load |
| 902 // tokens for the currently signed-in user if the SigninManager hasn't already | 908 // tokens for the currently signed-in user if the SigninManager hasn't already |
| 903 // been initialized. | 909 // been initialized. |
| 904 SigninManager* signin = SigninManagerFactory::GetForProfile(user_profile); | 910 SigninManager* signin = SigninManagerFactory::GetForProfile(user_profile); |
| 905 DCHECK(signin); | 911 DCHECK(signin); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1273 oauth_login_verifier_->StartOAuthVerification(); | 1279 oauth_login_verifier_->StartOAuthVerification(); |
| 1274 } | 1280 } |
| 1275 | 1281 |
| 1276 | 1282 |
| 1277 void LoginUtilsImpl::FetchPolicyToken(Profile* offrecord_profile, | 1283 void LoginUtilsImpl::FetchPolicyToken(Profile* offrecord_profile, |
| 1278 const std::string& token, | 1284 const std::string& token, |
| 1279 const std::string& secret) { | 1285 const std::string& secret) { |
| 1280 // Fetch dm service token now, if it hasn't been fetched yet. | 1286 // Fetch dm service token now, if it hasn't been fetched yet. |
| 1281 if (!policy_oauth_fetcher_.get() || policy_oauth_fetcher_->failed()) { | 1287 if (!policy_oauth_fetcher_.get() || policy_oauth_fetcher_->failed()) { |
| 1282 // Trigger oauth token fetch for user policy. | 1288 // Trigger oauth token fetch for user policy. |
| 1283 policy_oauth_fetcher_.reset(new PolicyOAuthFetcher(offrecord_profile, | 1289 policy_oauth_fetcher_.reset( |
| 1284 token, | 1290 new PolicyOAuthFetcher(authenticator_->authentication_profile(), |
| 1285 secret)); | 1291 token, secret)); |
| 1286 policy_oauth_fetcher_->Start(); | 1292 policy_oauth_fetcher_->Start(); |
| 1287 } | 1293 } |
| 1288 | 1294 |
| 1289 // TODO(zelidrag): We should add initialization of other services somewhere | 1295 // TODO(zelidrag): We should add initialization of other services somewhere |
| 1290 // here as well. This could be handled with TokenService class once it is | 1296 // here as well. This could be handled with TokenService class once it is |
| 1291 // ready to handle OAuth tokens. | 1297 // ready to handle OAuth tokens. |
| 1292 | 1298 |
| 1293 // We don't need authenticator instance any more, reset it so that | 1299 // We don't need authenticator instance any more, reset it so that |
| 1294 // ScreenLocker would create a separate instance. | 1300 // ScreenLocker would create a separate instance. |
| 1295 // TODO(nkostylev): There's a potential race if SL would be created before | 1301 // TODO(nkostylev): There's a potential race if SL would be created before |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1385 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 1380 CrosSettings* cros_settings = CrosSettings::Get(); | 1386 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1381 bool allow_new_user = false; | 1387 bool allow_new_user = false; |
| 1382 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1388 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1383 if (allow_new_user) | 1389 if (allow_new_user) |
| 1384 return true; | 1390 return true; |
| 1385 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1391 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 1386 } | 1392 } |
| 1387 | 1393 |
| 1388 } // namespace chromeos | 1394 } // namespace chromeos |
| OLD | NEW |