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/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 Loading... |
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 Loading... |
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 Loading... |
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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2103 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
2114 ProfileSyncService* old_this = this; | 2104 ProfileSyncService* old_this = this; |
2115 this->~ProfileSyncService(); | 2105 this->~ProfileSyncService(); |
2116 new(old_this) ProfileSyncService( | 2106 new(old_this) ProfileSyncService( |
2117 new ProfileSyncComponentsFactoryImpl(profile, | 2107 new ProfileSyncComponentsFactoryImpl(profile, |
2118 CommandLine::ForCurrentProcess()), | 2108 CommandLine::ForCurrentProcess()), |
2119 profile, | 2109 profile, |
2120 signin, | 2110 signin, |
2121 behavior); | 2111 behavior); |
2122 } | 2112 } |
OLD | NEW |