| 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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 | 1322 |
| 1323 bool ProfileSyncService::FirstSetupInProgress() const { | 1323 bool ProfileSyncService::FirstSetupInProgress() const { |
| 1324 return !HasSyncSetupCompleted() && setup_in_progress_; | 1324 return !HasSyncSetupCompleted() && setup_in_progress_; |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { | 1327 void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { |
| 1328 bool was_in_progress = setup_in_progress_; | 1328 bool was_in_progress = setup_in_progress_; |
| 1329 setup_in_progress_ = setup_in_progress; | 1329 setup_in_progress_ = setup_in_progress; |
| 1330 if (!setup_in_progress && was_in_progress) { | 1330 if (!setup_in_progress && was_in_progress) { |
| 1331 if (sync_initialized()) { | 1331 if (sync_initialized()) { |
| 1332 ConfigurePriorityDataTypes(); |
| 1332 ReconfigureDatatypeManager(); | 1333 ReconfigureDatatypeManager(); |
| 1333 } | 1334 } |
| 1334 } | 1335 } |
| 1335 NotifyObservers(); | 1336 NotifyObservers(); |
| 1336 } | 1337 } |
| 1337 | 1338 |
| 1338 bool ProfileSyncService::sync_initialized() const { | 1339 bool ProfileSyncService::sync_initialized() const { |
| 1339 return backend_initialized_; | 1340 return backend_initialized_; |
| 1340 } | 1341 } |
| 1341 | 1342 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 const syncer::BaseTransaction* trans) const { | 1513 const syncer::BaseTransaction* trans) const { |
| 1513 return backend_.get() && backend_->IsCryptographerReady(trans); | 1514 return backend_.get() && backend_->IsCryptographerReady(trans); |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1516 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | 1517 SyncBackendHost* ProfileSyncService::GetBackendForTest() { |
| 1517 // We don't check |backend_initialized_|; we assume the test class | 1518 // We don't check |backend_initialized_|; we assume the test class |
| 1518 // knows what it's doing. | 1519 // knows what it's doing. |
| 1519 return backend_.get(); | 1520 return backend_.get(); |
| 1520 } | 1521 } |
| 1521 | 1522 |
| 1523 void ProfileSyncService::ConfigurePriorityDataTypes() { |
| 1524 const syncer::ModelTypeSet priority_types = |
| 1525 Intersection(GetPreferredDataTypes(), syncer::PriorityUserTypes()); |
| 1526 data_type_manager_->Configure(priority_types, |
| 1527 syncer::CONFIGURE_REASON_RECONFIGURATION); |
| 1528 } |
| 1529 |
| 1522 void ProfileSyncService::ConfigureDataTypeManager() { | 1530 void ProfileSyncService::ConfigureDataTypeManager() { |
| 1523 // Don't configure datatypes if the setup UI is still on the screen - this | 1531 // Don't configure datatypes if the setup UI is still on the screen - this |
| 1524 // is to help multi-screen setting UIs (like iOS) where they don't want to | 1532 // is to help multi-screen setting UIs (like iOS) where they don't want to |
| 1525 // start syncing data until the user is done configuring encryption options, | 1533 // start syncing data until the user is done configuring encryption options, |
| 1526 // etc. ReconfigureDatatypeManager() will get called again once the UI calls | 1534 // etc. ReconfigureDatatypeManager() will get called again once the UI calls |
| 1527 // SetSetupInProgress(false). | 1535 // SetSetupInProgress(false). |
| 1528 if (setup_in_progress_) | 1536 if (setup_in_progress_) |
| 1529 return; | 1537 return; |
| 1530 | 1538 |
| 1531 bool restart = false; | 1539 bool restart = false; |
| 1532 if (!data_type_manager_.get()) { | 1540 if (!data_type_manager_.get()) { |
| 1533 restart = true; | 1541 restart = true; |
| 1534 data_type_manager_.reset( | 1542 data_type_manager_.reset( |
| 1535 factory_->CreateDataTypeManager(debug_info_listener_, | 1543 factory_->CreateDataTypeManager(debug_info_listener_, |
| 1536 backend_.get(), | 1544 backend_.get(), |
| 1537 &data_type_controllers_, | 1545 &data_type_controllers_, |
| 1538 this, | 1546 this, |
| 1539 &failed_datatypes_handler_)); | 1547 &failed_datatypes_handler_)); |
| 1540 | 1548 |
| 1541 // We create the migrator at the same time. | 1549 // We create the migrator at the same time. |
| 1542 migrator_.reset( | 1550 migrator_.reset( |
| 1543 new browser_sync::BackendMigrator( | 1551 new browser_sync::BackendMigrator( |
| 1544 profile_->GetDebugName(), GetUserShare(), | 1552 profile_->GetDebugName(), GetUserShare(), |
| 1545 this, data_type_manager_.get(), | 1553 this, data_type_manager_.get(), |
| 1546 base::Bind(&ProfileSyncService::StartSyncingWithServer, | 1554 base::Bind(&ProfileSyncService::StartSyncingWithServer, |
| 1547 base::Unretained(this)))); | 1555 base::Unretained(this)))); |
| 1548 } | 1556 } |
| 1557 ConfigurePriorityDataTypes(); |
| 1549 | 1558 |
| 1550 #if defined(OS_ANDROID) | 1559 #if defined(OS_ANDROID) |
| 1551 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) && | 1560 if (GetPreferredDataTypes().Has(syncer::PASSWORDS) && |
| 1552 !ShouldEnablePasswordSyncForAndroid()) { | 1561 !ShouldEnablePasswordSyncForAndroid()) { |
| 1553 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported."); | 1562 DisableBrokenDatatype(syncer::PASSWORDS, FROM_HERE, "Not supported."); |
| 1554 } | 1563 } |
| 1555 #endif | 1564 #endif |
| 1556 | 1565 |
| 1557 const syncer::ModelTypeSet types = GetPreferredDataTypes(); | 1566 const syncer::ModelTypeSet types = GetPreferredDataTypes(); |
| 1558 if (IsPassphraseRequiredForDecryption()) { | 1567 if (IsPassphraseRequiredForDecryption()) { |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2029 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 2021 ProfileSyncService* old_this = this; | 2030 ProfileSyncService* old_this = this; |
| 2022 this->~ProfileSyncService(); | 2031 this->~ProfileSyncService(); |
| 2023 new(old_this) ProfileSyncService( | 2032 new(old_this) ProfileSyncService( |
| 2024 new ProfileSyncComponentsFactoryImpl(profile, | 2033 new ProfileSyncComponentsFactoryImpl(profile, |
| 2025 CommandLine::ForCurrentProcess()), | 2034 CommandLine::ForCurrentProcess()), |
| 2026 profile, | 2035 profile, |
| 2027 signin, | 2036 signin, |
| 2028 behavior); | 2037 behavior); |
| 2029 } | 2038 } |
| OLD | NEW |