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/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 } else { | 1007 } else { |
1008 ProfileSyncService::SyncEvent( | 1008 ProfileSyncService::SyncEvent( |
1009 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); | 1009 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); |
1010 } | 1010 } |
1011 } | 1011 } |
1012 // Let the various services know that we're no longer active. | 1012 // Let the various services know that we're no longer active. |
1013 GetLoginUIService()->LoginUIClosed(this); | 1013 GetLoginUIService()->LoginUIClosed(this); |
1014 } | 1014 } |
1015 | 1015 |
1016 if (sync_service) { | 1016 if (sync_service) { |
1017 sync_service->SetSetupInProgress(false); | |
1018 | |
1019 // Make sure user isn't left half-logged-in (signed in, but without sync | 1017 // Make sure user isn't left half-logged-in (signed in, but without sync |
1020 // started up). If the user hasn't finished setting up sync, then sign out | 1018 // started up). If the user hasn't finished setting up sync, then sign out |
1021 // and shut down sync. | 1019 // and shut down sync. |
1022 if (!sync_service->HasSyncSetupCompleted()) { | 1020 if (!sync_service->HasSyncSetupCompleted()) { |
1023 DVLOG(1) << "Signin aborted by user action"; | 1021 DVLOG(1) << "Signin aborted by user action"; |
1024 sync_service->DisableForUser(); | 1022 sync_service->DisableForUser(); |
1025 | 1023 |
1026 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); | 1024 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); |
1027 sync_prefs.SetStartSuppressed(true); | 1025 sync_prefs.SetStartSuppressed(true); |
1028 } | 1026 } |
| 1027 sync_service->SetSetupInProgress(false); |
1029 } | 1028 } |
1030 | 1029 |
1031 // Reset the attempted email address and error, otherwise the sync setup | 1030 // Reset the attempted email address and error, otherwise the sync setup |
1032 // overlay in the settings page will stay in whatever error state it was last | 1031 // overlay in the settings page will stay in whatever error state it was last |
1033 // when it is reopened. | 1032 // when it is reopened. |
1034 last_attempted_user_email_.clear(); | 1033 last_attempted_user_email_.clear(); |
1035 last_signin_error_ = GoogleServiceAuthError::None(); | 1034 last_signin_error_ = GoogleServiceAuthError::None(); |
1036 | 1035 |
1037 configuring_sync_ = false; | 1036 configuring_sync_ = false; |
1038 signin_tracker_.reset(); | 1037 signin_tracker_.reset(); |
(...skipping 13 matching lines...) Expand all Loading... |
1052 // 2) Normal signin through options page (IsSyncEnabledAndLoggedIn() will | 1051 // 2) Normal signin through options page (IsSyncEnabledAndLoggedIn() will |
1053 // return false). | 1052 // return false). |
1054 // 3) Previously working credentials have expired | 1053 // 3) Previously working credentials have expired |
1055 // (service->GetAuthError() != NONE). | 1054 // (service->GetAuthError() != NONE). |
1056 // 4) User is already signed in, but App Notifications needs to force another | 1055 // 4) User is already signed in, but App Notifications needs to force another |
1057 // login so it can fetch an oauth token (passes force_login=true) | 1056 // login so it can fetch an oauth token (passes force_login=true) |
1058 // 5) User clicks [Advanced Settings] button on options page while already | 1057 // 5) User clicks [Advanced Settings] button on options page while already |
1059 // logged in. | 1058 // logged in. |
1060 // 6) One-click signin (credentials are already available, so should display | 1059 // 6) One-click signin (credentials are already available, so should display |
1061 // sync configure UI, not login UI). | 1060 // sync configure UI, not login UI). |
| 1061 // 7) ChromeOS re-enable after disabling sync. |
1062 if (force_login || | 1062 if (force_login || |
1063 !service->IsSyncEnabledAndLoggedIn() || | 1063 !service->IsSyncEnabledAndLoggedIn() || |
1064 service->GetAuthError().state() != GoogleServiceAuthError::NONE) { | 1064 service->GetAuthError().state() != GoogleServiceAuthError::NONE) { |
1065 // User is not logged in, or login has been specially requested - need to | 1065 // User is not logged in, or login has been specially requested - need to |
1066 // display login UI (cases 1-4). | 1066 // display login UI (cases 1-4). |
1067 DisplayGaiaLogin(false); | 1067 DisplayGaiaLogin(false); |
1068 } else { | 1068 } else { |
1069 // User is already logged in. They must have brought up the config wizard | 1069 // User is already logged in. They must have brought up the config wizard |
1070 // via the "Advanced..." button or through One-Click signin (cases 5/6). | 1070 // via the "Advanced..." button or through One-Click signin (cases 5/6), or |
| 1071 // they are re-enabling sync on Chrome OS. |
1071 DisplayConfigureSync(true, false); | 1072 DisplayConfigureSync(true, false); |
1072 } | 1073 } |
1073 | 1074 |
1074 if (!UseWebBasedSigninFlow()) | 1075 if (!UseWebBasedSigninFlow()) |
1075 ShowSetupUI(); | 1076 ShowSetupUI(); |
1076 } | 1077 } |
1077 | 1078 |
1078 void SyncSetupHandler::OpenConfigureSync() { | 1079 void SyncSetupHandler::OpenConfigureSync() { |
1079 if (!PrepareSyncSetup()) | 1080 if (!PrepareSyncSetup()) |
1080 return; | 1081 return; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 if (i != current_profile_index && AreUserNamesEqual( | 1145 if (i != current_profile_index && AreUserNamesEqual( |
1145 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1146 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
1146 *error_message = l10n_util::GetStringUTF16( | 1147 *error_message = l10n_util::GetStringUTF16( |
1147 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1148 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1148 return false; | 1149 return false; |
1149 } | 1150 } |
1150 } | 1151 } |
1151 | 1152 |
1152 return true; | 1153 return true; |
1153 } | 1154 } |
OLD | NEW |