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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 sync_prefs_(profile_->GetPrefs()), | 211 sync_prefs_(profile_->GetPrefs()), |
212 sync_service_url_(GetSyncServiceURL(*CommandLine::ForCurrentProcess())), | 212 sync_service_url_(GetSyncServiceURL(*CommandLine::ForCurrentProcess())), |
213 is_first_time_sync_configure_(false), | 213 is_first_time_sync_configure_(false), |
214 backend_initialized_(false), | 214 backend_initialized_(false), |
215 sync_disabled_by_admin_(false), | 215 sync_disabled_by_admin_(false), |
216 is_auth_in_progress_(false), | 216 is_auth_in_progress_(false), |
217 signin_(signin_wrapper.Pass()), | 217 signin_(signin_wrapper.Pass()), |
218 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 218 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
219 expect_sync_configuration_aborted_(false), | 219 expect_sync_configuration_aborted_(false), |
220 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), | 220 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), |
221 encrypt_everything_allowed_(true), | |
221 encrypt_everything_(false), | 222 encrypt_everything_(false), |
222 encryption_pending_(false), | 223 encryption_pending_(false), |
223 configure_status_(DataTypeManager::UNKNOWN), | 224 configure_status_(DataTypeManager::UNKNOWN), |
224 oauth2_token_service_(oauth2_token_service), | 225 oauth2_token_service_(oauth2_token_service), |
225 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), | 226 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), |
226 weak_factory_(this), | 227 weak_factory_(this), |
227 startup_controller_weak_factory_(this), | 228 startup_controller_weak_factory_(this), |
228 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), | 229 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), |
229 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), | 230 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), |
230 network_resources_(new syncer::HttpBridgeNetworkResources), | 231 network_resources_(new syncer::HttpBridgeNetworkResources), |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1355 // TODO(rlarocque): Support non-blocking types. http://crbug.com/351005. | 1356 // TODO(rlarocque): Support non-blocking types. http://crbug.com/351005. |
1356 | 1357 |
1357 NotifyObservers(); | 1358 NotifyObservers(); |
1358 } | 1359 } |
1359 | 1360 |
1360 void ProfileSyncService::OnEncryptedTypesChanged( | 1361 void ProfileSyncService::OnEncryptedTypesChanged( |
1361 syncer::ModelTypeSet encrypted_types, | 1362 syncer::ModelTypeSet encrypted_types, |
1362 bool encrypt_everything) { | 1363 bool encrypt_everything) { |
1363 encrypted_types_ = encrypted_types; | 1364 encrypted_types_ = encrypted_types; |
1364 encrypt_everything_ = encrypt_everything; | 1365 encrypt_everything_ = encrypt_everything; |
1366 DCHECK(encrypt_everything_allowed_ || !encrypt_everything_); | |
1365 DVLOG(1) << "Encrypted types changed to " | 1367 DVLOG(1) << "Encrypted types changed to " |
1366 << syncer::ModelTypeSetToString(encrypted_types_) | 1368 << syncer::ModelTypeSetToString(encrypted_types_) |
1367 << " (encrypt everything is set to " | 1369 << " (encrypt everything is set to " |
1368 << (encrypt_everything_ ? "true" : "false") << ")"; | 1370 << (encrypt_everything_ ? "true" : "false") << ")"; |
1369 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); | 1371 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); |
1370 | 1372 |
1371 NotifyObservers(); | 1373 NotifyObservers(); |
1372 } | 1374 } |
1373 | 1375 |
1374 void ProfileSyncService::OnEncryptionComplete() { | 1376 void ProfileSyncService::OnEncryptionComplete() { |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2187 if (IsPassphraseRequired()) { | 2189 if (IsPassphraseRequired()) { |
2188 DVLOG(1) << "Setting passphrase for decryption."; | 2190 DVLOG(1) << "Setting passphrase for decryption."; |
2189 return backend_->SetDecryptionPassphrase(passphrase); | 2191 return backend_->SetDecryptionPassphrase(passphrase); |
2190 } else { | 2192 } else { |
2191 NOTREACHED() << "SetDecryptionPassphrase must not be called when " | 2193 NOTREACHED() << "SetDecryptionPassphrase must not be called when " |
2192 "IsPassphraseRequired() is false."; | 2194 "IsPassphraseRequired() is false."; |
2193 return false; | 2195 return false; |
2194 } | 2196 } |
2195 } | 2197 } |
2196 | 2198 |
2199 bool ProfileSyncService::EncryptEverythingAllowed() const { | |
2200 return encrypt_everything_allowed_; | |
2201 } | |
2202 | |
2203 void ProfileSyncService::SetEncryptEverythingAllowed(bool allowed) { | |
2204 encrypt_everything_allowed_ = allowed; | |
Marc Treib
2014/10/22 16:10:39
Hm. Do we need to handle the case when this is set
| |
2205 } | |
2206 | |
2197 void ProfileSyncService::EnableEncryptEverything() { | 2207 void ProfileSyncService::EnableEncryptEverything() { |
2208 DCHECK(EncryptEverythingAllowed()); | |
2209 | |
2198 // Tests override backend_initialized() to always return true, so we | 2210 // Tests override backend_initialized() to always return true, so we |
2199 // must check that instead of |backend_initialized_|. | 2211 // must check that instead of |backend_initialized_|. |
2200 // TODO(akalin): Fix the above. :/ | 2212 // TODO(akalin): Fix the above. :/ |
2201 DCHECK(backend_initialized()); | 2213 DCHECK(backend_initialized()); |
2202 // TODO(atwilson): Persist the encryption_pending_ flag to address the various | 2214 // TODO(atwilson): Persist the encryption_pending_ flag to address the various |
2203 // problems around cancelling encryption in the background (crbug.com/119649). | 2215 // problems around cancelling encryption in the background (crbug.com/119649). |
2204 if (!encrypt_everything_) | 2216 if (!encrypt_everything_) |
2205 encryption_pending_ = true; | 2217 encryption_pending_ = true; |
2206 } | 2218 } |
2207 | 2219 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2716 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2728 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
2717 return device_info_sync_service_->GetLocalDeviceBackupTime(); | 2729 return device_info_sync_service_->GetLocalDeviceBackupTime(); |
2718 } | 2730 } |
2719 | 2731 |
2720 void ProfileSyncService::FlushDirectory() const { | 2732 void ProfileSyncService::FlushDirectory() const { |
2721 // backend_initialized_ implies backend_ isn't NULL and the manager exists. | 2733 // backend_initialized_ implies backend_ isn't NULL and the manager exists. |
2722 // If sync is not initialized yet, we fail silently. | 2734 // If sync is not initialized yet, we fail silently. |
2723 if (backend_initialized_) | 2735 if (backend_initialized_) |
2724 backend_->FlushDirectory(); | 2736 backend_->FlushDirectory(); |
2725 } | 2737 } |
OLD | NEW |