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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 14691004: [sync] Separate sign in from sync on Desktop Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 is_auth_in_progress_ = false; 724 is_auth_in_progress_ = false;
725 backend_initialized_ = false; 725 backend_initialized_ = false;
726 // NULL if we're called from Shutdown(). 726 // NULL if we're called from Shutdown().
727 if (invalidator_registrar_) 727 if (invalidator_registrar_)
728 UpdateInvalidatorRegistrarState(); 728 UpdateInvalidatorRegistrarState();
729 cached_passphrase_.clear(); 729 cached_passphrase_.clear();
730 encryption_pending_ = false; 730 encryption_pending_ = false;
731 encrypt_everything_ = false; 731 encrypt_everything_ = false;
732 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); 732 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes();
733 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 733 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
734 start_up_time_ = base::Time();
734 // Revert to "no auth error". 735 // Revert to "no auth error".
735 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) 736 if (last_auth_error_.state() != GoogleServiceAuthError::NONE)
736 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); 737 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
737 738
738 if (sync_global_error_) { 739 if (sync_global_error_) {
739 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 740 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
740 sync_global_error_.get()); 741 sync_global_error_.get());
741 RemoveObserver(sync_global_error_.get()); 742 RemoveObserver(sync_global_error_.get());
742 sync_global_error_.reset(NULL); 743 sync_global_error_.reset(NULL);
743 } 744 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1076
1076 void ProfileSyncService::OnConnectionStatusChange( 1077 void ProfileSyncService::OnConnectionStatusChange(
1077 syncer::ConnectionStatus status) { 1078 syncer::ConnectionStatus status) {
1078 const GoogleServiceAuthError auth_error = 1079 const GoogleServiceAuthError auth_error =
1079 ConnectionStatusToAuthError(status); 1080 ConnectionStatusToAuthError(status);
1080 DVLOG(1) << "Connection status change: " << auth_error.ToString(); 1081 DVLOG(1) << "Connection status change: " << auth_error.ToString();
1081 UpdateAuthErrorState(auth_error); 1082 UpdateAuthErrorState(auth_error);
1082 } 1083 }
1083 1084
1084 void ProfileSyncService::OnStopSyncingPermanently() { 1085 void ProfileSyncService::OnStopSyncingPermanently() {
1085 UpdateAuthErrorState(AuthError(AuthError::SERVICE_UNAVAILABLE));
1086 sync_prefs_.SetStartSuppressed(true); 1086 sync_prefs_.SetStartSuppressed(true);
1087 DisableForUser(); 1087 DisableForUser();
1088
1089 // Signout doesn't exist as a concept on Chrome OS. It currently does
1090 // on other auto-start platforms (like Android, though we should probably
1091 // use SigninManagerBase there as well), but we don't want to sign the
1092 // user out on auto-start platforms if sync was disabled.
1093 // TODO(tim): Platform specific refactoring here is bug 237866.
1094 #if !defined(OS_CHROMEOS)
1095 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
1096
1097 if (!auto_start_enabled_) // Skip signout on ChromeOS/Android.
1098 signin->SignOut();
1099 #endif
1100 } 1088 }
1101 1089
1102 void ProfileSyncService::OnPassphraseRequired( 1090 void ProfileSyncService::OnPassphraseRequired(
1103 syncer::PassphraseRequiredReason reason, 1091 syncer::PassphraseRequiredReason reason,
1104 const sync_pb::EncryptedData& pending_keys) { 1092 const sync_pb::EncryptedData& pending_keys) {
1105 DCHECK(backend_.get()); 1093 DCHECK(backend_.get());
1106 DCHECK(backend_->IsNigoriEnabled()); 1094 DCHECK(backend_->IsNigoriEnabled());
1107 1095
1108 // TODO(lipalani) : add this check to other locations as well. 1096 // TODO(lipalani) : add this check to other locations as well.
1109 if (HasUnrecoverableError()) { 1097 if (HasUnrecoverableError()) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 expect_sync_configuration_aborted_ = true; 1202 expect_sync_configuration_aborted_ = true;
1215 } 1203 }
1216 // Trigger an unrecoverable error to stop syncing. 1204 // Trigger an unrecoverable error to stop syncing.
1217 OnInternalUnrecoverableError(FROM_HERE, 1205 OnInternalUnrecoverableError(FROM_HERE,
1218 last_actionable_error_.error_description, 1206 last_actionable_error_.error_description,
1219 true, 1207 true,
1220 ERROR_REASON_ACTIONABLE_ERROR); 1208 ERROR_REASON_ACTIONABLE_ERROR);
1221 break; 1209 break;
1222 case syncer::DISABLE_SYNC_ON_CLIENT: 1210 case syncer::DISABLE_SYNC_ON_CLIENT:
1223 OnStopSyncingPermanently(); 1211 OnStopSyncingPermanently();
1212 // TODO(rsimha): Re-evaluate whether to also sign out the user here after
1213 // a dashboard clear. See http://crbug.com/240436.
1224 break; 1214 break;
1225 default: 1215 default:
1226 NOTREACHED(); 1216 NOTREACHED();
1227 } 1217 }
1228 NotifyObservers(); 1218 NotifyObservers();
1229 } 1219 }
1230 1220
1231 void ProfileSyncService::OnConfigureBlocked() { 1221 void ProfileSyncService::OnConfigureBlocked() {
1232 NotifyObservers(); 1222 NotifyObservers();
1233 } 1223 }
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 !successful->password.empty()) { 1910 !successful->password.empty()) {
1921 cached_passphrase_ = successful->password; 1911 cached_passphrase_ = successful->password;
1922 // Try to consume the passphrase we just cached. If the sync backend 1912 // Try to consume the passphrase we just cached. If the sync backend
1923 // is not running yet, the passphrase will remain cached until the 1913 // is not running yet, the passphrase will remain cached until the
1924 // backend starts up. 1914 // backend starts up.
1925 ConsumeCachedPassphraseIfPossible(); 1915 ConsumeCachedPassphraseIfPossible();
1926 } 1916 }
1927 #if defined(OS_CHROMEOS) 1917 #if defined(OS_CHROMEOS)
1928 RefreshSpareBootstrapToken(successful->password); 1918 RefreshSpareBootstrapToken(successful->password);
1929 #endif 1919 #endif
1930 if (!sync_initialized() || 1920 if (!sync_initialized() && GetAuthError().state() != AuthError::NONE) {
Andrew T Wilson (Slow) 2013/05/15 15:01:24 This doesn't seem like the right change - we want
Raghu Simha 2013/05/16 02:13:20 I had orignally changed this logic to handle the c
1931 GetAuthError().state() != AuthError::NONE) {
1932 // Track the fact that we're still waiting for auth to complete. 1921 // Track the fact that we're still waiting for auth to complete.
1922 // Note: We mustn't set |is_auth_in_progress_| to true when the backend
1923 // is already initialized because it's possible to end up here when a
1924 // signed in user with sync disabled changes their gaia password, and
1925 // then re-auths while trying to re-enable sync. In such a case, auth
1926 // is complete when we receive NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL.
1933 is_auth_in_progress_ = true; 1927 is_auth_in_progress_ = true;
1934 } 1928 }
1935 break; 1929 break;
1936 } 1930 }
1937 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { 1931 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
1938 const TokenService::TokenRequestFailedDetails& token_details = 1932 const TokenService::TokenRequestFailedDetails& token_details =
1939 *(content::Details<const TokenService::TokenRequestFailedDetails>( 1933 *(content::Details<const TokenService::TokenRequestFailedDetails>(
1940 details).ptr()); 1934 details).ptr());
1941 if (IsTokenServiceRelevant(token_details.service()) && 1935 if (IsTokenServiceRelevant(token_details.service()) &&
1942 !IsSyncTokenAvailable()) { 1936 !IsSyncTokenAvailable()) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 2107 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
2114 ProfileSyncService* old_this = this; 2108 ProfileSyncService* old_this = this;
2115 this->~ProfileSyncService(); 2109 this->~ProfileSyncService();
2116 new(old_this) ProfileSyncService( 2110 new(old_this) ProfileSyncService(
2117 new ProfileSyncComponentsFactoryImpl(profile, 2111 new ProfileSyncComponentsFactoryImpl(profile,
2118 CommandLine::ForCurrentProcess()), 2112 CommandLine::ForCurrentProcess()),
2119 profile, 2113 profile,
2120 signin, 2114 signin,
2121 behavior); 2115 behavior);
2122 } 2116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698