| 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 "components/browser_sync/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "components/prefs/json_pref_store.h" | 34 #include "components/prefs/json_pref_store.h" |
| 35 #include "components/signin/core/browser/about_signin_internals.h" | 35 #include "components/signin/core/browser/about_signin_internals.h" |
| 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 37 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
| 38 #include "components/signin/core/browser/signin_metrics.h" | 38 #include "components/signin/core/browser/signin_metrics.h" |
| 39 #include "components/strings/grit/components_strings.h" | 39 #include "components/strings/grit/components_strings.h" |
| 40 #include "components/sync/api/model_type_store.h" | 40 #include "components/sync/api/model_type_store.h" |
| 41 #include "components/sync/api/sync_error.h" | 41 #include "components/sync/api/sync_error.h" |
| 42 #include "components/sync/base/cryptographer.h" | 42 #include "components/sync/base/cryptographer.h" |
| 43 #include "components/sync/base/passphrase_type.h" | 43 #include "components/sync/base/passphrase_type.h" |
| 44 #include "components/sync/base/pref_names.h" |
| 45 #include "components/sync/base/report_unrecoverable_error.h" |
| 44 #include "components/sync/base/stop_source.h" | 46 #include "components/sync/base/stop_source.h" |
| 45 #include "components/sync/base/sync_db_util.h" | 47 #include "components/sync/base/sync_db_util.h" |
| 48 #include "components/sync/base/system_encryptor.h" |
| 46 #include "components/sync/core/configure_reason.h" | 49 #include "components/sync/core/configure_reason.h" |
| 47 #include "components/sync/core/http_bridge_network_resources.h" | 50 #include "components/sync/core/http_bridge_network_resources.h" |
| 48 #include "components/sync/core/network_resources.h" | 51 #include "components/sync/core/network_resources.h" |
| 49 #include "components/sync/core/shared_model_type_processor.h" | 52 #include "components/sync/core/shared_model_type_processor.h" |
| 50 #include "components/sync/core/sync_encryption_handler.h" | 53 #include "components/sync/core/sync_encryption_handler.h" |
| 51 #include "components/sync/device_info/device_info.h" | 54 #include "components/sync/device_info/device_info.h" |
| 52 #include "components/sync/device_info/device_info_service.h" | 55 #include "components/sync/device_info/device_info_service.h" |
| 53 #include "components/sync/device_info/device_info_sync_service.h" | 56 #include "components/sync/device_info/device_info_sync_service.h" |
| 54 #include "components/sync/device_info/device_info_tracker.h" | 57 #include "components/sync/device_info/device_info_tracker.h" |
| 55 #include "components/sync/driver/backend_migrator.h" | 58 #include "components/sync/driver/backend_migrator.h" |
| 56 #include "components/sync/driver/change_processor.h" | 59 #include "components/sync/driver/change_processor.h" |
| 57 #include "components/sync/driver/directory_data_type_controller.h" | 60 #include "components/sync/driver/directory_data_type_controller.h" |
| 58 #include "components/sync/driver/glue/chrome_report_unrecoverable_error.h" | |
| 59 #include "components/sync/driver/glue/sync_backend_host_impl.h" | 61 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
| 60 #include "components/sync/driver/pref_names.h" | |
| 61 #include "components/sync/driver/signin_manager_wrapper.h" | 62 #include "components/sync/driver/signin_manager_wrapper.h" |
| 62 #include "components/sync/driver/sync_api_component_factory.h" | 63 #include "components/sync/driver/sync_api_component_factory.h" |
| 63 #include "components/sync/driver/sync_driver_switches.h" | 64 #include "components/sync/driver/sync_driver_switches.h" |
| 64 #include "components/sync/driver/sync_error_controller.h" | 65 #include "components/sync/driver/sync_error_controller.h" |
| 65 #include "components/sync/driver/sync_type_preference_provider.h" | 66 #include "components/sync/driver/sync_type_preference_provider.h" |
| 66 #include "components/sync/driver/sync_util.h" | 67 #include "components/sync/driver/sync_util.h" |
| 67 #include "components/sync/driver/system_encryptor.h" | |
| 68 #include "components/sync/driver/user_selectable_sync_type.h" | 68 #include "components/sync/driver/user_selectable_sync_type.h" |
| 69 #include "components/sync/engine/cycle/model_neutral_state.h" | 69 #include "components/sync/engine/cycle/model_neutral_state.h" |
| 70 #include "components/sync/engine/cycle/type_debug_info_observer.h" | 70 #include "components/sync/engine/cycle/type_debug_info_observer.h" |
| 71 #include "components/sync/engine/sync_string_conversions.h" | 71 #include "components/sync/engine/sync_string_conversions.h" |
| 72 #include "components/sync/js/js_event_details.h" | 72 #include "components/sync/js/js_event_details.h" |
| 73 #include "components/sync/protocol/sync.pb.h" | 73 #include "components/sync/protocol/sync.pb.h" |
| 74 #include "components/sync/syncable/directory.h" | 74 #include "components/sync/syncable/directory.h" |
| 75 #include "components/sync/syncable/syncable_read_transaction.h" | 75 #include "components/sync/syncable/syncable_read_transaction.h" |
| 76 #include "components/sync_sessions/favicon_cache.h" | 76 #include "components/sync_sessions/favicon_cache.h" |
| 77 #include "components/sync_sessions/session_data_type_controller.h" | 77 #include "components/sync_sessions/session_data_type_controller.h" |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 base::Unretained(network_resources_.get()), | 507 base::Unretained(network_resources_.get()), |
| 508 url_request_context_, network_time_update_callback_); | 508 url_request_context_, network_time_update_callback_); |
| 509 | 509 |
| 510 backend_->Initialize( | 510 backend_->Initialize( |
| 511 this, std::move(sync_thread_), db_thread_, file_thread_, | 511 this, std::move(sync_thread_), db_thread_, file_thread_, |
| 512 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), | 512 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), |
| 513 credentials, delete_stale_data, | 513 credentials, delete_stale_data, |
| 514 std::unique_ptr<syncer::SyncManagerFactory>( | 514 std::unique_ptr<syncer::SyncManagerFactory>( |
| 515 new syncer::SyncManagerFactory()), | 515 new syncer::SyncManagerFactory()), |
| 516 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), | 516 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), |
| 517 base::Bind(syncer::ChromeReportUnrecoverableError, channel_), | 517 base::Bind(syncer::ReportUnrecoverableError, channel_), |
| 518 http_post_provider_factory_getter, std::move(saved_nigori_state_)); | 518 http_post_provider_factory_getter, std::move(saved_nigori_state_)); |
| 519 } | 519 } |
| 520 | 520 |
| 521 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 521 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
| 522 if (encryption_pending()) | 522 if (encryption_pending()) |
| 523 return true; | 523 return true; |
| 524 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); | 524 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
| 525 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); | 525 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); |
| 526 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); | 526 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); |
| 527 return !Intersection(preferred_types, encrypted_types).Empty(); | 527 return !Intersection(preferred_types, encrypted_types).Empty(); |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 void ProfileSyncService::OnLocalSetPassphraseEncryption( | 1258 void ProfileSyncService::OnLocalSetPassphraseEncryption( |
| 1259 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) { | 1259 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) { |
| 1260 DCHECK(thread_checker_.CalledOnValidThread()); | 1260 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1261 if (!base::FeatureList::IsEnabled( | 1261 if (!base::FeatureList::IsEnabled( |
| 1262 switches::kSyncClearDataOnPassphraseEncryption)) | 1262 switches::kSyncClearDataOnPassphraseEncryption)) |
| 1263 return; | 1263 return; |
| 1264 | 1264 |
| 1265 // At this point the user has set a custom passphrase and we have received the | 1265 // At this point the user has set a custom passphrase and we have received the |
| 1266 // updated nigori state. Time to cache the nigori state, and catch up the | 1266 // updated nigori state. Time to cache the nigori state, and catch up the |
| 1267 // active data types. | 1267 // active data types. |
| 1268 sync_prefs_.SetSavedNigoriStateForPassphraseEncryptionTransition( | 1268 sync_prefs_.SetNigoriSpecificsForPassphraseTransition( |
| 1269 nigori_state); | 1269 nigori_state.nigori_specifics); |
| 1270 sync_prefs_.SetPassphraseEncryptionTransitionInProgress(true); | 1270 sync_prefs_.SetPassphraseEncryptionTransitionInProgress(true); |
| 1271 BeginConfigureCatchUpBeforeClear(); | 1271 BeginConfigureCatchUpBeforeClear(); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() { | 1274 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() { |
| 1275 DCHECK(data_type_manager_); | 1275 DCHECK(data_type_manager_); |
| 1276 DCHECK(!saved_nigori_state_); | 1276 DCHECK(!saved_nigori_state_); |
| 1277 saved_nigori_state_ = | 1277 saved_nigori_state_ = |
| 1278 sync_prefs_.GetSavedNigoriStateForPassphraseEncryptionTransition(); | 1278 base::MakeUnique<syncer::SyncEncryptionHandler::NigoriState>(); |
| 1279 sync_prefs_.GetNigoriSpecificsForPassphraseTransition( |
| 1280 &saved_nigori_state_->nigori_specifics); |
| 1279 const syncer::ModelTypeSet types = GetActiveDataTypes(); | 1281 const syncer::ModelTypeSet types = GetActiveDataTypes(); |
| 1280 catch_up_configure_in_progress_ = true; | 1282 catch_up_configure_in_progress_ = true; |
| 1281 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CATCH_UP); | 1283 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CATCH_UP); |
| 1282 } | 1284 } |
| 1283 | 1285 |
| 1284 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() { | 1286 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() { |
| 1285 DCHECK(thread_checker_.CalledOnValidThread()); | 1287 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1286 backend_->ClearServerData( | 1288 backend_->ClearServerData( |
| 1287 base::Bind(&ProfileSyncService::OnClearServerDataDone, | 1289 base::Bind(&ProfileSyncService::OnClearServerDataDone, |
| 1288 sync_enabled_weak_factory_.GetWeakPtr())); | 1290 sync_enabled_weak_factory_.GetWeakPtr())); |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 | 2493 |
| 2492 DCHECK(startup_controller_->IsSetupInProgress()); | 2494 DCHECK(startup_controller_->IsSetupInProgress()); |
| 2493 startup_controller_->SetSetupInProgress(false); | 2495 startup_controller_->SetSetupInProgress(false); |
| 2494 | 2496 |
| 2495 if (IsBackendInitialized()) | 2497 if (IsBackendInitialized()) |
| 2496 ReconfigureDatatypeManager(); | 2498 ReconfigureDatatypeManager(); |
| 2497 NotifyObservers(); | 2499 NotifyObservers(); |
| 2498 } | 2500 } |
| 2499 | 2501 |
| 2500 } // namespace browser_sync | 2502 } // namespace browser_sync |
| OLD | NEW |