diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-09-18 14:34:04 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-04 11:15:27 +0000 |
commit | e6430e577f105ad8813c92e75c54660c4985026e (patch) | |
tree | 88115e5d1fb471fea807111924dcccbeadbf9e4f /chromium/components/browser_sync | |
parent | 53d399fe6415a96ea6986ec0d402a9c07da72453 (diff) | |
download | qtwebengine-chromium-e6430e577f105ad8813c92e75c54660c4985026e.tar.gz |
BASELINE: Update Chromium to 61.0.3163.99
Change-Id: I8452f34574d88ca2b27af9bd56fc9ff3f16b1367
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/browser_sync')
10 files changed, 147 insertions, 151 deletions
diff --git a/chromium/components/browser_sync/BUILD.gn b/chromium/components/browser_sync/BUILD.gn index 4c2e28742e6..761ca07d9ec 100644 --- a/chromium/components/browser_sync/BUILD.gn +++ b/chromium/components/browser_sync/BUILD.gn @@ -33,7 +33,7 @@ static_library("browser_sync") { "//components/password_manager/sync/browser", "//components/pref_registry", "//components/prefs", - "//components/reading_list/core:flags", + "//components/reading_list/features:flags", "//components/signin/core/browser", "//components/strings", "//components/sync_bookmarks", diff --git a/chromium/components/browser_sync/DEPS b/chromium/components/browser_sync/DEPS index 83dd8c54333..b81123b156f 100644 --- a/chromium/components/browser_sync/DEPS +++ b/chromium/components/browser_sync/DEPS @@ -11,7 +11,7 @@ include_rules = [ "+components/password_manager/sync/browser", "+components/pref_registry", "+components/prefs", - "+components/reading_list/core", + "+components/reading_list/features", "+components/signin/core/browser", "+components/signin/core/common", "+components/sync", diff --git a/chromium/components/browser_sync/profile_sync_components_factory_impl.cc b/chromium/components/browser_sync/profile_sync_components_factory_impl.cc index 5f47d6185b4..03f74739635 100644 --- a/chromium/components/browser_sync/profile_sync_components_factory_impl.cc +++ b/chromium/components/browser_sync/profile_sync_components_factory_impl.cc @@ -27,7 +27,7 @@ #include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/sync/browser/password_data_type_controller.h" #include "components/prefs/pref_service.h" -#include "components/reading_list/core/reading_list_switches.h" +#include "components/reading_list/features/reading_list_switches.h" #include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/device_info/device_info_data_type_controller.h" #include "components/sync/device_info/local_device_info_provider_impl.h" @@ -154,48 +154,51 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( sync_service->GetLocalDeviceInfoProvider())); } - // Autocomplete sync is enabled by default. Register unless explicitly - // disabled. - if (!disabled_types.Has(syncer::AUTOFILL)) { - if (FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { - sync_service->RegisterDataTypeController( - base::MakeUnique<autofill::WebDataModelTypeController>( - syncer::AUTOFILL, sync_client_, db_thread_, web_data_service_, - base::Bind( - &autofill::AutocompleteSyncBridge::FromWebDataService))); - } else { + // These features are enabled only if there's a DB thread to post tasks to. + if (db_thread_) { + // Autocomplete sync is enabled by default. Register unless explicitly + // disabled. + if (!disabled_types.Has(syncer::AUTOFILL)) { + if (FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { + sync_service->RegisterDataTypeController( + base::MakeUnique<autofill::WebDataModelTypeController>( + syncer::AUTOFILL, sync_client_, db_thread_, web_data_service_, + base::Bind( + &autofill::AutocompleteSyncBridge::FromWebDataService))); + } else { + sync_service->RegisterDataTypeController( + base::MakeUnique<AutofillDataTypeController>( + db_thread_, error_callback, sync_client_, web_data_service_)); + } + } + + // Autofill sync is enabled by default. Register unless explicitly + // disabled. + if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { sync_service->RegisterDataTypeController( - base::MakeUnique<AutofillDataTypeController>( + base::MakeUnique<AutofillProfileDataTypeController>( db_thread_, error_callback, sync_client_, web_data_service_)); } - } - // Autofill sync is enabled by default. Register unless explicitly - // disabled. - if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { - sync_service->RegisterDataTypeController( - base::MakeUnique<AutofillProfileDataTypeController>( - db_thread_, error_callback, sync_client_, web_data_service_)); - } - - // Wallet data sync is enabled by default, but behind a syncer experiment - // enforced by the datatype controller. Register unless explicitly disabled. - bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); - if (!wallet_disabled) { - sync_service->RegisterDataTypeController( - base::MakeUnique<AutofillWalletDataTypeController>( - syncer::AUTOFILL_WALLET_DATA, db_thread_, error_callback, - sync_client_, web_data_service_)); - } + // Wallet data sync is enabled by default, but behind a syncer experiment + // enforced by the datatype controller. Register unless explicitly disabled. + bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); + if (!wallet_disabled) { + sync_service->RegisterDataTypeController( + base::MakeUnique<AutofillWalletDataTypeController>( + syncer::AUTOFILL_WALLET_DATA, db_thread_, error_callback, + sync_client_, web_data_service_)); + } - // Wallet metadata sync depends on Wallet data sync. Register if Wallet data - // is syncing and metadata sync is not explicitly disabled. - if (!wallet_disabled && - !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { - sync_service->RegisterDataTypeController( - base::MakeUnique<AutofillWalletDataTypeController>( - syncer::AUTOFILL_WALLET_METADATA, db_thread_, error_callback, - sync_client_, web_data_service_)); + // Wallet metadata sync depends on Wallet data sync. Register if Wallet data + // is syncing and metadata sync is not explicitly disabled. + if (!wallet_disabled && + !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { + sync_service->RegisterDataTypeController( + base::MakeUnique<AutofillWalletDataTypeController>( + syncer::AUTOFILL_WALLET_METADATA, db_thread_, error_callback, + sync_client_, web_data_service_)); + } } // Bookmark sync is enabled by default. Register unless explicitly @@ -206,55 +209,54 @@ void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( sync_client_)); } - const bool history_disabled = - sync_client_->GetPrefService()->GetBoolean(history_disabled_pref_); - // TypedUrl sync is enabled by default. Register unless explicitly disabled, - // or if saving history is disabled. - if (!disabled_types.Has(syncer::TYPED_URLS) && !history_disabled) { - if (base::FeatureList::IsEnabled(switches::kSyncUSSTypedURL)) { - // TODO(gangwu): Register controller here once typed url controller - // implemented. - } else { - sync_service->RegisterDataTypeController( - base::MakeUnique<TypedUrlDataTypeController>( - error_callback, sync_client_, history_disabled_pref_)); + // These features are enabled only if history is not disabled. + if (!sync_client_->GetPrefService()->GetBoolean(history_disabled_pref_)) { + // TypedUrl sync is enabled by default. Register unless explicitly + // disabled. + if (!disabled_types.Has(syncer::TYPED_URLS)) { + if (base::FeatureList::IsEnabled(switches::kSyncUSSTypedURL)) { + // TODO(gangwu): Register controller here once typed url controller + // implemented. + } else { + sync_service->RegisterDataTypeController( + base::MakeUnique<TypedUrlDataTypeController>( + error_callback, sync_client_, history_disabled_pref_)); + } } - } - // Delete directive sync is enabled by default. Register unless full history - // sync is disabled. - if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES) && - !history_disabled) { - sync_service->RegisterDataTypeController( - base::MakeUnique<HistoryDeleteDirectivesDataTypeController>( - error_callback, sync_client_)); - } + // Delete directive sync is enabled by default. + if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES)) { + sync_service->RegisterDataTypeController( + base::MakeUnique<HistoryDeleteDirectivesDataTypeController>( + error_callback, sync_client_)); + } - // Session sync is enabled by default. Register unless explicitly disabled. - // This is also disabled if the browser history is disabled, because the - // tab sync data is added to the web history on the server. - if (!disabled_types.Has(syncer::PROXY_TABS) && !history_disabled) { - sync_service->RegisterDataTypeController( - base::MakeUnique<ProxyDataTypeController>(syncer::PROXY_TABS)); - sync_service->RegisterDataTypeController( - base::MakeUnique<SessionDataTypeController>( - error_callback, sync_client_, - sync_service->GetLocalDeviceInfoProvider(), - history_disabled_pref_)); - } + // Session sync is enabled by default. This is disabled if history is + // disabled because the tab sync data is added to the web history on the + // server. + if (!disabled_types.Has(syncer::PROXY_TABS)) { + sync_service->RegisterDataTypeController( + base::MakeUnique<ProxyDataTypeController>(syncer::PROXY_TABS)); + sync_service->RegisterDataTypeController( + base::MakeUnique<SessionDataTypeController>( + error_callback, sync_client_, + sync_service->GetLocalDeviceInfoProvider(), + history_disabled_pref_)); + } - // Favicon sync is enabled by default. Register unless explicitly disabled. - if (!disabled_types.Has(syncer::FAVICON_IMAGES) && - !disabled_types.Has(syncer::FAVICON_TRACKING) && !history_disabled) { - // crbug/384552. We disable error uploading for this data types for now. - sync_service->RegisterDataTypeController( - base::MakeUnique<AsyncDirectoryTypeController>( - syncer::FAVICON_IMAGES, base::Closure(), sync_client_, - syncer::GROUP_UI, ui_thread_)); - sync_service->RegisterDataTypeController( - base::MakeUnique<AsyncDirectoryTypeController>( - syncer::FAVICON_TRACKING, base::Closure(), sync_client_, - syncer::GROUP_UI, ui_thread_)); + // Favicon sync is enabled by default. Register unless explicitly disabled. + if (!disabled_types.Has(syncer::FAVICON_IMAGES) && + !disabled_types.Has(syncer::FAVICON_TRACKING)) { + // crbug/384552. We disable error uploading for this data types for now. + sync_service->RegisterDataTypeController( + base::MakeUnique<AsyncDirectoryTypeController>( + syncer::FAVICON_IMAGES, base::Closure(), sync_client_, + syncer::GROUP_UI, ui_thread_)); + sync_service->RegisterDataTypeController( + base::MakeUnique<AsyncDirectoryTypeController>( + syncer::FAVICON_TRACKING, base::Closure(), sync_client_, + syncer::GROUP_UI, ui_thread_)); + } } // Password sync is enabled by default. Register unless explicitly diff --git a/chromium/components/browser_sync/profile_sync_service.cc b/chromium/components/browser_sync/profile_sync_service.cc index cf5f2af870f..513e27529ac 100644 --- a/chromium/components/browser_sync/profile_sync_service.cc +++ b/chromium/components/browser_sync/profile_sync_service.cc @@ -32,11 +32,12 @@ #include "components/invalidation/public/invalidation_service.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/json_pref_store.h" -#include "components/reading_list/core/reading_list_enable_flags.h" +#include "components/reading_list/features/reading_list_enable_flags.h" #include "components/signin/core/browser/about_signin_internals.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_metrics.h" +#include "components/signin/core/common/profile_management_switches.h" #include "components/strings/grit/components_strings.h" #include "components/sync/base/bind_to_task_runner.h" #include "components/sync/base/cryptographer.h" @@ -234,7 +235,7 @@ void ProfileSyncService::Initialize() { url_request_context_, syncer::SyncStoppedReporter::ResultCallback()); sessions_sync_manager_ = base::MakeUnique<SessionsSyncManager>( sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), - std::move(router), + router, base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated, sync_enabled_weak_factory_.GetWeakPtr()), base::Bind(&ProfileSyncService::TriggerRefresh, @@ -786,6 +787,12 @@ void ProfileSyncService::SetFirstSetupComplete() { } } +bool ProfileSyncService::IsSyncConfirmationNeeded() const { + DCHECK(thread_checker_.CalledOnValidThread()); + return (!IsLocalSyncEnabled() && IsSignedIn()) && !IsFirstSetupInProgress() && + !IsFirstSetupComplete() && IsSyncRequested(); +} + void ProfileSyncService::UpdateLastSyncedTime() { sync_prefs_.SetLastSyncedTime(base::Time::Now()); } @@ -924,8 +931,7 @@ void ProfileSyncService::OnEngineInitialized( } // Initialize local device info. - local_device_->Initialize(cache_guid, signin_scoped_device_id, - sync_client_->GetBlockingPool()); + local_device_->Initialize(cache_guid, signin_scoped_device_id); if (protocol_event_observers_.might_have_observers()) { engine_->RequestBufferedProtocolEventsAndEnableForwarding(); @@ -950,11 +956,6 @@ void ProfileSyncService::OnEngineInitialized( crypto_->SetSyncEngine(engine_.get()); crypto_->SetDataTypeManager(data_type_manager_.get()); - // If we have a cached passphrase use it to decrypt/encrypt data now that the - // backend is initialized. We want to call this before notifying observers in - // case this operation affects the "passphrase required" status. - crypto_->ConsumeCachedPassphraseIfPossible(); - // Auto-start means IsFirstSetupComplete gets set automatically. if (start_behavior_ == AUTO_START && !IsFirstSetupComplete()) { // This will trigger a configure if it completes setup. @@ -1207,10 +1208,6 @@ void ProfileSyncService::OnConfigureDone( configure_status_ = result.status; data_type_status_table_ = result.data_type_status_table; - // We should have cleared our cached passphrase before we get here (in - // OnEngineInitialized()). - DCHECK(crypto_->cached_passphrase().empty()); - if (!sync_configure_start_time_.is_null()) { if (configure_status_ == DataTypeManager::OK) { base::Time sync_configure_stop_time = base::Time::Now(); @@ -1295,6 +1292,8 @@ void ProfileSyncService::OnConfigureDone( return; } + RecordMemoryUsageHistograms(); + StartSyncingWithServer(); } @@ -1547,23 +1546,6 @@ void ProfileSyncService::UpdateSelectedTypesHistogram( } } -#if defined(OS_CHROMEOS) -void ProfileSyncService::RefreshSpareBootstrapToken( - const std::string& passphrase) { - syncer::SystemEncryptor encryptor; - syncer::Cryptographer temp_cryptographer(&encryptor); - // The first 2 params (hostname and username) doesn't have any effect here. - syncer::KeyParams key_params = {"localhost", "dummy", passphrase}; - - std::string bootstrap_token; - if (!temp_cryptographer.AddKey(key_params)) { - NOTREACHED() << "Failed to add key to cryptographer."; - } - temp_cryptographer.GetBootstrapToken(&bootstrap_token); - sync_prefs_.SetSpareBootstrapToken(bootstrap_token); -} -#endif - void ProfileSyncService::OnUserChoseDatatypes( bool sync_everything, syncer::ModelTypeSet chosen_types) { @@ -1937,23 +1919,20 @@ void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { } void ProfileSyncService::GoogleSigninSucceeded(const std::string& account_id, - const std::string& username, - const std::string& password) { + const std::string& username) { DCHECK(thread_checker_.CalledOnValidThread()); - if (IsSyncRequested() && !password.empty()) { - crypto_->CachePassphrase(password); - // Try to consume the passphrase we just cached. If the sync engine - // is not running yet, the passphrase will remain cached until the - // engine starts up. - crypto_->ConsumeCachedPassphraseIfPossible(); - } -#if defined(OS_CHROMEOS) - RefreshSpareBootstrapToken(password); -#endif if (!IsEngineInitialized() || GetAuthError().state() != AuthError::NONE) { // Track the fact that we're still waiting for auth to complete. is_auth_in_progress_ = true; } + + if (switches::IsAccountConsistencyDiceEnabled() && + oauth2_token_service_->RefreshTokenIsAvailable(account_id)) { + // When Dice is enabled, the refresh token may be available before the user + // enables sync. Start sync if the refresh token is already available in the + // token service when the authenticated account is set. + OnRefreshTokenAvailable(account_id); + } } void ProfileSyncService::GoogleSignedOut(const std::string& account_id, @@ -2387,6 +2366,16 @@ void ProfileSyncService::ReportPreviousSessionMemoryWarningCount() { sync_prefs_.SetCleanShutdown(false); } +void ProfileSyncService::RecordMemoryUsageHistograms() { + ModelTypeSet active_types = GetActiveDataTypes(); + for (ModelTypeSet::Iterator type_it = active_types.First(); type_it.Good(); + type_it.Inc()) { + auto dtc_it = data_type_controllers_.find(type_it.Get()); + if (dtc_it != data_type_controllers_.end()) + dtc_it->second->RecordMemoryUsageHistogram(); + } +} + const GURL& ProfileSyncService::sync_service_url() const { DCHECK(thread_checker_.CalledOnValidThread()); return sync_service_url_; diff --git a/chromium/components/browser_sync/profile_sync_service.h b/chromium/components/browser_sync/profile_sync_service.h index a713ca3c734..d9c8da9b83b 100644 --- a/chromium/components/browser_sync/profile_sync_service.h +++ b/chromium/components/browser_sync/profile_sync_service.h @@ -25,7 +25,6 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "build/build_config.h" -#include "components/keyed_service/core/keyed_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/signin_manager_base.h" #include "components/sync/base/experiments.h" @@ -170,7 +169,6 @@ class ProfileSyncService : public syncer::SyncServiceBase, public syncer::SyncPrefObserver, public syncer::DataTypeManagerObserver, public syncer::UnrecoverableErrorHandler, - public KeyedService, public OAuth2TokenService::Consumer, public OAuth2TokenService::Observer, public SigninManagerBase::Observer, @@ -384,8 +382,7 @@ class ProfileSyncService : public syncer::SyncServiceBase, // SigninManagerBase::Observer implementation. void GoogleSigninSucceeded(const std::string& account_id, - const std::string& username, - const std::string& password) override; + const std::string& username) override; void GoogleSignedOut(const std::string& account_id, const std::string& username) override; @@ -437,6 +434,10 @@ class ProfileSyncService : public syncer::SyncServiceBase, // Returns whether sync is currently allowed on this platform. bool IsSyncAllowedByPlatform() const; + // Whether sync is currently blocked from starting because the sync + // confirmation dialog hasn't been confirmed. + virtual bool IsSyncConfirmationNeeded() const; + // Returns whether sync is managed, i.e. controlled by configuration // management. If so, the user is not allowed to configure sync. virtual bool IsManaged() const; @@ -681,12 +682,6 @@ class ProfileSyncService : public syncer::SyncServiceBase, bool sync_everything, const syncer::ModelTypeSet chosen_types) const; -#if defined(OS_CHROMEOS) - // Refresh spare sync bootstrap token for re-enabling the sync service. - // Called on successful sign-in notifications. - void RefreshSpareBootstrapToken(const std::string& passphrase); -#endif - // Internal unrecoverable error handler. Used to track error reason via // Sync.UnrecoverableErrors histogram. void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, @@ -723,6 +718,9 @@ class ProfileSyncService : public syncer::SyncServiceBase, // Check if previous shutdown is shutdown cleanly. void ReportPreviousSessionMemoryWarningCount(); + // Estimates and records memory usage histograms per type. + void RecordMemoryUsageHistograms(); + // After user switches to custom passphrase encryption a set of steps needs to // be performed: // diff --git a/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc b/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc index 469864650b5..54135dd7702 100644 --- a/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc +++ b/chromium/components/browser_sync/profile_sync_service_autofill_unittest.cc @@ -196,11 +196,11 @@ class MockAutofillBackend : public autofill::AutofillWebDataBackend { autofill::AutofillWebDataServiceObserverOnDBThread* observer) override {} void RemoveExpiredFormElements() override {} void NotifyOfMultipleAutofillChanges() override { - DCHECK(!ui_thread_->RunsTasksOnCurrentThread()); + DCHECK(!ui_thread_->RunsTasksInCurrentSequence()); ui_thread_->PostTask(FROM_HERE, on_changed_); } void NotifyThatSyncHasStarted(syncer::ModelType model_type) override { - DCHECK(!ui_thread_->RunsTasksOnCurrentThread()); + DCHECK(!ui_thread_->RunsTasksInCurrentSequence()); ui_thread_->PostTask(FROM_HERE, base::Bind(on_sync_started_, model_type)); } @@ -332,7 +332,7 @@ class WebDataServiceFake : public AutofillWebDataService { void CreateSyncableService( const base::Closure& on_changed_callback, const base::Callback<void(syncer::ModelType)>& on_sync_started) { - ASSERT_TRUE(db_thread_->RunsTasksOnCurrentThread()); + ASSERT_TRUE(db_thread_->RunsTasksInCurrentSequence()); // These services are deleted in DestroySyncableService(). backend_ = base::MakeUnique<MockAutofillBackend>( GetDatabase(), on_changed_callback, on_sync_started, ui_thread_.get()); @@ -350,7 +350,7 @@ class WebDataServiceFake : public AutofillWebDataService { } void DestroySyncableService() { - ASSERT_TRUE(db_thread_->RunsTasksOnCurrentThread()); + ASSERT_TRUE(db_thread_->RunsTasksInCurrentSequence()); autocomplete_syncable_service_ = nullptr; autofill_profile_syncable_service_ = nullptr; backend_.reset(); @@ -740,7 +740,7 @@ class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> { void Update() { // This gets called in a modelsafeworker thread. - ASSERT_TRUE(db_thread_->RunsTasksOnCurrentThread()); + ASSERT_TRUE(db_thread_->RunsTasksInCurrentSequence()); syncer::UserShare* user_share = service_->GetUserShare(); syncer::syncable::Directory* directory = user_share->directory.get(); @@ -789,7 +789,7 @@ class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> { void CreateNewEntry(const AutofillEntry& entry) { entry_ = entry; - ASSERT_FALSE(db_thread_->RunsTasksOnCurrentThread()); + ASSERT_FALSE(db_thread_->RunsTasksInCurrentSequence()); if (!db_thread_->PostTask(FROM_HERE, base::Bind(&FakeServerUpdater::Update, this))) { NOTREACHED() << "Failed to post task to the db thread."; diff --git a/chromium/components/browser_sync/profile_sync_service_mock.h b/chromium/components/browser_sync/profile_sync_service_mock.h index 35191d35e42..1df3ffb80c6 100644 --- a/chromium/components/browser_sync/profile_sync_service_mock.h +++ b/chromium/components/browser_sync/profile_sync_service_mock.h @@ -76,6 +76,7 @@ class ProfileSyncServiceMock : public ProfileSyncService { MOCK_CONST_METHOD0(IsSyncActive, bool()); MOCK_CONST_METHOD0(IsEngineInitialized, bool()); MOCK_CONST_METHOD0(IsSyncRequested, bool()); + MOCK_CONST_METHOD0(IsSyncConfirmationNeeded, bool()); MOCK_CONST_METHOD0(waiting_for_auth, bool()); MOCK_METHOD1(OnActionableError, void(const syncer::SyncProtocolError&)); MOCK_CONST_METHOD1(IsDataTypeControllerRunning, bool(syncer::ModelType)); diff --git a/chromium/components/browser_sync/profile_sync_service_startup_unittest.cc b/chromium/components/browser_sync/profile_sync_service_startup_unittest.cc index 9d3e951e6d1..2b603cc3ab5 100644 --- a/chromium/components/browser_sync/profile_sync_service_startup_unittest.cc +++ b/chromium/components/browser_sync/profile_sync_service_startup_unittest.cc @@ -44,7 +44,6 @@ namespace { const char kGaiaId[] = "12345"; const char kEmail[] = "test_user@gmail.com"; -const char kDummyPassword[] = "foobar"; class SyncServiceObserverMock : public syncer::SyncServiceObserver { public: @@ -119,13 +118,14 @@ class ProfileSyncServiceStartupTest : public testing::Test { kEmail); pref_service()->SetString(prefs::kGoogleServicesAccountId, account_id); #if !defined(OS_CHROMEOS) + const char kDummyPassword[] = "foobar"; profile_sync_service_bundle_.signin_manager()->SignIn(kGaiaId, kEmail, kDummyPassword); #else profile_sync_service_bundle_.signin_manager()->SetAuthenticatedAccountInfo( kGaiaId, kEmail); if (sync_service) - sync_service->GoogleSigninSucceeded(account_id, kEmail, kDummyPassword); + sync_service->GoogleSigninSucceeded(account_id, kEmail); #endif return account_id; } @@ -195,6 +195,9 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { auto sync_blocker = sync_service_->GetSetupInProgressHandle(); + // Confirmation isn't needed before sign in occurs. + EXPECT_FALSE(sync_service_->IsSyncConfirmationNeeded()); + // Simulate successful signin as test_user. std::string account_id = SimulateTestUserSignin(sync_service_.get()); ON_CALL(*data_type_manager, IsNigoriEnabled()).WillByDefault(Return(true)); diff --git a/chromium/components/browser_sync/profile_sync_service_unittest.cc b/chromium/components/browser_sync/profile_sync_service_unittest.cc index 4dd3cb85a24..d5aa12bb29d 100644 --- a/chromium/components/browser_sync/profile_sync_service_unittest.cc +++ b/chromium/components/browser_sync/profile_sync_service_unittest.cc @@ -60,7 +60,7 @@ class FakeDataTypeManager : public syncer::DataTypeManager { explicit FakeDataTypeManager(const ConfigureCalled& configure_called) : configure_called_(configure_called) {} - ~FakeDataTypeManager() override{}; + ~FakeDataTypeManager() override {} void Configure(syncer::ModelTypeSet desired_types, syncer::ConfigureReason reason) override { @@ -72,7 +72,7 @@ class FakeDataTypeManager : public syncer::DataTypeManager { void ResetDataTypeErrors() override {} void PurgeForMigration(syncer::ModelTypeSet undesired_types, syncer::ConfigureReason reason) override {} - void Stop() override{}; + void Stop() override {} ModelTypeSet GetActiveDataTypes() const override { return ModelTypeSet(); } bool IsNigoriEnabled() const override { return true; } State state() const override { return syncer::DataTypeManager::CONFIGURED; } @@ -222,6 +222,7 @@ class ProfileSyncServiceTest : public ::testing::Test { prefs()->SetBoolean(syncer::prefs::kEnableLocalSyncBackend, true); init_params.oauth2_token_service = nullptr; init_params.gaia_cookie_manager_service = nullptr; + init_params.signin_wrapper.reset(); service_ = base::MakeUnique<ProfileSyncService>(std::move(init_params)); service_->RegisterDataTypeController( @@ -392,6 +393,7 @@ TEST_F(ProfileSyncServiceTest, SuccessfulLocalBackendInitialization) { InitializeForNthSync(); EXPECT_FALSE(service()->IsManaged()); EXPECT_TRUE(service()->IsSyncActive()); + EXPECT_FALSE(service()->IsSyncConfirmationNeeded()); } // Verify that an initialization where first setup is not complete does not @@ -401,12 +403,14 @@ TEST_F(ProfileSyncServiceTest, NeedsConfirmation) { base::MakeUnique<base::Value>(false)); IssueTestTokens(); CreateService(ProfileSyncService::MANUAL_START); + syncer::SyncPrefs sync_prefs(prefs()); base::Time now = base::Time::Now(); sync_prefs.SetLastSyncedTime(now); sync_prefs.SetKeepEverythingSynced(true); service()->Initialize(); EXPECT_FALSE(service()->IsSyncActive()); + EXPECT_TRUE(service()->IsSyncConfirmationNeeded()); // The last sync time shouldn't be cleared. // TODO(zea): figure out a way to check that the directory itself wasn't diff --git a/chromium/components/browser_sync/profile_sync_test_util.cc b/chromium/components/browser_sync/profile_sync_test_util.cc index 575271243a2..c482bfbeb64 100644 --- a/chromium/components/browser_sync/profile_sync_test_util.cc +++ b/chromium/components/browser_sync/profile_sync_test_util.cc @@ -16,8 +16,8 @@ #include "components/signin/core/browser/signin_manager_base.h" #include "components/sync/base/sync_prefs.h" #include "components/sync/driver/signin_manager_wrapper.h" -#include "components/sync/engine/browser_thread_model_worker.h" #include "components/sync/engine/passive_model_worker.h" +#include "components/sync/engine/sequenced_model_worker.h" #include "components/sync/engine/ui_model_worker.h" #include "net/url_request/url_request_test_util.h" @@ -130,10 +130,9 @@ BundleSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) { DCHECK(file_thread_) << "DB thread was specified but FILE thread was not."; switch (group) { case syncer::GROUP_DB: - return new syncer::BrowserThreadModelWorker(db_thread_, syncer::GROUP_DB); + return new syncer::SequencedModelWorker(db_thread_, syncer::GROUP_DB); case syncer::GROUP_FILE: - return new syncer::BrowserThreadModelWorker(file_thread_, - syncer::GROUP_FILE); + return new syncer::SequencedModelWorker(file_thread_, syncer::GROUP_FILE); case syncer::GROUP_UI: return new syncer::UIModelWorker(base::ThreadTaskRunnerHandle::Get()); case syncer::GROUP_PASSIVE: |