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

Unified Diff: chrome/browser/ui/sync/one_click_signin_sync_starter.cc

Issue 15774008: Pass errors generated during limited-user registration up to the UI for display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed Drew's comments Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/sync/one_click_signin_sync_starter.cc
===================================================================
--- chrome/browser/ui/sync/one_click_signin_sync_starter.cc (revision 203598)
+++ chrome/browser/ui/sync/one_click_signin_sync_starter.cc (working copy)
@@ -198,49 +198,60 @@
Profile* new_profile,
Profile::CreateStatus status) {
DCHECK_NE(profile_, new_profile);
- if (status == Profile::CREATE_STATUS_FAIL) {
- // TODO(atwilson): On error, unregister the client to release the DMToken
- // and surface a better error for the user.
- NOTREACHED() << "Error creating new profile";
- CancelSigninAndDelete();
- return;
- }
- // Wait until the profile is initialized before we transfer credentials.
- if (status == Profile::CREATE_STATUS_INITIALIZED) {
- SigninManager* old_signin_manager =
- SigninManagerFactory::GetForProfile(profile_);
- SigninManager* new_signin_manager =
- SigninManagerFactory::GetForProfile(new_profile);
- DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty());
- DCHECK(old_signin_manager->GetAuthenticatedUsername().empty());
- DCHECK(new_signin_manager->GetAuthenticatedUsername().empty());
- DCHECK(policy_client_);
+ // TODO(atwilson): On error, unregister the client to release the DMToken
+ // and surface a better error for the user.
+ switch (status) {
+ case Profile::CREATE_STATUS_LOCAL_FAIL: {
+ NOTREACHED() << "Error creating new profile";
+ CancelSigninAndDelete();
+ return;
+ }
+ case Profile::CREATE_STATUS_CREATED: {
+ break;
+ }
+ case Profile::CREATE_STATUS_INITIALIZED: {
+ // Wait until the profile is initialized before we transfer credentials.
+ SigninManager* old_signin_manager =
+ SigninManagerFactory::GetForProfile(profile_);
+ SigninManager* new_signin_manager =
+ SigninManagerFactory::GetForProfile(new_profile);
+ DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty());
+ DCHECK(old_signin_manager->GetAuthenticatedUsername().empty());
+ DCHECK(new_signin_manager->GetAuthenticatedUsername().empty());
+ DCHECK(policy_client_);
- // Copy credentials from the old profile to the just-created profile,
- // and switch over to tracking that profile.
- new_signin_manager->CopyCredentialsFrom(*old_signin_manager);
- FinishProfileSyncServiceSetup();
- Initialize(new_profile, NULL);
- DCHECK_EQ(profile_, new_profile);
+ // Copy credentials from the old profile to the just-created profile,
+ // and switch over to tracking that profile.
+ new_signin_manager->CopyCredentialsFrom(*old_signin_manager);
+ FinishProfileSyncServiceSetup();
+ Initialize(new_profile, NULL);
+ DCHECK_EQ(profile_, new_profile);
- // We've transferred our credentials to the new profile - notify that
- // the signin for the original profile was cancelled (must do this after
- // we have called Initialize() with the new profile, as otherwise this
- // object will get freed when the signin on the old profile is cancelled.
- old_signin_manager->SignOut();
+ // We've transferred our credentials to the new profile - notify that
+ // the signin for the original profile was cancelled (must do this after
+ // we have called Initialize() with the new profile, as otherwise this
+ // object will get freed when the signin on the old profile is cancelled.
+ old_signin_manager->SignOut();
- // Load policy for the just-created profile - once policy has finished
- // loading the signin process will complete.
- LoadPolicyWithCachedClient();
+ // Load policy for the just-created profile - once policy has finished
+ // loading the signin process will complete.
+ LoadPolicyWithCachedClient();
- // Open the profile's first window, after all initialization.
- ProfileManager::FindOrCreateNewWindowForProfile(
- new_profile,
- chrome::startup::IS_PROCESS_STARTUP,
- chrome::startup::IS_FIRST_RUN,
- desktop_type,
- false);
+ // Open the profile's first window, after all initialization.
+ ProfileManager::FindOrCreateNewWindowForProfile(
+ new_profile,
+ chrome::startup::IS_PROCESS_STARTUP,
+ chrome::startup::IS_FIRST_RUN,
+ desktop_type,
+ false);
+ }
+ case Profile::CREATE_STATUS_REMOTE_FAIL:
+ case Profile::MAX_CREATE_STATUS: {
+ NOTREACHED() << "Invalid profile creation status";
+ CancelSigninAndDelete();
+ return;
+ }
}
}
#endif

Powered by Google App Engine
This is Rietveld 408576698