Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 12704002: Support for auth code based authentication flow for both app and web UI driven flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/chromeos/chromeos_version.h" 10 #include "base/chromeos/chromeos_version.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/prefs/pref_member.h" 20 #include "base/prefs/pref_member.h"
21 #include "base/prefs/pref_registry_simple.h" 21 #include "base/prefs/pref_registry_simple.h"
22 #include "base/prefs/pref_service.h" 22 #include "base/prefs/pref_service.h"
23 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/synchronization/lock.h" 24 #include "base/synchronization/lock.h"
25 #include "base/task_runner_util.h" 25 #include "base/task_runner_util.h"
26 #include "base/threading/worker_pool.h" 26 #include "base/threading/worker_pool.h"
27 #include "base/time.h" 27 #include "base/time.h"
28 #include "base/utf_string_conversions.h" 28 #include "base/utf_string_conversions.h"
29 #include "chrome/browser/about_flags.h" 29 #include "chrome/browser/about_flags.h"
30 #include "chrome/browser/app_mode/app_mode_utils.h"
30 #include "chrome/browser/browser_process.h" 31 #include "chrome/browser/browser_process.h"
31 #include "chrome/browser/browser_shutdown.h" 32 #include "chrome/browser/browser_shutdown.h"
32 #include "chrome/browser/chromeos/boot_times_loader.h" 33 #include "chrome/browser/chromeos/boot_times_loader.h"
33 #include "chrome/browser/chromeos/cros/cros_library.h" 34 #include "chrome/browser/chromeos/cros/cros_library.h"
34 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 35 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
35 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 36 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
36 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 37 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
37 #include "chrome/browser/chromeos/input_method/input_method_util.h" 38 #include "chrome/browser/chromeos/input_method/input_method_util.h"
38 #include "chrome/browser/chromeos/login/chrome_restart_request.h" 39 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
39 #include "chrome/browser/chromeos/login/language_switch_menu.h" 40 #include "chrome/browser/chromeos/login/language_switch_menu.h"
(...skipping 22 matching lines...) Expand all
62 #include "chrome/browser/rlz/rlz.h" 63 #include "chrome/browser/rlz/rlz.h"
63 #include "chrome/browser/signin/signin_manager.h" 64 #include "chrome/browser/signin/signin_manager.h"
64 #include "chrome/browser/signin/signin_manager_factory.h" 65 #include "chrome/browser/signin/signin_manager_factory.h"
65 #include "chrome/browser/signin/token_service.h" 66 #include "chrome/browser/signin/token_service.h"
66 #include "chrome/browser/signin/token_service_factory.h" 67 #include "chrome/browser/signin/token_service_factory.h"
67 #include "chrome/browser/sync/profile_sync_service.h" 68 #include "chrome/browser/sync/profile_sync_service.h"
68 #include "chrome/browser/sync/profile_sync_service_factory.h" 69 #include "chrome/browser/sync/profile_sync_service_factory.h"
69 #include "chrome/browser/ui/startup/startup_browser_creator.h" 70 #include "chrome/browser/ui/startup/startup_browser_creator.h"
70 #include "chrome/common/chrome_notification_types.h" 71 #include "chrome/common/chrome_notification_types.h"
71 #include "chrome/common/chrome_paths.h" 72 #include "chrome/common/chrome_paths.h"
73 #include "chrome/common/chrome_switches.h"
72 #include "chrome/common/logging_chrome.h" 74 #include "chrome/common/logging_chrome.h"
73 #include "chrome/common/pref_names.h" 75 #include "chrome/common/pref_names.h"
74 #include "chromeos/dbus/dbus_thread_manager.h" 76 #include "chromeos/dbus/dbus_thread_manager.h"
75 #include "chromeos/dbus/session_manager_client.h" 77 #include "chromeos/dbus/session_manager_client.h"
76 #include "content/public/browser/browser_thread.h" 78 #include "content/public/browser/browser_thread.h"
77 #include "content/public/browser/notification_observer.h" 79 #include "content/public/browser/notification_observer.h"
78 #include "content/public/browser/notification_service.h" 80 #include "content/public/browser/notification_service.h"
79 #include "google_apis/gaia/gaia_auth_consumer.h" 81 #include "google_apis/gaia/gaia_auth_consumer.h"
80 #include "google_apis/gaia/gaia_constants.h" 82 #include "google_apis/gaia/gaia_constants.h"
81 #include "google_apis/gaia/gaia_urls.h" 83 #include "google_apis/gaia/gaia_urls.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 134 }
133 135
134 virtual ~LoginUtilsImpl() { 136 virtual ~LoginUtilsImpl() {
135 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 137 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
136 } 138 }
137 139
138 // LoginUtils implementation: 140 // LoginUtils implementation:
139 virtual void DoBrowserLaunch(Profile* profile, 141 virtual void DoBrowserLaunch(Profile* profile,
140 LoginDisplayHost* login_host) OVERRIDE; 142 LoginDisplayHost* login_host) OVERRIDE;
141 virtual void PrepareProfile( 143 virtual void PrepareProfile(
142 const std::string& username, 144 const UserCredentials& credentials,
143 const std::string& display_email, 145 const std::string& display_email,
144 const std::string& password,
145 bool using_oauth, 146 bool using_oauth,
146 bool has_cookies, 147 bool has_cookies,
147 LoginUtils::Delegate* delegate) OVERRIDE; 148 LoginUtils::Delegate* delegate) OVERRIDE;
148 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; 149 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE;
149 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; 150 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE;
150 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; 151 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE;
151 virtual scoped_refptr<Authenticator> CreateAuthenticator( 152 virtual scoped_refptr<Authenticator> CreateAuthenticator(
152 LoginStatusConsumer* consumer) OVERRIDE; 153 LoginStatusConsumer* consumer) OVERRIDE;
153 virtual void PrewarmAuthentication() OVERRIDE; 154 virtual void PrewarmAuthentication() OVERRIDE;
154 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; 155 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // Profile is created, extensions and promo resources are initialized. 191 // Profile is created, extensions and promo resources are initialized.
191 void UserProfileInitialized(Profile* user_profile); 192 void UserProfileInitialized(Profile* user_profile);
192 193
193 // Callback to resume profile creation after transferring auth data from 194 // Callback to resume profile creation after transferring auth data from
194 // the authentication profile. 195 // the authentication profile.
195 void CompleteProfileCreate(Profile* user_profile); 196 void CompleteProfileCreate(Profile* user_profile);
196 197
197 // Finalized profile preparation. 198 // Finalized profile preparation.
198 void FinalizePrepareProfile(Profile* user_profile); 199 void FinalizePrepareProfile(Profile* user_profile);
199 200
201 // Initializes member variables needed for session restore process via
202 // OAuthLoginManager.
203 void InitSessionRestoreStrategy();
204
200 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 205 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
201 void RestoreAuthSession(Profile* user_profile, 206 void RestoreAuthSession(Profile* user_profile,
202 bool restore_from_auth_cookies); 207 bool restore_from_auth_cookies);
203 208
204 // Callback when managed mode preferences have been applied. 209 // Callback when managed mode preferences have been applied.
205 void EnteredManagedMode(bool success); 210 void EnteredManagedMode(bool success);
206 211
207 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. 212 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
208 void InitRlz(Profile* user_profile, bool disabled); 213 void InitRlz(Profile* user_profile, bool disabled);
209 214
210 // Starts signing related services. Initiates TokenService token retrieval. 215 // Starts signing related services. Initiates TokenService token retrieval.
211 void StartSignedInServices(Profile* profile); 216 void StartSignedInServices(Profile* profile);
212 217
213 std::string password_; 218 UserCredentials credentials_;
214 bool using_oauth_; 219 bool using_oauth_;
215 // True if the authentication profile's cookie jar should contain 220 // True if the authentication profile's cookie jar should contain
216 // authentication cookies from the authentication extension log in flow. 221 // authentication cookies from the authentication extension log in flow.
217 bool has_web_auth_cookies_; 222 bool has_web_auth_cookies_;
218 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). 223 // Has to be scoped_refptr, see comment for CreateAuthenticator(...).
219 scoped_refptr<Authenticator> authenticator_; 224 scoped_refptr<Authenticator> authenticator_;
220 scoped_ptr<OAuthLoginManager> login_manager_; 225 scoped_ptr<OAuthLoginManager> login_manager_;
221 226
222 // Delegate to be fired when the profile will be prepared. 227 // Delegate to be fired when the profile will be prepared.
223 LoginUtils::Delegate* delegate_; 228 LoginUtils::Delegate* delegate_;
224 229
225 // True if should restore authentication session when notified about 230 // True if should restore authentication session when notified about
226 // online state change. 231 // online state change.
227 bool should_restore_auth_session_; 232 bool should_restore_auth_session_;
228 233
234 // Sesion restore strategy.
235 OAuthLoginManager::SessionRestoreStrategy session_restore_strategy_;
236 // OAuth2 refresh token for session restore.
237 std::string oauth2_refresh_token_;
238
229 content::NotificationRegistrar registrar_; 239 content::NotificationRegistrar registrar_;
230 240
231 // This is set via a notification after the profile has initialized the 241 // This is set via a notification after the profile has initialized the
232 // getter. 242 // getter.
233 net::URLRequestContextGetter* url_request_context_getter_; 243 net::URLRequestContextGetter* url_request_context_getter_;
234 244
235 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); 245 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl);
236 }; 246 };
237 247
238 class LoginUtilsWrapper { 248 class LoginUtilsWrapper {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 308
299 // Mark login host for deletion after browser starts. This 309 // Mark login host for deletion after browser starts. This
300 // guarantees that the message loop will be referenced by the 310 // guarantees that the message loop will be referenced by the
301 // browser before it is dereferenced by the login host. 311 // browser before it is dereferenced by the login host.
302 if (login_host) 312 if (login_host)
303 login_host->OnSessionStart(); 313 login_host->OnSessionStart();
304 UserManager::Get()->SessionStarted(); 314 UserManager::Get()->SessionStarted();
305 } 315 }
306 316
307 void LoginUtilsImpl::PrepareProfile( 317 void LoginUtilsImpl::PrepareProfile(
308 const std::string& username, 318 const UserCredentials& credentials,
309 const std::string& display_email, 319 const std::string& display_email,
310 const std::string& password,
311 bool using_oauth, 320 bool using_oauth,
312 bool has_cookies, 321 bool has_cookies,
313 LoginUtils::Delegate* delegate) { 322 LoginUtils::Delegate* delegate) {
314 BootTimesLoader* btl = BootTimesLoader::Get(); 323 BootTimesLoader* btl = BootTimesLoader::Get();
315 324
316 VLOG(1) << "Completing login for " << username; 325 VLOG(1) << "Completing login for " << credentials.username;
317 326
318 btl->AddLoginTimeMarker("StartSession-Start", false); 327 btl->AddLoginTimeMarker("StartSession-Start", false);
319 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( 328 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession(
320 username); 329 credentials.username);
321 btl->AddLoginTimeMarker("StartSession-End", false); 330 btl->AddLoginTimeMarker("StartSession-End", false);
322 331
323 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); 332 btl->AddLoginTimeMarker("UserLoggedIn-Start", false);
324 UserManager* user_manager = UserManager::Get(); 333 UserManager* user_manager = UserManager::Get();
325 user_manager->UserLoggedIn(username, false); 334 user_manager->UserLoggedIn(credentials.username, false);
326 btl->AddLoginTimeMarker("UserLoggedIn-End", false); 335 btl->AddLoginTimeMarker("UserLoggedIn-End", false);
327 336
328 // Switch log file as soon as possible. 337 // Switch log file as soon as possible.
329 if (base::chromeos::IsRunningOnChromeOS()) 338 if (base::chromeos::IsRunningOnChromeOS())
330 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); 339 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess()));
331 340
332 // Update user's displayed email. 341 // Update user's displayed email.
333 if (!display_email.empty()) 342 if (!display_email.empty())
334 user_manager->SaveUserDisplayEmail(username, display_email); 343 user_manager->SaveUserDisplayEmail(credentials.username, display_email);
335 344
336 password_ = password; 345 credentials_ = credentials;
337 346
338 using_oauth_ = using_oauth; 347 using_oauth_ = using_oauth;
339 has_web_auth_cookies_ = has_cookies; 348 has_web_auth_cookies_ = has_cookies;
340 delegate_ = delegate; 349 delegate_ = delegate;
350 InitSessionRestoreStrategy();
341 351
342 policy::BrowserPolicyConnector* connector = 352 policy::BrowserPolicyConnector* connector =
343 g_browser_process->browser_policy_connector(); 353 g_browser_process->browser_policy_connector();
344 354
345 // If this is an enterprise device and the user belongs to the enterprise 355 // If this is an enterprise device and the user belongs to the enterprise
346 // domain, then wait for a policy fetch before logging the user in. This 356 // domain, then wait for a policy fetch before logging the user in. This
347 // will delay Profile creation until the policy is fetched, so that features 357 // will delay Profile creation until the policy is fetched, so that features
348 // controlled by policy (e.g. Sync, Startup tabs) only start after the 358 // controlled by policy (e.g. Sync, Startup tabs) only start after the
349 // PrefService has the right values. 359 // PrefService has the right values.
350 // Profile creation is also resumed if the fetch attempt fails. 360 // Profile creation is also resumed if the fetch attempt fails.
351 bool wait_for_policy_fetch = 361 bool wait_for_policy_fetch =
352 using_oauth_ && 362 using_oauth_ &&
353 authenticator_.get() && 363 authenticator_.get() &&
354 (connector->GetUserAffiliation(username) == 364 (connector->GetUserAffiliation(credentials_.username) ==
355 policy::USER_AFFILIATION_MANAGED); 365 policy::USER_AFFILIATION_MANAGED);
356 366
357 // Initialize user policy before the profile is created so the profile 367 // Initialize user policy before the profile is created so the profile
358 // initialization code sees the cached policy settings. 368 // initialization code sees the cached policy settings.
359 connector->InitializeUserPolicy(username, 369 connector->InitializeUserPolicy(credentials_.username,
360 user_manager->IsLoggedInAsPublicAccount(), 370 user_manager->IsLoggedInAsPublicAccount(),
361 wait_for_policy_fetch); 371 wait_for_policy_fetch);
362 372
363 // The default profile will have been changed because the ProfileManager 373 // The default profile will have been changed because the ProfileManager
364 // will process the notification that the UserManager sends out. 374 // will process the notification that the UserManager sends out.
365 ProfileManager::CreateDefaultProfileAsync( 375 ProfileManager::CreateDefaultProfileAsync(
366 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); 376 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr()));
367 377
368 if (wait_for_policy_fetch) { 378 if (wait_for_policy_fetch) {
369 // Profile creation will block until user policy is fetched, which 379 // Profile creation will block until user policy is fetched, which
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 policy::NetworkConfigurationUpdater* network_configuration_updater = 426 policy::NetworkConfigurationUpdater* network_configuration_updater =
417 g_browser_process->browser_policy_connector()-> 427 g_browser_process->browser_policy_connector()->
418 GetNetworkConfigurationUpdater(); 428 GetNetworkConfigurationUpdater();
419 if (network_configuration_updater) 429 if (network_configuration_updater)
420 network_configuration_updater->OnUserPolicyInitialized(); 430 network_configuration_updater->OnUserPolicyInitialized();
421 } 431 }
422 432
423 RespectLocalePreference(user_profile); 433 RespectLocalePreference(user_profile);
424 } 434 }
425 435
436 void LoginUtilsImpl::InitSessionRestoreStrategy() {
437 CommandLine* command_line = CommandLine::ForCurrentProcess();
438 bool in_app_mode = chrome::IsRunningInForcedAppMode();
439
440 // Are we in kiosk app mode?
441 if (in_app_mode) {
442 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) {
443 oauth2_refresh_token_ = command_line->GetSwitchValueASCII(
444 ::switches::kAppModeOAuth2Token);
445 }
446
447 if (command_line->HasSwitch(::switches::kAppModeAuthCode)) {
448 credentials_.auth_code = command_line->GetSwitchValueASCII(
449 ::switches::kAppModeAuthCode);
450 }
451
452 DCHECK(!has_web_auth_cookies_);
453 if (!credentials_.auth_code.empty()) {
454 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE;
455 } else if (!oauth2_refresh_token_.empty()) {
456 session_restore_strategy_ =
457 OAuthLoginManager::RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN;
458 } else {
459 session_restore_strategy_ =
460 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN;
461 }
462 return;
463 }
464
465 if (has_web_auth_cookies_) {
466 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_COOKIE_JAR;
467 } else if (!credentials_.auth_code.empty()) {
468 session_restore_strategy_ = OAuthLoginManager::RESTORE_FROM_AUTH_CODE;
469 } else {
470 session_restore_strategy_ =
471 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN;
472 }
473 }
474
475
426 void LoginUtilsImpl::OnProfileCreated( 476 void LoginUtilsImpl::OnProfileCreated(
427 Profile* user_profile, 477 Profile* user_profile,
428 Profile::CreateStatus status) { 478 Profile::CreateStatus status) {
429 CHECK(user_profile); 479 CHECK(user_profile);
430 480
431 switch (status) { 481 switch (status) {
432 case Profile::CREATE_STATUS_INITIALIZED: 482 case Profile::CREATE_STATUS_INITIALIZED:
433 UserProfileInitialized(user_profile); 483 UserProfileInitialized(user_profile);
434 break; 484 break;
435 case Profile::CREATE_STATUS_CREATED: 485 case Profile::CREATE_STATUS_CREATED:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 UserManager::Get()->SetMergeSessionState( 542 UserManager::Get()->SetMergeSessionState(
493 UserManager::MERGE_STATUS_IN_PROCESS); 543 UserManager::MERGE_STATUS_IN_PROCESS);
494 // Remove legacy OAuth1 token if we have one. If it's valid, we should already 544 // Remove legacy OAuth1 token if we have one. If it's valid, we should already
495 // have OAuth2 refresh token in TokenService that could be used to retrieve 545 // have OAuth2 refresh token in TokenService that could be used to retrieve
496 // all other tokens and credentials. 546 // all other tokens and credentials.
497 login_manager_->RestoreSession( 547 login_manager_->RestoreSession(
498 user_profile, 548 user_profile,
499 authenticator_ && authenticator_->authentication_profile() ? 549 authenticator_ && authenticator_->authentication_profile() ?
500 authenticator_->authentication_profile()->GetRequestContext() : 550 authenticator_->authentication_profile()->GetRequestContext() :
501 NULL, 551 NULL,
502 restore_from_auth_cookies); 552 session_restore_strategy_,
553 oauth2_refresh_token_,
554 credentials_.auth_code);
503 } 555 }
504 556
505 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { 557 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) {
506 BootTimesLoader* btl = BootTimesLoader::Get(); 558 BootTimesLoader* btl = BootTimesLoader::Get();
507 // Own TPM device if, for any reason, it has not been done in EULA 559 // Own TPM device if, for any reason, it has not been done in EULA
508 // wizard screen. 560 // wizard screen.
509 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); 561 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary();
510 btl->AddLoginTimeMarker("TPMOwn-Start", false); 562 btl->AddLoginTimeMarker("TPMOwn-Start", false);
511 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { 563 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) {
512 if (cryptohome->TpmIsOwned()) { 564 if (cryptohome->TpmIsOwned()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 static bool initialized = false; 645 static bool initialized = false;
594 if (!initialized) { 646 if (!initialized) {
595 initialized = true; 647 initialized = true;
596 // Notify the sync service that signin was successful. Note: Since the sync 648 // Notify the sync service that signin was successful. Note: Since the sync
597 // service is lazy-initialized, we need to make sure it has been created. 649 // service is lazy-initialized, we need to make sure it has been created.
598 ProfileSyncService* sync_service = 650 ProfileSyncService* sync_service =
599 ProfileSyncServiceFactory::GetInstance()->GetForProfile(user_profile); 651 ProfileSyncServiceFactory::GetInstance()->GetForProfile(user_profile);
600 // We may not always have a passphrase (for example, on a restart after a 652 // We may not always have a passphrase (for example, on a restart after a
601 // browser crash). Only notify the sync service if we have a passphrase, 653 // browser crash). Only notify the sync service if we have a passphrase,
602 // so it can do any required re-encryption. 654 // so it can do any required re-encryption.
603 if (!password_.empty() && sync_service) { 655 if (!credentials_.password.empty() && sync_service) {
604 GoogleServiceSigninSuccessDetails details( 656 GoogleServiceSigninSuccessDetails details(
605 signin->GetAuthenticatedUsername(), 657 signin->GetAuthenticatedUsername(),
606 password_); 658 credentials_.password);
607 content::NotificationService::current()->Notify( 659 content::NotificationService::current()->Notify(
608 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, 660 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
609 content::Source<Profile>(user_profile), 661 content::Source<Profile>(user_profile),
610 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); 662 content::Details<const GoogleServiceSigninSuccessDetails>(&details));
611 } 663 }
612 } 664 }
613 password_.clear(); 665 credentials_.password.clear();
666 credentials_.auth_code.clear();
614 } 667 }
615 668
616 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) { 669 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) {
617 DCHECK(profile != NULL); 670 DCHECK(profile != NULL);
618 PrefService* prefs = profile->GetPrefs(); 671 PrefService* prefs = profile->GetPrefs();
619 DCHECK(prefs != NULL); 672 DCHECK(prefs != NULL);
620 if (g_browser_process == NULL) 673 if (g_browser_process == NULL)
621 return; 674 return;
622 675
623 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale); 676 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 bool LoginUtils::IsWhitelisted(const std::string& username) { 943 bool LoginUtils::IsWhitelisted(const std::string& username) {
891 CrosSettings* cros_settings = CrosSettings::Get(); 944 CrosSettings* cros_settings = CrosSettings::Get();
892 bool allow_new_user = false; 945 bool allow_new_user = false;
893 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 946 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
894 if (allow_new_user) 947 if (allow_new_user)
895 return true; 948 return true;
896 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 949 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
897 } 950 }
898 951
899 } // namespace chromeos 952 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698