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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { | 120 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { |
121 if (service == kRelevantTokenServices[i]) | 121 if (service == kRelevantTokenServices[i]) |
122 return true; | 122 return true; |
123 } | 123 } |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 bool ShouldShowActionOnUI( | 127 bool ShouldShowActionOnUI( |
128 const syncer::SyncProtocolError& error) { | 128 const syncer::SyncProtocolError& error) { |
129 return (error.action != syncer::UNKNOWN_ACTION && | 129 return (error.action != syncer::UNKNOWN_ACTION && |
130 error.action != syncer::DISABLE_SYNC_ON_CLIENT); | 130 error.action != syncer::DISABLE_SYNC_ON_CLIENT && |
131 error.action != syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT); | |
131 } | 132 } |
132 | 133 |
133 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, | 134 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, |
134 Profile* profile, | 135 Profile* profile, |
135 SigninManagerBase* signin_manager, | 136 SigninManagerBase* signin_manager, |
136 StartBehavior start_behavior) | 137 StartBehavior start_behavior) |
137 : last_auth_error_(AuthError::AuthErrorNone()), | 138 : last_auth_error_(AuthError::AuthErrorNone()), |
138 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), | 139 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), |
139 factory_(factory), | 140 factory_(factory), |
140 profile_(profile), | 141 profile_(profile), |
141 // |profile| may be NULL in unit tests. | 142 // |profile| may be NULL in unit tests. |
142 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), | 143 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), |
143 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), | 144 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), |
144 sync_service_url_(kDevServerUrl), | 145 sync_service_url_(kDevServerUrl), |
145 data_type_requested_sync_startup_(false), | 146 data_type_requested_sync_startup_(false), |
146 is_first_time_sync_configure_(false), | 147 is_first_time_sync_configure_(false), |
147 backend_initialized_(false), | 148 backend_initialized_(false), |
149 sync_disabled_by_admin_(false), | |
148 is_auth_in_progress_(false), | 150 is_auth_in_progress_(false), |
149 signin_(signin_manager), | 151 signin_(signin_manager), |
150 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 152 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
151 weak_factory_(this), | 153 weak_factory_(this), |
152 expect_sync_configuration_aborted_(false), | 154 expect_sync_configuration_aborted_(false), |
153 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), | 155 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), |
154 encrypt_everything_(false), | 156 encrypt_everything_(false), |
155 encryption_pending_(false), | 157 encryption_pending_(false), |
156 auto_start_enabled_(start_behavior == AUTO_START), | 158 auto_start_enabled_(start_behavior == AUTO_START), |
157 failed_datatypes_handler_(this), | 159 failed_datatypes_handler_(this), |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1212 OnInternalUnrecoverableError(FROM_HERE, | 1214 OnInternalUnrecoverableError(FROM_HERE, |
1213 last_actionable_error_.error_description, | 1215 last_actionable_error_.error_description, |
1214 true, | 1216 true, |
1215 ERROR_REASON_ACTIONABLE_ERROR); | 1217 ERROR_REASON_ACTIONABLE_ERROR); |
1216 break; | 1218 break; |
1217 case syncer::DISABLE_SYNC_ON_CLIENT: | 1219 case syncer::DISABLE_SYNC_ON_CLIENT: |
1218 OnStopSyncingPermanently(); | 1220 OnStopSyncingPermanently(); |
1219 // TODO(rsimha): Re-evaluate whether to also sign out the user here after | 1221 // TODO(rsimha): Re-evaluate whether to also sign out the user here after |
1220 // a dashboard clear. See http://crbug.com/240436. | 1222 // a dashboard clear. See http://crbug.com/240436. |
1221 break; | 1223 break; |
1224 case syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT: | |
1225 // Sync disabled by domain admin. we should stop syncing until next | |
1226 // restart | |
Andrew T Wilson (Slow)
2013/05/24 15:13:10
nit: sentence punctuation (add a period at the end
pavely
2013/05/24 22:17:11
Done.
| |
1227 sync_disabled_by_admin_ = true; | |
1228 ShutdownImpl(true); | |
1229 break; | |
1222 default: | 1230 default: |
1223 NOTREACHED(); | 1231 NOTREACHED(); |
1224 } | 1232 } |
1225 NotifyObservers(); | 1233 NotifyObservers(); |
1226 } | 1234 } |
1227 | 1235 |
1228 void ProfileSyncService::OnConfigureBlocked() { | 1236 void ProfileSyncService::OnConfigureBlocked() { |
1229 NotifyObservers(); | 1237 NotifyObservers(); |
1230 } | 1238 } |
1231 | 1239 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 break; | 1976 break; |
1969 } | 1977 } |
1970 case chrome::NOTIFICATION_TOKENS_CLEARED: { | 1978 case chrome::NOTIFICATION_TOKENS_CLEARED: { |
1971 // GetCredentials() will generate invalid credentials to cause the backend | 1979 // GetCredentials() will generate invalid credentials to cause the backend |
1972 // to generate an auth error. | 1980 // to generate an auth error. |
1973 if (backend_) | 1981 if (backend_) |
1974 backend_->UpdateCredentials(GetCredentials()); | 1982 backend_->UpdateCredentials(GetCredentials()); |
1975 break; | 1983 break; |
1976 } | 1984 } |
1977 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: | 1985 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: |
1978 // Disable sync if the user is signed out. | |
1979 DisableForUser(); | 1986 DisableForUser(); |
1980 break; | 1987 break; |
1981 default: { | 1988 default: { |
1982 NOTREACHED(); | 1989 NOTREACHED(); |
1983 } | 1990 } |
1984 } | 1991 } |
1985 } | 1992 } |
1986 | 1993 |
1987 void ProfileSyncService::AddObserver(Observer* observer) { | 1994 void ProfileSyncService::AddObserver(Observer* observer) { |
1988 observers_.AddObserver(observer); | 1995 observers_.AddObserver(observer); |
(...skipping 16 matching lines...) Expand all Loading... | |
2005 } | 2012 } |
2006 | 2013 |
2007 // static | 2014 // static |
2008 bool ProfileSyncService::IsSyncEnabled() { | 2015 bool ProfileSyncService::IsSyncEnabled() { |
2009 // We have switches::kEnableSync just in case we need to change back to | 2016 // We have switches::kEnableSync just in case we need to change back to |
2010 // sync-disabled-by-default on a platform. | 2017 // sync-disabled-by-default on a platform. |
2011 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync); | 2018 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync); |
2012 } | 2019 } |
2013 | 2020 |
2014 bool ProfileSyncService::IsManaged() const { | 2021 bool ProfileSyncService::IsManaged() const { |
2015 return sync_prefs_.IsManaged(); | 2022 return sync_prefs_.IsManaged() || sync_disabled_by_admin_; |
Andrew T Wilson (Slow)
2013/05/24 15:13:10
I'm OK with this change even though it means we no
| |
2016 } | 2023 } |
2017 | 2024 |
2018 bool ProfileSyncService::ShouldPushChanges() { | 2025 bool ProfileSyncService::ShouldPushChanges() { |
2019 // True only after all bootstrapping has succeeded: the sync backend | 2026 // True only after all bootstrapping has succeeded: the sync backend |
2020 // is initialized, all enabled data types are consistent with one | 2027 // is initialized, all enabled data types are consistent with one |
2021 // another, and no unrecoverable error has transpired. | 2028 // another, and no unrecoverable error has transpired. |
2022 if (HasUnrecoverableError()) | 2029 if (HasUnrecoverableError()) |
2023 return false; | 2030 return false; |
2024 | 2031 |
2025 if (!data_type_manager_) | 2032 if (!data_type_manager_) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2088 void ProfileSyncService::UpdateInvalidatorRegistrarState() { | 2095 void ProfileSyncService::UpdateInvalidatorRegistrarState() { |
2089 const syncer::InvalidatorState effective_state = | 2096 const syncer::InvalidatorState effective_state = |
2090 backend_initialized_ ? | 2097 backend_initialized_ ? |
2091 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; | 2098 invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR; |
2092 DVLOG(1) << "New invalidator state: " | 2099 DVLOG(1) << "New invalidator state: " |
2093 << syncer::InvalidatorStateToString(invalidator_state_) | 2100 << syncer::InvalidatorStateToString(invalidator_state_) |
2094 << ", effective state: " | 2101 << ", effective state: " |
2095 << syncer::InvalidatorStateToString(effective_state); | 2102 << syncer::InvalidatorStateToString(effective_state); |
2096 invalidator_registrar_->UpdateInvalidatorState(effective_state); | 2103 invalidator_registrar_->UpdateInvalidatorState(effective_state); |
2097 } | 2104 } |
OLD | NEW |