Commit 3accf29c authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Remove SyncService::IsFirstSetupComplete

It has been replaced by SyncUserSettings::IsFirstSetupComplete.
Note that *Profile*SyncService::IsFirstSetupComplete still exists for
now (it's used by SyncUserSettings). This will be changed in a later CL.

There were 3 remaining places that still used the SyncService version
of IsFirstSetupComplete; those are trivially migrated to
SyncUserSettings.

Bug: 884159
Change-Id: I90b29436986a7220803c61e2f2767c620e291e71
Reviewed-on: https://chromium-review.googlesource.com/c/1352785Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612091}
parent 08750528
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "chrome/browser/sync_file_system/syncable_file_system_util.h" #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
...@@ -741,7 +742,7 @@ void SyncFileSystemService::OnFileStatusChanged( ...@@ -741,7 +742,7 @@ void SyncFileSystemService::OnFileStatusChanged(
void SyncFileSystemService::UpdateSyncEnabledStatus( void SyncFileSystemService::UpdateSyncEnabledStatus(
syncer::SyncService* profile_sync_service) { syncer::SyncService* profile_sync_service) {
if (!profile_sync_service->IsFirstSetupComplete()) if (!profile_sync_service->GetUserSettings()->IsFirstSetupComplete())
return; return;
bool old_sync_enabled = sync_enabled_; bool old_sync_enabled = sync_enabled_;
sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has( sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has(
......
...@@ -225,7 +225,7 @@ class ProfileSyncService : public syncer::SyncService, ...@@ -225,7 +225,7 @@ class ProfileSyncService : public syncer::SyncService,
const syncer::SyncUserSettings* GetUserSettings() const override; const syncer::SyncUserSettings* GetUserSettings() const override;
int GetDisableReasons() const override; int GetDisableReasons() const override;
TransportState GetTransportState() const override; TransportState GetTransportState() const override;
bool IsFirstSetupComplete() const override; virtual bool IsFirstSetupComplete() const; // Virtual for testing.
bool IsLocalSyncEnabled() const override; bool IsLocalSyncEnabled() const override;
void TriggerRefresh(const syncer::ModelTypeSet& types) override; void TriggerRefresh(const syncer::ModelTypeSet& types) override;
void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override; void OnDataTypeRequestsSyncStartup(syncer::ModelType type) override;
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browsing_data/core/pref_names.h" #include "components/browsing_data/core/pref_names.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
namespace { namespace {
bool IsAutofillSyncEnabled(const syncer::SyncService* sync_service) { bool IsAutofillSyncEnabled(const syncer::SyncService* sync_service) {
return sync_service && sync_service->IsFirstSetupComplete() && return sync_service &&
sync_service->GetUserSettings()->IsFirstSetupComplete() &&
sync_service->IsSyncFeatureActive() && sync_service->IsSyncFeatureActive() &&
sync_service->GetActiveDataTypes().Has(syncer::AUTOFILL); sync_service->GetActiveDataTypes().Has(syncer::AUTOFILL);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/values.h" #include "base/values.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_token_status.h" #include "components/sync/driver/sync_token_status.h"
#include "components/sync/driver/sync_user_settings.h"
#include "components/sync/engine/cycle/sync_cycle_snapshot.h" #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
#include "components/sync/engine/sync_status.h" #include "components/sync/engine/sync_status.h"
#include "components/sync/engine/sync_string_conversions.h" #include "components/sync/engine/sync_string_conversions.h"
...@@ -483,7 +484,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( ...@@ -483,7 +484,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
// Local State. // Local State.
server_connection->Set(GetConnectionStatus(token_status)); server_connection->Set(GetConnectionStatus(token_status));
last_synced->Set(GetLastSyncedTimeString(service->GetLastSyncedTime())); last_synced->Set(GetLastSyncedTimeString(service->GetLastSyncedTime()));
is_setup_complete->Set(service->IsFirstSetupComplete()); is_setup_complete->Set(service->GetUserSettings()->IsFirstSetupComplete());
if (is_status_valid) if (is_status_valid)
is_syncing->Set(full_status.syncing); is_syncing->Set(full_status.syncing);
is_local_sync_enabled->Set(service->IsLocalSyncEnabled()); is_local_sync_enabled->Set(service->IsLocalSyncEnabled());
......
...@@ -43,10 +43,6 @@ bool FakeSyncService::IsAuthenticatedAccountPrimary() const { ...@@ -43,10 +43,6 @@ bool FakeSyncService::IsAuthenticatedAccountPrimary() const {
return true; return true;
} }
bool FakeSyncService::IsFirstSetupComplete() const {
return false;
}
bool FakeSyncService::IsLocalSyncEnabled() const { bool FakeSyncService::IsLocalSyncEnabled() const {
return false; return false;
} }
......
...@@ -30,7 +30,6 @@ class FakeSyncService : public SyncService { ...@@ -30,7 +30,6 @@ class FakeSyncService : public SyncService {
TransportState GetTransportState() const override; TransportState GetTransportState() const override;
AccountInfo GetAuthenticatedAccountInfo() const override; AccountInfo GetAuthenticatedAccountInfo() const override;
bool IsAuthenticatedAccountPrimary() const override; bool IsAuthenticatedAccountPrimary() const override;
bool IsFirstSetupComplete() const override;
bool IsLocalSyncEnabled() const override; bool IsLocalSyncEnabled() const override;
void TriggerRefresh(const ModelTypeSet& types) override; void TriggerRefresh(const ModelTypeSet& types) override;
ModelTypeSet GetActiveDataTypes() const override; ModelTypeSet GetActiveDataTypes() const override;
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
namespace syncer { namespace syncer {
SyncSetupInProgressHandle::SyncSetupInProgressHandle(base::Closure on_destroy) SyncSetupInProgressHandle::SyncSetupInProgressHandle(base::Closure on_destroy)
...@@ -17,7 +19,7 @@ bool SyncService::IsSyncFeatureEnabled() const { ...@@ -17,7 +19,7 @@ bool SyncService::IsSyncFeatureEnabled() const {
// Note: IsFirstSetupComplete() shouldn't usually be true if we don't have a // Note: IsFirstSetupComplete() shouldn't usually be true if we don't have a
// primary account, but it could happen if the account changes from primary to // primary account, but it could happen if the account changes from primary to
// secondary. // secondary.
return CanSyncFeatureStart() && IsFirstSetupComplete(); return CanSyncFeatureStart() && GetUserSettings()->IsFirstSetupComplete();
} }
bool SyncService::CanSyncFeatureStart() const { bool SyncService::CanSyncFeatureStart() const {
...@@ -61,7 +63,7 @@ bool SyncService::IsSyncFeatureActive() const { ...@@ -61,7 +63,7 @@ bool SyncService::IsSyncFeatureActive() const {
} }
bool SyncService::IsFirstSetupInProgress() const { bool SyncService::IsFirstSetupInProgress() const {
return !IsFirstSetupComplete() && IsSetupInProgress(); return !GetUserSettings()->IsFirstSetupComplete() && IsSetupInProgress();
} }
bool SyncService::HasUnrecoverableError() const { bool SyncService::HasUnrecoverableError() const {
......
...@@ -216,14 +216,6 @@ class SyncService : public DataTypeEncryptionHandler, public KeyedService { ...@@ -216,14 +216,6 @@ class SyncService : public DataTypeEncryptionHandler, public KeyedService {
// independent of first-setup state. // independent of first-setup state.
bool IsFirstSetupInProgress() const; bool IsFirstSetupInProgress() const;
// Whether the user has completed the initial Sync setup. This does not mean
// that sync is currently running (due to delayed startup, unrecoverable
// errors, or shutdown). If you want to know whether Sync is actually running,
// use GetTransportState or IsSyncFeatureActive instead.
// Note: This refers to Sync-the-feature. Sync-the-transport may be active
// independent of first-setup state.
virtual bool IsFirstSetupComplete() const = 0;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// SETUP-IN-PROGRESS HANDLING // SETUP-IN-PROGRESS HANDLING
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
......
...@@ -68,7 +68,7 @@ void TestSyncService::SetAuthError(const GoogleServiceAuthError& auth_error) { ...@@ -68,7 +68,7 @@ void TestSyncService::SetAuthError(const GoogleServiceAuthError& auth_error) {
} }
void TestSyncService::SetFirstSetupComplete(bool first_setup_complete) { void TestSyncService::SetFirstSetupComplete(bool first_setup_complete) {
first_setup_complete_ = first_setup_complete; user_settings_.SetFirstSetupComplete(first_setup_complete);
} }
void TestSyncService::SetPreferredDataTypes(const ModelTypeSet& types) { void TestSyncService::SetPreferredDataTypes(const ModelTypeSet& types) {
...@@ -127,10 +127,6 @@ const GoogleServiceAuthError& TestSyncService::GetAuthError() const { ...@@ -127,10 +127,6 @@ const GoogleServiceAuthError& TestSyncService::GetAuthError() const {
return auth_error_; return auth_error_;
} }
bool TestSyncService::IsFirstSetupComplete() const {
return first_setup_complete_;
}
std::unique_ptr<SyncSetupInProgressHandle> std::unique_ptr<SyncSetupInProgressHandle>
TestSyncService::GetSetupInProgressHandle() { TestSyncService::GetSetupInProgressHandle() {
return nullptr; return nullptr;
......
...@@ -51,8 +51,6 @@ class TestSyncService : public SyncService { ...@@ -51,8 +51,6 @@ class TestSyncService : public SyncService {
bool IsAuthenticatedAccountPrimary() const override; bool IsAuthenticatedAccountPrimary() const override;
const GoogleServiceAuthError& GetAuthError() const override; const GoogleServiceAuthError& GetAuthError() const override;
bool IsFirstSetupComplete() const override;
std::unique_ptr<SyncSetupInProgressHandle> GetSetupInProgressHandle() std::unique_ptr<SyncSetupInProgressHandle> GetSetupInProgressHandle()
override; override;
bool IsSetupInProgress() const override; bool IsSetupInProgress() const override;
...@@ -112,7 +110,6 @@ class TestSyncService : public SyncService { ...@@ -112,7 +110,6 @@ class TestSyncService : public SyncService {
AccountInfo account_info_; AccountInfo account_info_;
bool account_is_primary_ = true; bool account_is_primary_ = true;
GoogleServiceAuthError auth_error_; GoogleServiceAuthError auth_error_;
bool first_setup_complete_ = true;
ModelTypeSet preferred_data_types_; ModelTypeSet preferred_data_types_;
ModelTypeSet active_data_types_; ModelTypeSet active_data_types_;
......
...@@ -46,11 +46,11 @@ void TestSyncUserSettings::SetSyncAllowedByPlatform(bool allowed) { ...@@ -46,11 +46,11 @@ void TestSyncUserSettings::SetSyncAllowedByPlatform(bool allowed) {
} }
bool TestSyncUserSettings::IsFirstSetupComplete() const { bool TestSyncUserSettings::IsFirstSetupComplete() const {
return service_->IsFirstSetupComplete(); return first_setup_complete_;
} }
void TestSyncUserSettings::SetFirstSetupComplete() { void TestSyncUserSettings::SetFirstSetupComplete() {
service_->SetFirstSetupComplete(true); SetFirstSetupComplete(true);
} }
bool TestSyncUserSettings::IsSyncEverythingEnabled() const { bool TestSyncUserSettings::IsSyncEverythingEnabled() const {
...@@ -121,4 +121,8 @@ bool TestSyncUserSettings::SetDecryptionPassphrase( ...@@ -121,4 +121,8 @@ bool TestSyncUserSettings::SetDecryptionPassphrase(
return service_->SetDecryptionPassphrase(passphrase); return service_->SetDecryptionPassphrase(passphrase);
} }
void TestSyncUserSettings::SetFirstSetupComplete(bool first_setup_complete) {
first_setup_complete_ = first_setup_complete;
}
} // namespace syncer } // namespace syncer
...@@ -47,9 +47,12 @@ class TestSyncUserSettings : public SyncUserSettings { ...@@ -47,9 +47,12 @@ class TestSyncUserSettings : public SyncUserSettings {
void SetEncryptionPassphrase(const std::string& passphrase) override; void SetEncryptionPassphrase(const std::string& passphrase) override;
bool SetDecryptionPassphrase(const std::string& passphrase) override; bool SetDecryptionPassphrase(const std::string& passphrase) override;
void SetFirstSetupComplete(bool first_setup_complete);
private: private:
TestSyncService* service_; TestSyncService* service_;
bool first_setup_complete_ = true;
bool sync_everything_enabled_ = true; bool sync_everything_enabled_ = true;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment