diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 21:33:40 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-20 21:33:40 +0000 |
commit | 34f5405bf386e659e2058aa232f2061f4586e0b4 (patch) | |
tree | 95fe8e3192d8a27bf48782d42957080a64e53b8f | |
parent | 271b8dad376b640e0e42a18218fae1264cb0924c (diff) | |
download | chromium_src-34f5405bf386e659e2058aa232f2061f4586e0b4.zip chromium_src-34f5405bf386e659e2058aa232f2061f4586e0b4.tar.gz chromium_src-34f5405bf386e659e2058aa232f2061f4586e0b4.tar.bz2 |
[Sync] Move SyncPrefs into sync_driver component
This also moves all sync preferences out of the common pref_names file and into
a sync_driver specific pref_names. To allow that, the dependency on history
policy is moved into the typed_url_data_type_controller, and a dependency
on the deprecated acknowledged types pref is removed from ntp_resource_cache.
BUG=339726
R=blundell@chromium.org, mnissler@chromium.org, rlarocque@chromium.org
TBR=atwilson@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/195873020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258415 0039d316-1c4b-4281-b951-d872f2087c98
56 files changed, 510 insertions, 386 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 294b410..1286def 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -28,6 +28,7 @@ include_rules = [ "+components/rappor", "+components/sessions", "+components/signin", + "+components/sync_driver", "+components/startup_metric_utils", "+components/storage_monitor", "+components/translate/content/browser", diff --git a/chrome/browser/autocomplete/base_search_provider.cc b/chrome/browser/autocomplete/base_search_provider.cc index 87b67ce..06e3cf3 100644 --- a/chrome/browser/autocomplete/base_search_provider.cc +++ b/chrome/browser/autocomplete/base_search_provider.cc @@ -25,6 +25,7 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/pref_names.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/common/url_constants.h" #include "net/base/escape.h" #include "net/base/net_util.h" @@ -578,7 +579,7 @@ bool BaseSearchProvider::CanSendURL( // Check field trials and settings allow sending the URL on suggest requests. ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); - browser_sync::SyncPrefs sync_prefs(profile->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); if (service == NULL || !service->IsSyncEnabledAndLoggedIn() || !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index f9a3442..ae57ff8 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -39,6 +39,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" +#include "components/sync_driver/pref_names.h" #include "components/variations/entropy_provider.h" #include "content/public/test/test_browser_thread_bundle.h" #include "net/url_request/test_url_fetcher_factory.h" @@ -4005,13 +4006,14 @@ TEST_F(SearchProviderTest, CanSendURL) { AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); // Tab sync not enabled. - profile_.GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); - profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, false); + profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncKeepEverythingSynced, + false); + profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, false); EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, AutocompleteInput::OTHER, &profile_)); - profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, true); + profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, true); // Tab sync is encrypted. ProfileSyncService* service = diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc index de43a4c..c85fc04 100644 --- a/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc +++ b/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc @@ -7,8 +7,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/extensions/api/preferences_private.h" +#include "components/sync_driver/sync_prefs.h" namespace extensions { @@ -46,7 +46,7 @@ bool PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction::RunImpl() { syncer::ModelTypeSet result_set = syncer::UserSelectableTypes(); // Only include categories that are synced. - browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); if (!sync_prefs.HasKeepEverythingSynced()) { result_set = syncer::Intersection(result_set, sync_service->GetPreferredDataTypes()); diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc index c92f4fb..e521c3f 100644 --- a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc +++ b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc @@ -25,6 +25,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/base/testing_profile.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_context.h" using extensions::PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction; @@ -116,7 +117,7 @@ class PreferencesPrivateApiTest : public ExtensionApiTest { Profile* profile = Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); - browser_sync::SyncPrefs sync_prefs(profile->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); sync_prefs.SetKeepEverythingSynced(false); ProfileManager* profile_manager = g_browser_process->profile_manager(); diff --git a/chrome/browser/extensions/extension_sync_service.cc b/chrome/browser/extensions/extension_sync_service.cc index 87b6623..e5de8db 100644 --- a/chrome/browser/extensions/extension_sync_service.cc +++ b/chrome/browser/extensions/extension_sync_service.cc @@ -19,8 +19,8 @@ #include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/glue/sync_start_util.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/extensions/sync_helper.h" +#include "components/sync_driver/sync_prefs.h" #include "extensions/browser/app_sorting.h" #include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_registry.h" @@ -44,16 +44,14 @@ ExtensionSyncService::ExtensionSyncService(Profile* profile, extension_service_(extension_service), app_sync_bundle_(this), extension_sync_bundle_(this), - pending_app_enables_( - make_scoped_ptr(new browser_sync::SyncPrefs( - extension_prefs_->pref_service())), - &app_sync_bundle_, - syncer::APPS), - pending_extension_enables_( - make_scoped_ptr(new browser_sync::SyncPrefs( - extension_prefs_->pref_service())), - &extension_sync_bundle_, - syncer::EXTENSIONS), + pending_app_enables_(make_scoped_ptr(new sync_driver::SyncPrefs( + extension_prefs_->pref_service())), + &app_sync_bundle_, + syncer::APPS), + pending_extension_enables_(make_scoped_ptr(new sync_driver::SyncPrefs( + extension_prefs_->pref_service())), + &extension_sync_bundle_, + syncer::EXTENSIONS), extesnion_gcm_app_handler_(new ExtensionGCMAppHandler(profile)) { SetSyncStartFlare(sync_start_util::GetFlareForSyncableService( profile_->GetPath())); diff --git a/chrome/browser/extensions/external_component_loader.cc b/chrome/browser/extensions/external_component_loader.cc index ad197e8..15d9d04 100644 --- a/chrome/browser/extensions/external_component_loader.cc +++ b/chrome/browser/extensions/external_component_loader.cc @@ -15,6 +15,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" +#include "components/sync_driver/pref_names.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/browser_thread.h" @@ -57,7 +58,7 @@ void ExternalComponentLoader::StartLoading() { BookmarksExperimentState bookmarks_experiment_state_before = static_cast<BookmarksExperimentState>(profile_->GetPrefs()->GetInteger( - prefs::kEnhancedBookmarksExperimentEnabled)); + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); if (bookmarks_experiment_state_before == kBookmarksExperimentEnabled) { // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". // "0" - user opted out. @@ -65,7 +66,7 @@ void ExternalComponentLoader::StartLoading() { switches::kEnhancedBookmarksExperiment) != "0") { // Experiment enabled. std::string ext_id = profile_->GetPrefs()->GetString( - prefs::kEnhancedBookmarksExtensionId); + sync_driver::prefs::kEnhancedBookmarksExtensionId); if (!ext_id.empty()) { prefs_->SetString(ext_id + ".external_update_url", extension_urls::GetWebstoreUpdateUrl().spec()); @@ -73,7 +74,7 @@ void ExternalComponentLoader::StartLoading() { } else { // Experiment enabled but user opted out. profile_->GetPrefs()->SetInteger( - prefs::kEnhancedBookmarksExperimentEnabled, + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, kBookmarksExperimentEnabledUserOptOut); } } else if (bookmarks_experiment_state_before == @@ -82,10 +83,10 @@ void ExternalComponentLoader::StartLoading() { switches::kEnhancedBookmarksExperiment) != "0") { // User opted in again. profile_->GetPrefs()->SetInteger( - prefs::kEnhancedBookmarksExperimentEnabled, + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, kBookmarksExperimentEnabled); std::string ext_id = profile_->GetPrefs()->GetString( - prefs::kEnhancedBookmarksExtensionId); + sync_driver::prefs::kEnhancedBookmarksExtensionId); if (!ext_id.empty()) { prefs_->SetString(ext_id + ".external_update_url", extension_urls::GetWebstoreUpdateUrl().spec()); @@ -93,12 +94,14 @@ void ExternalComponentLoader::StartLoading() { } } else { // Experiment disabled. - profile_->GetPrefs()->ClearPref(prefs::kEnhancedBookmarksExperimentEnabled); - profile_->GetPrefs()->ClearPref(prefs::kEnhancedBookmarksExtensionId); + profile_->GetPrefs()->ClearPref( + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled); + profile_->GetPrefs()->ClearPref( + sync_driver::prefs::kEnhancedBookmarksExtensionId); } BookmarksExperimentState bookmarks_experiment_state = static_cast<BookmarksExperimentState>(profile_->GetPrefs()->GetInteger( - prefs::kEnhancedBookmarksExperimentEnabled)); + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); if (bookmarks_experiment_state_before != bookmarks_experiment_state) { UpdateBookmarksExperiment(g_browser_process->local_state(), bookmarks_experiment_state); diff --git a/chrome/browser/extensions/pending_enables.cc b/chrome/browser/extensions/pending_enables.cc index f7af99d..64558c5 100644 --- a/chrome/browser/extensions/pending_enables.cc +++ b/chrome/browser/extensions/pending_enables.cc @@ -6,18 +6,17 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/sync_bundle.h" -#include "chrome/browser/sync/sync_prefs.h" +#include "components/sync_driver/sync_prefs.h" namespace extensions { -PendingEnables::PendingEnables(scoped_ptr<browser_sync::SyncPrefs> sync_prefs, +PendingEnables::PendingEnables(scoped_ptr<sync_driver::SyncPrefs> sync_prefs, SyncBundle* sync_bundle, syncer::ModelType enable_type) : sync_prefs_(sync_prefs.Pass()), sync_bundle_(sync_bundle), enable_type_(enable_type), - is_sync_enabled_for_test_(false) { -} + is_sync_enabled_for_test_(false) {} PendingEnables::~PendingEnables() { } diff --git a/chrome/browser/extensions/pending_enables.h b/chrome/browser/extensions/pending_enables.h index 2c3d590..fb1a16b 100644 --- a/chrome/browser/extensions/pending_enables.h +++ b/chrome/browser/extensions/pending_enables.h @@ -15,7 +15,7 @@ class ExtensionService; class ProfileSyncService; -namespace browser_sync { +namespace sync_driver { class SyncPrefs; } @@ -29,7 +29,7 @@ class SyncBundle; // server when sync does start. class PendingEnables { public: - PendingEnables(scoped_ptr<browser_sync::SyncPrefs> sync_prefs, + PendingEnables(scoped_ptr<sync_driver::SyncPrefs> sync_prefs, SyncBundle* sync_bundle, syncer::ModelType enable_type); ~PendingEnables(); @@ -51,7 +51,7 @@ class PendingEnables { bool IsSyncEnabled(); bool IsWaitingForSync(); - scoped_ptr<browser_sync::SyncPrefs> sync_prefs_; + scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; SyncBundle* sync_bundle_; syncer::ModelType enable_type_; std::set<std::string> ids_; diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 1dc94cf..4edd2ab 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -71,7 +71,6 @@ #include "chrome/browser/signin/easy_unlock_controller.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_promo.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/browser/task_manager/task_manager.h" #include "chrome/browser/ui/app_list/app_list_service.h" #include "chrome/browser/ui/browser_ui_prefs.h" @@ -95,6 +94,7 @@ #include "components/autofill/core/browser/autofill_manager.h" #include "components/password_manager/core/browser/password_manager.h" #include "components/rappor/rappor_service.h" +#include "components/sync_driver/sync_prefs.h" #include "components/translate/core/browser/translate_prefs.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/render_process_host.h" @@ -340,7 +340,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { autofill::AutofillManager::RegisterProfilePrefs(registry); BookmarkPromptPrefs::RegisterProfilePrefs(registry); bookmark_utils::RegisterProfilePrefs(registry); - browser_sync::SyncPrefs::RegisterProfilePrefs(registry); + sync_driver::SyncPrefs::RegisterProfilePrefs(registry); ChromeContentBrowserClient::RegisterProfilePrefs(registry); ChromeVersionService::RegisterProfilePrefs(registry); chrome_browser_net::HttpServerPropertiesManager::RegisterProfilePrefs( diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index c93ad22..11f322d 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -13,8 +13,8 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/pref_names.h" +#include "components/sync_driver/sync_prefs.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" @@ -204,7 +204,7 @@ bool Profile::IsSyncAccessible() { // No ProfileSyncService created yet - we don't want to create one, so just // infer the accessible state by looking at prefs/command line flags. - browser_sync::SyncPrefs prefs(GetPrefs()); + sync_driver::SyncPrefs prefs(GetPrefs()); return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); } diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index fd5a029..0487c01 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -50,6 +50,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "components/startup_metric_utils/startup_metric_utils.h" +#include "components/sync_driver/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/host_zoom_map.h" #include "content/public/browser/notification_service.h" @@ -408,7 +409,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { prefs::kReverseAutologinRejectedEmailList, pref_service); one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); - sync_disabled_.Init(prefs::kSyncManaged, pref_service); + sync_disabled_.Init(sync_driver::prefs::kSyncManaged, pref_service); sync_disabled_.MoveToThread(io_message_loop_proxy); signin_allowed_.Init(prefs::kSigninAllowed, pref_service); diff --git a/chrome/browser/signin/signin_manager_base.cc b/chrome/browser/signin/signin_manager_base.cc index fc8f2e6..e9504c9 100644 --- a/chrome/browser/signin/signin_manager_base.cc +++ b/chrome/browser/signin/signin_manager_base.cc @@ -16,9 +16,9 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/signin/about_signin_internals.h" #include "chrome/browser/signin/about_signin_internals_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_thread.h" #include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_constants.h" diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc index 42f04dc..0287961 100644 --- a/chrome/browser/sync/glue/session_model_associator.cc +++ b/chrome/browser/sync/glue/session_model_associator.cc @@ -29,9 +29,9 @@ #include "chrome/browser/sync/glue/synced_window_delegate.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "components/sessions/serialized_navigation_entry.h" +#include "components/sync_driver/sync_prefs.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/favicon_status.h" @@ -58,7 +58,6 @@ using content::BrowserThread; using content::NavigationEntry; -using prefs::kSyncSessionsGUID; using sessions::SerializedNavigationEntry; using syncer::SESSIONS; @@ -692,7 +691,7 @@ void SessionModelAssociator::InitializeCurrentMachineTag( DCHECK(CalledOnValidThread()); DCHECK(current_machine_tag_.empty()); std::string persisted_guid; - browser_sync::SyncPrefs prefs(profile_->GetPrefs()); + sync_driver::SyncPrefs prefs(profile_->GetPrefs()); persisted_guid = prefs.GetSyncSessionsGUID(); if (!persisted_guid.empty()) { current_machine_tag_ = persisted_guid; diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.cc b/chrome/browser/sync/glue/sync_backend_host_impl.cc index 8a9a3bf..f5b2f6e 100644 --- a/chrome/browser/sync/glue/sync_backend_host_impl.cc +++ b/chrome/browser/sync/glue/sync_backend_host_impl.cc @@ -12,9 +12,9 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/glue/sync_backend_host_core.h" #include "chrome/browser/sync/glue/sync_backend_registrar.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/chrome_switches.h" #include "components/sync_driver/sync_frontend.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -46,7 +46,7 @@ namespace browser_sync { SyncBackendHostImpl::SyncBackendHostImpl( const std::string& name, Profile* profile, - const base::WeakPtr<SyncPrefs>& sync_prefs) + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs) : frontend_loop_(base::MessageLoop::current()), profile_(profile), name_(name), diff --git a/chrome/browser/sync/glue/sync_backend_host_impl.h b/chrome/browser/sync/glue/sync_backend_host_impl.h index 4a65f46..b2ed962 100644 --- a/chrome/browser/sync/glue/sync_backend_host_impl.h +++ b/chrome/browser/sync/glue/sync_backend_host_impl.h @@ -46,12 +46,15 @@ class NetworkResources; class SyncManagerFactory; } +namespace sync_driver { +class SyncPrefs; +} + namespace browser_sync { class ChangeProcessor; class SyncBackendHostCore; class SyncBackendRegistrar; -class SyncPrefs; class SyncedDeviceTracker; struct DoInitializeOptions; @@ -68,10 +71,9 @@ class SyncBackendHostImpl // it serves and communicates to via the SyncFrontend interface (on // the same thread it used to call the constructor). Must outlive // |sync_prefs|. - SyncBackendHostImpl( - const std::string& name, - Profile* profile, - const base::WeakPtr<SyncPrefs>& sync_prefs); + SyncBackendHostImpl(const std::string& name, + Profile* profile, + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs); virtual ~SyncBackendHostImpl(); // SyncBackendHost implementation. @@ -280,7 +282,7 @@ class SyncBackendHostImpl bool initialized_; - const base::WeakPtr<SyncPrefs> sync_prefs_; + const base::WeakPtr<sync_driver::SyncPrefs> sync_prefs_; ExtensionsActivityMonitor extensions_activity_monitor_; diff --git a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc index 483d53b..62553d1 100644 --- a/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc +++ b/chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc @@ -17,9 +17,9 @@ #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/sync/glue/device_info.h" #include "chrome/browser/sync/glue/synced_device_tracker.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/test/base/testing_profile.h" #include "components/sync_driver/sync_frontend.h" +#include "components/sync_driver/sync_prefs.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -135,7 +135,7 @@ class SyncBackendHostTest : public testing::Test { virtual void SetUp() OVERRIDE { profile_.reset(new TestingProfile()); - sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); + sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); backend_.reset(new SyncBackendHostImpl( profile_->GetDebugName(), profile_.get(), @@ -255,7 +255,7 @@ class SyncBackendHostTest : public testing::Test { StrictMock<MockSyncFrontend> mock_frontend_; syncer::SyncCredentials credentials_; scoped_ptr<TestingProfile> profile_; - scoped_ptr<SyncPrefs> sync_prefs_; + scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; scoped_ptr<SyncBackendHost> backend_; scoped_ptr<FakeSyncManagerFactory> fake_manager_factory_; FakeSyncManager* fake_manager_; diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.cc b/chrome/browser/sync/glue/typed_url_data_type_controller.cc index 2587999..7a56c18 100644 --- a/chrome/browser/sync/glue/typed_url_data_type_controller.cc +++ b/chrome/browser/sync/glue/typed_url_data_type_controller.cc @@ -92,6 +92,22 @@ syncer::ModelSafeGroup TypedUrlDataTypeController::model_safe_group() return syncer::GROUP_HISTORY; } +void TypedUrlDataTypeController::LoadModels( + const ModelLoadCallback& model_load_callback) { + if (profile()->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)) { + model_load_callback.Run( + type(), + syncer::SyncError(FROM_HERE, + syncer::SyncError::DATATYPE_ERROR, + "History sync disabled by policy.", + type())); + return; + } + + set_state(MODEL_LOADED); + model_load_callback.Run(type(), syncer::SyncError()); +} + void TypedUrlDataTypeController::SetBackend(history::HistoryBackend* backend) { DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); backend_ = backend; diff --git a/chrome/browser/sync/glue/typed_url_data_type_controller.h b/chrome/browser/sync/glue/typed_url_data_type_controller.h index 95b087b..ce2a7863 100644 --- a/chrome/browser/sync/glue/typed_url_data_type_controller.h +++ b/chrome/browser/sync/glue/typed_url_data_type_controller.h @@ -34,6 +34,8 @@ class TypedUrlDataTypeController : public NonFrontendDataTypeController { // NonFrontendDataTypeController implementation virtual syncer::ModelType type() const OVERRIDE; virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE; + virtual void LoadModels(const ModelLoadCallback& model_load_callback) + OVERRIDE; // Invoked on the history thread to set our history backend - must be called // before CreateSyncComponents() is invoked. diff --git a/chrome/browser/sync/profile_sync_components_factory.h b/chrome/browser/sync/profile_sync_components_factory.h index 36058e7..3212f11 100644 --- a/chrome/browser/sync/profile_sync_components_factory.h +++ b/chrome/browser/sync/profile_sync_components_factory.h @@ -29,10 +29,13 @@ class FailedDataTypesHandler; class GenericChangeProcessor; class SharedChangeProcessor; class SyncBackendHost; -class SyncPrefs; class DataTypeErrorHandler; } // namespace browser_sync +namespace sync_driver { +class SyncPrefs; +} + namespace syncer { class DataTypeDebugInfoListener; class SyncableService; @@ -88,7 +91,7 @@ class ProfileSyncComponentsFactory { virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( const std::string& name, Profile* profile, - const base::WeakPtr<browser_sync::SyncPrefs>& sync_prefs) = 0; + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs) = 0; // Creating this in the factory helps us mock it out in testing. virtual browser_sync::GenericChangeProcessor* CreateGenericChangeProcessor( diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index 93996d2..44f5a5b 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -430,10 +430,10 @@ DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( } browser_sync::SyncBackendHost* - ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost( - const std::string& name, - Profile* profile, - const base::WeakPtr<browser_sync::SyncPrefs>& sync_prefs) { +ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost( + const std::string& name, + Profile* profile, + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs) { return new browser_sync::SyncBackendHostImpl(name, profile, sync_prefs); } diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.h b/chrome/browser/sync/profile_sync_components_factory_impl.h index 8186ad1..31f8f5b 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.h +++ b/chrome/browser/sync/profile_sync_components_factory_impl.h @@ -43,7 +43,7 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory { virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( const std::string& name, Profile* profile, - const base::WeakPtr<browser_sync::SyncPrefs>& sync_prefs) OVERRIDE; + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs) OVERRIDE; virtual browser_sync::GenericChangeProcessor* CreateGenericChangeProcessor( ProfileSyncService* profile_sync_service, diff --git a/chrome/browser/sync/profile_sync_components_factory_mock.h b/chrome/browser/sync/profile_sync_components_factory_mock.h index 67b877a..11e9cb4 100644 --- a/chrome/browser/sync/profile_sync_components_factory_mock.h +++ b/chrome/browser/sync/profile_sync_components_factory_mock.h @@ -38,10 +38,10 @@ class ProfileSyncComponentsFactoryMock : public ProfileSyncComponentsFactory { browser_sync::FailedDataTypesHandler* failed_datatypes_handler)); MOCK_METHOD3(CreateSyncBackendHost, - browser_sync::SyncBackendHost*( - const std::string& name, - Profile* profile, - const base::WeakPtr<browser_sync::SyncPrefs>& sync_prefs)); + browser_sync::SyncBackendHost*( + const std::string& name, + Profile* profile, + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs)); MOCK_METHOD4(CreateGenericChangeProcessor, browser_sync::GenericChangeProcessor*( ProfileSyncService* profile_sync_service, diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 5bae7d1..616c2bb 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -64,6 +64,7 @@ #include "chrome/common/url_constants.h" #include "components/signin/core/profile_oauth2_token_service.h" #include "components/sync_driver/data_type_controller.h" +#include "components/sync_driver/pref_names.h" #include "components/sync_driver/system_encryptor.h" #include "components/sync_driver/user_selectable_sync_type.h" #include "components/user_prefs/pref_registry_syncable.h" @@ -310,7 +311,8 @@ void ProfileSyncService::TrySyncDatatypePrefRecovery() { return; const PrefService::Preference* keep_everything_synced = - pref_service->FindPreference(prefs::kSyncKeepEverythingSynced); + pref_service->FindPreference( + sync_driver::prefs::kSyncKeepEverythingSynced); // This will be false if the preference was properly set or if it's controlled // by policy. if (!keep_everything_synced->IsDefaultValue()) @@ -1010,35 +1012,38 @@ void ProfileSyncService::OnExperimentsChanged( } int bookmarks_experiment_state_before = profile_->GetPrefs()->GetInteger( - prefs::kEnhancedBookmarksExperimentEnabled); + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled); // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". // "" and "1" means experiment is enabled. if ((CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kEnhancedBookmarksExperiment) != "0")) { - profile_->GetPrefs()->SetInteger(prefs::kEnhancedBookmarksExperimentEnabled, - experiments.enhanced_bookmarks_enabled ? - kBookmarksExperimentEnabled : - kNoBookmarksExperiment); - profile_->GetPrefs()->SetString(prefs::kEnhancedBookmarksExtensionId, - experiments.enhanced_bookmarks_ext_id); + profile_->GetPrefs()->SetInteger( + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, + experiments.enhanced_bookmarks_enabled ? kBookmarksExperimentEnabled + : kNoBookmarksExperiment); + profile_->GetPrefs()->SetString( + sync_driver::prefs::kEnhancedBookmarksExtensionId, + experiments.enhanced_bookmarks_ext_id); } else { // User opt-out from chrome://flags if (experiments.enhanced_bookmarks_enabled) { profile_->GetPrefs()->SetInteger( - prefs::kEnhancedBookmarksExperimentEnabled, + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled, kBookmarksExperimentEnabledUserOptOut); // Keep extension id up-to-date in case will opt-in later. - profile_->GetPrefs()->SetString(prefs::kEnhancedBookmarksExtensionId, - experiments.enhanced_bookmarks_ext_id); + profile_->GetPrefs()->SetString( + sync_driver::prefs::kEnhancedBookmarksExtensionId, + experiments.enhanced_bookmarks_ext_id); } else { profile_->GetPrefs()->ClearPref( - prefs::kEnhancedBookmarksExperimentEnabled); - profile_->GetPrefs()->ClearPref(prefs::kEnhancedBookmarksExtensionId); + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled); + profile_->GetPrefs()->ClearPref( + sync_driver::prefs::kEnhancedBookmarksExtensionId); } } BookmarksExperimentState bookmarks_experiment_state = static_cast<BookmarksExperimentState>(profile_->GetPrefs()->GetInteger( - prefs::kEnhancedBookmarksExperimentEnabled)); + sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); // If bookmark experiment state was changed update about flags experiment. if (bookmarks_experiment_state_before != bookmarks_experiment_state) { UpdateBookmarksExperiment(g_browser_process->local_state(), @@ -2126,7 +2131,7 @@ void ProfileSyncService::UnsuppressAndStart() { if (signin_.get() && signin_->GetOriginal()->GetAuthenticatedUsername().empty()) { signin_->GetOriginal()->SetAuthenticatedUsername( - sync_prefs_.GetGoogleServicesUsername()); + profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); } startup_controller_.TryStart(); } diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index eb89d2f..0b3c439 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -27,7 +27,6 @@ #include "chrome/browser/sync/profile_sync_service_observer.h" #include "chrome/browser/sync/sessions2/sessions_sync_manager.h" #include "chrome/browser/sync/startup_controller.h" -#include "chrome/browser/sync/sync_prefs.h" #include "components/keyed_service/core/keyed_service.h" #include "components/sync_driver/data_type_controller.h" #include "components/sync_driver/data_type_encryption_handler.h" @@ -35,6 +34,7 @@ #include "components/sync_driver/data_type_manager_observer.h" #include "components/sync_driver/failed_data_types_handler.h" #include "components/sync_driver/sync_frontend.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_types.h" @@ -169,7 +169,7 @@ using browser_sync::SessionsSyncManager; // class ProfileSyncService : public ProfileSyncServiceBase, public browser_sync::SyncFrontend, - public browser_sync::SyncPrefObserver, + public sync_driver::SyncPrefObserver, public browser_sync::DataTypeManagerObserver, public syncer::UnrecoverableErrorHandler, public content::NotificationObserver, @@ -864,7 +864,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, // The class that handles getting, setting, and persisting sync // preferences. - browser_sync::SyncPrefs sync_prefs_; + sync_driver::SyncPrefs sync_prefs_; // TODO(ncarter): Put this in a profile, once there is UI for it. // This specifies where to find the sync server. diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc index 9717168..8ee0e7a 100644 --- a/chrome/browser/sync/profile_sync_service_android.cc +++ b/chrome/browser/sync/profile_sync_service_android.cc @@ -22,9 +22,9 @@ #include "chrome/browser/sync/about_sync_util.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/browser/sync/sync_ui_util.h" -#include "chrome/common/pref_names.h" +#include "components/sync_driver/pref_names.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" @@ -70,7 +70,7 @@ ProfileSyncServiceAndroid::ProfileSyncServiceAndroid(JNIEnv* env, jobject obj) return; } - sync_prefs_.reset(new browser_sync::SyncPrefs(profile_->GetPrefs())); + sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); sync_service_ = ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); @@ -472,7 +472,7 @@ jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value // to to base::Time. return static_cast<jlong>( - profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); + profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); } void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, diff --git a/chrome/browser/sync/profile_sync_service_android.h b/chrome/browser/sync/profile_sync_service_android.h index 5af9cd8..92451cd 100644 --- a/chrome/browser/sync/profile_sync_service_android.h +++ b/chrome/browser/sync/profile_sync_service_android.h @@ -13,7 +13,7 @@ #include "base/compiler_specific.h" #include "base/time/time.h" #include "chrome/browser/sync/profile_sync_service_observer.h" -#include "chrome/browser/sync/sync_prefs.h" +#include "components/sync_driver/sync_prefs.h" #include "google/cacheinvalidation/include/types.h" #include "google_apis/gaia/google_service_auth_error.h" @@ -222,7 +222,7 @@ class ProfileSyncServiceAndroid : public ProfileSyncServiceObserver { ProfileSyncService* sync_service_; // The class that handles getting, setting, and persisting sync // preferences. - scoped_ptr<browser_sync::SyncPrefs> sync_prefs_; + scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; // Java-side ProfileSyncService object. JavaObjectWeakGlobalRef weak_java_profile_sync_service_; diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index a381bf0..58c2f4b 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -17,12 +17,13 @@ #include "chrome/browser/sync/profile_sync_components_factory_mock.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_test_util.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "components/signin/core/profile_oauth2_token_service.h" #include "components/sync_driver/data_type_manager.h" #include "components/sync_driver/data_type_manager_mock.h" +#include "components/sync_driver/pref_names.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -171,7 +172,7 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { // We've never completed startup. - profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); CreateSyncService(); SetUpSyncBackendHost(); DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); @@ -183,8 +184,11 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { sync_->Initialize(); // Preferences should be back to defaults. - EXPECT_EQ(0, profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); - EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)); + EXPECT_EQ( + 0, + profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); + EXPECT_FALSE(profile_->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncHasSetupCompleted)); Mock::VerifyAndClearExpectations(data_type_manager); // Then start things up. @@ -218,7 +222,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { // TODO(pavely): Reenable test once android is switched to oauth2. TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) { // We've never completed startup. - profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); CreateSyncService(); // Should not actually start, rather just clean things up and wait @@ -229,8 +233,11 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) { sync_->Initialize(); // Preferences should be back to defaults. - EXPECT_EQ(0, profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); - EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted)); + EXPECT_EQ( + 0, + profile_->GetPrefs()->GetInt64(sync_driver::prefs::kSyncLastSyncedTime)); + EXPECT_FALSE(profile_->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncHasSetupCompleted)); // Then start things up. sync_->SetSetupInProgress(true); @@ -303,7 +310,7 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { CreateDataTypeManager(_, _, _, _, _, _)).Times(0); EXPECT_CALL(*components_factory_mock(), CreateSyncBackendHost(_, _, _)).Times(0); - profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); sync_->Initialize(); @@ -318,7 +325,7 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) { SetUpSyncBackendHost(); DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); - profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); EXPECT_CALL(*data_type_manager, Configure(_, _)); EXPECT_CALL(*data_type_manager, state()). WillRepeatedly(Return(DataTypeManager::CONFIGURED)); @@ -356,12 +363,13 @@ TEST_F(ProfileSyncServiceStartupTest, StartNormal) { // therefore being left unset. TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) { // Clear the datatype preference fields (simulating bug 154940). - profile_->GetPrefs()->ClearPref(prefs::kSyncKeepEverythingSynced); + profile_->GetPrefs()->ClearPref( + sync_driver::prefs::kSyncKeepEverythingSynced); syncer::ModelTypeSet user_types = syncer::UserTypes(); for (syncer::ModelTypeSet::Iterator iter = user_types.First(); iter.Good(); iter.Inc()) { profile_->GetPrefs()->ClearPref( - browser_sync::SyncPrefs::GetPrefNameForDataType(iter.Get())); + sync_driver::SyncPrefs::GetPrefNameForDataType(iter.Get())); } // Pre load the tokens @@ -383,7 +391,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) { sync_->Initialize(); EXPECT_TRUE(profile_->GetPrefs()->GetBoolean( - prefs::kSyncKeepEverythingSynced)); + sync_driver::prefs::kSyncKeepEverythingSynced)); } // Verify that the recovery of datatype preferences doesn't overwrite a valid @@ -391,7 +399,8 @@ TEST_F(ProfileSyncServiceStartupTest, StartRecoverDatatypePrefs) { TEST_F(ProfileSyncServiceStartupTest, StartDontRecoverDatatypePrefs) { // Explicitly set Keep Everything Synced to false and have only bookmarks // enabled. - profile_->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); + profile_->GetPrefs()->SetBoolean( + sync_driver::prefs::kSyncKeepEverythingSynced, false); // Pre load the tokens profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, @@ -411,7 +420,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartDontRecoverDatatypePrefs) { sync_->Initialize(); EXPECT_FALSE(profile_->GetPrefs()->GetBoolean( - prefs::kSyncKeepEverythingSynced)); + sync_driver::prefs::kSyncKeepEverythingSynced)); } TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) { @@ -421,7 +430,7 @@ TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) { CreateSyncService(); // Disable sync through policy. - profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); + profile_->GetPrefs()->SetBoolean(sync_driver::prefs::kSyncManaged, true); EXPECT_CALL(*components_factory_mock(), CreateDataTypeManager(_, _, _, _, _, _)).Times(0); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); @@ -449,7 +458,7 @@ TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) { WillOnce(Return(DataTypeManager::CONFIGURED)); EXPECT_CALL(*data_type_manager, Stop()).Times(1); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); - profile_->GetPrefs()->SetBoolean(prefs::kSyncManaged, true); + profile_->GetPrefs()->SetBoolean(sync_driver::prefs::kSyncManaged, true); // When switching back to unmanaged, the state should change, but the service // should not start up automatically (kSyncSetupCompleted will be false). @@ -457,7 +466,7 @@ TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) { EXPECT_CALL(*components_factory_mock(), CreateDataTypeManager(_, _, _, _, _, _)).Times(0); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); - profile_->GetPrefs()->ClearPref(prefs::kSyncManaged); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncManaged); } TEST_F(ProfileSyncServiceStartupTest, StartFailure) { @@ -505,7 +514,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) { SyncBackendHostMock* mock_sbh = SetUpSyncBackendHost(); mock_sbh->set_fail_initial_download(true); - profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); + profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); sync_->Initialize(); diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index 773fe93..e07f250 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -21,6 +21,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_pref_service_syncable.h" #include "chrome/test/base/testing_profile.h" +#include "components/sync_driver/pref_names.h" #include "content/public/test/test_browser_thread_bundle.h" #include "google_apis/gaia/gaia_constants.h" #include "testing/gmock/include/gmock/gmock.h" @@ -192,8 +193,7 @@ TEST_F(ProfileSyncServiceTest, InitialState) { // Verify a successful initialization. TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { profile()->GetTestingPrefService()->SetManagedPref( - prefs::kSyncManaged, - base::Value::CreateBooleanValue(false)); + sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(false)); IssueTestTokens(); CreateService(browser_sync::AUTO_START); ExpectDataTypeManagerCreation(); @@ -224,8 +224,7 @@ TEST_F(ProfileSyncServiceTest, SetupInProgress) { // Verify that disable by enterprise policy works. TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { profile()->GetTestingPrefService()->SetManagedPref( - prefs::kSyncManaged, - base::Value::CreateBooleanValue(true)); + sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); IssueTestTokens(); CreateService(browser_sync::AUTO_START); Initialize(); @@ -246,8 +245,7 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { EXPECT_TRUE(service()->sync_initialized()); profile()->GetTestingPrefService()->SetManagedPref( - prefs::kSyncManaged, - base::Value::CreateBooleanValue(true)); + sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); EXPECT_TRUE(service()->IsManaged()); EXPECT_FALSE(service()->sync_initialized()); @@ -272,7 +270,8 @@ TEST_F(ProfileSyncServiceTest, EarlyStopAndSuppress) { IssueTestTokens(); service()->StopAndSuppress(); - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); // Because of supression, this should fail. Initialize(); @@ -283,8 +282,8 @@ TEST_F(ProfileSyncServiceTest, EarlyStopAndSuppress) { ExpectSyncBackendHostCreation(); service()->UnsuppressAndStart(); EXPECT_TRUE(service()->sync_initialized()); - EXPECT_FALSE( - profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); } // Test StopAndSuppress() after we've initialized the backend. @@ -296,21 +295,23 @@ TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { Initialize(); EXPECT_TRUE(service()->sync_initialized()); - EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); testing::Mock::VerifyAndClearExpectations(components_factory()); service()->StopAndSuppress(); EXPECT_FALSE(service()->sync_initialized()); - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); ExpectDataTypeManagerCreation(); ExpectSyncBackendHostCreation(); service()->UnsuppressAndStart(); EXPECT_TRUE(service()->sync_initialized()); - EXPECT_FALSE( - profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); } // Certain ProfileSyncService tests don't apply to Chrome OS, for example @@ -325,7 +326,8 @@ TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { Initialize(); EXPECT_TRUE(service()->sync_initialized()); - EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); + EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( + sync_driver::prefs::kSyncSuppressStart)); SigninManagerFactory::GetForProfile(profile())->SignOut(); EXPECT_FALSE(service()->sync_initialized()); diff --git a/chrome/browser/sync/sessions2/sessions_sync_manager.h b/chrome/browser/sync/sessions2/sessions_sync_manager.h index f118109..1c415a6 100644 --- a/chrome/browser/sync/sessions2/sessions_sync_manager.h +++ b/chrome/browser/sync/sessions2/sessions_sync_manager.h @@ -23,7 +23,7 @@ #include "chrome/browser/sync/glue/synced_session_tracker.h" #include "chrome/browser/sync/open_tabs_ui_delegate.h" #include "chrome/browser/sync/sessions2/tab_node_pool2.h" -#include "chrome/browser/sync/sync_prefs.h" +#include "components/sync_driver/sync_prefs.h" #include "sync/api/syncable_service.h" class Profile; @@ -347,7 +347,7 @@ class SessionsSyncManager : public syncer::SyncableService, // proves that we are still relevant. bool local_tab_pool_out_of_sync_; - SyncPrefs sync_prefs_; + sync_driver::SyncPrefs sync_prefs_; const Profile* const profile_; diff --git a/chrome/browser/sync/startup_controller.cc b/chrome/browser/sync/startup_controller.cc index 88928d7..3f84735 100644 --- a/chrome/browser/sync/startup_controller.cc +++ b/chrome/browser/sync/startup_controller.cc @@ -9,9 +9,9 @@ #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/chrome_switches.h" #include "components/signin/core/profile_oauth2_token_service.h" +#include "components/sync_driver/sync_prefs.h" namespace browser_sync { @@ -37,7 +37,7 @@ enum DeferredInitTrigger { StartupController::StartupController( ProfileSyncServiceStartBehavior start_behavior, const ProfileOAuth2TokenService* token_service, - const browser_sync::SyncPrefs* sync_prefs, + const sync_driver::SyncPrefs* sync_prefs, const ManagedUserSigninManagerWrapper* signin, base::Closure start_backend) : received_start_request_(false), @@ -47,8 +47,8 @@ StartupController::StartupController( token_service_(token_service), signin_(signin), start_backend_(start_backend), - fallback_timeout_(base::TimeDelta::FromSeconds( - kDeferredInitFallbackSeconds)), + fallback_timeout_( + base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)), weak_factory_(this) { if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/chrome/browser/sync/startup_controller.h b/chrome/browser/sync/startup_controller.h index 0dbceb5..b5ddc93 100644 --- a/chrome/browser/sync/startup_controller.h +++ b/chrome/browser/sync/startup_controller.h @@ -13,9 +13,11 @@ class ManagedUserSigninManagerWrapper; class ProfileOAuth2TokenService; -namespace browser_sync { - +namespace sync_driver { class SyncPrefs; +} + +namespace browser_sync { // Defines the type of behavior the sync engine should use. If configured for // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() @@ -35,7 +37,7 @@ class StartupController { public: StartupController(ProfileSyncServiceStartBehavior start_behavior, const ProfileOAuth2TokenService* token_service, - const browser_sync::SyncPrefs* sync_prefs, + const sync_driver::SyncPrefs* sync_prefs, const ManagedUserSigninManagerWrapper* signin, base::Closure start_backend); ~StartupController(); @@ -94,7 +96,7 @@ class StartupController { // distinct signin flow. const bool auto_start_enabled_; - const browser_sync::SyncPrefs* sync_prefs_; + const sync_driver::SyncPrefs* sync_prefs_; const ProfileOAuth2TokenService* token_service_; diff --git a/chrome/browser/sync/startup_controller_unittest.cc b/chrome/browser/sync/startup_controller_unittest.cc index 3aa1e2e..5c0a4ef 100644 --- a/chrome/browser/sync/startup_controller_unittest.cc +++ b/chrome/browser/sync/startup_controller_unittest.cc @@ -13,9 +13,9 @@ #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_profile.h" +#include "components/sync_driver/sync_prefs.h" #include "testing/gtest/include/gtest/gtest.h" namespace browser_sync { @@ -56,7 +56,7 @@ class StartupControllerTest : public testing::Test { virtual void SetUp() OVERRIDE { profile_.reset(new TestingProfile()); - sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); + sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); token_service_.reset( static_cast<FakeProfileOAuth2TokenServiceWrapper*>( FakeProfileOAuth2TokenServiceWrapper::Build(profile_.get()))); @@ -94,7 +94,7 @@ class StartupControllerTest : public testing::Test { return static_cast<FakeProfileOAuth2TokenService*>( token_service_->GetProfileOAuth2TokenService()); } - SyncPrefs* sync_prefs() { return sync_prefs_.get(); } + sync_driver::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } Profile* profile() { return profile_.get(); } private: @@ -103,7 +103,7 @@ class StartupControllerTest : public testing::Test { scoped_ptr<StartupController> controller_; scoped_ptr<FakeManagedUserSigninManagerWrapper> signin_; scoped_ptr<FakeProfileOAuth2TokenServiceWrapper> token_service_; - scoped_ptr<SyncPrefs> sync_prefs_; + scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; scoped_ptr<TestingProfile> profile_; }; diff --git a/chrome/browser/sync/sync_policy_handler.cc b/chrome/browser/sync/sync_policy_handler.cc index 94b24b7..91f96e7 100644 --- a/chrome/browser/sync/sync_policy_handler.cc +++ b/chrome/browser/sync/sync_policy_handler.cc @@ -6,8 +6,8 @@ #include "base/prefs/pref_value_map.h" #include "base/values.h" -#include "chrome/common/pref_names.h" #include "components/policy/core/common/policy_map.h" +#include "components/sync_driver/pref_names.h" #include "policy/policy_constants.h" namespace browser_sync { @@ -24,7 +24,7 @@ void SyncPolicyHandler::ApplyPolicySettings(const policy::PolicyMap& policies, const base::Value* value = policies.GetValue(policy_name()); bool disable_sync; if (value && value->GetAsBoolean(&disable_sync) && disable_sync) - prefs->SetValue(prefs::kSyncManaged, value->DeepCopy()); + prefs->SetValue(sync_driver::prefs::kSyncManaged, value->DeepCopy()); } } // namespace browser_sync diff --git a/chrome/browser/sync/sync_policy_handler_unittest.cc b/chrome/browser/sync/sync_policy_handler_unittest.cc index accdf65..0efee55 100644 --- a/chrome/browser/sync/sync_policy_handler_unittest.cc +++ b/chrome/browser/sync/sync_policy_handler_unittest.cc @@ -5,8 +5,8 @@ #include "base/prefs/pref_value_map.h" #include "base/values.h" #include "chrome/browser/sync/sync_policy_handler.h" -#include "chrome/common/pref_names.h" #include "components/policy/core/common/policy_map.h" +#include "components/sync_driver/pref_names.h" #include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,7 +20,7 @@ TEST_F(SyncPolicyHandlerTest, Default) { SyncPolicyHandler handler; PrefValueMap prefs; handler.ApplyPolicySettings(policy, &prefs); - EXPECT_FALSE(prefs.GetValue(prefs::kSyncManaged, NULL)); + EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL)); } TEST_F(SyncPolicyHandlerTest, Enabled) { @@ -35,7 +35,7 @@ TEST_F(SyncPolicyHandlerTest, Enabled) { handler.ApplyPolicySettings(policy, &prefs); // Enabling Sync should not set the pref. - EXPECT_FALSE(prefs.GetValue(prefs::kSyncManaged, NULL)); + EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL)); } TEST_F(SyncPolicyHandlerTest, Disabled) { @@ -51,7 +51,7 @@ TEST_F(SyncPolicyHandlerTest, Disabled) { // Sync should be flagged as managed. const base::Value* value = NULL; - EXPECT_TRUE(prefs.GetValue(prefs::kSyncManaged, &value)); + EXPECT_TRUE(prefs.GetValue(sync_driver::prefs::kSyncManaged, &value)); ASSERT_TRUE(value); bool sync_managed = false; bool result = value->GetAsBoolean(&sync_managed); diff --git a/chrome/browser/sync/test/integration/two_client_preferences_sync_test.cc b/chrome/browser/sync/test/integration/two_client_preferences_sync_test.cc index b5bb784..3efadea 100644 --- a/chrome/browser/sync/test/integration/two_client_preferences_sync_test.cc +++ b/chrome/browser/sync/test/integration/two_client_preferences_sync_test.cc @@ -9,6 +9,7 @@ #include "chrome/browser/translate/translate_tab_helper.h" #include "chrome/common/pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.h" +#include "components/sync_driver/pref_names.h" #include "components/translate/core/browser/translate_prefs.h" #include "components/translate/core/common/translate_pref_names.h" @@ -75,11 +76,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; DisableVerifier(); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncThemes)); + ASSERT_TRUE( + BooleanPrefMatches(sync_driver::prefs::kSyncKeepEverythingSynced)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncThemes)); GetClient(0)->DisableSyncForDatatype(syncer::THEMES); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced)); + ASSERT_FALSE( + BooleanPrefMatches(sync_driver::prefs::kSyncKeepEverythingSynced)); } // TCM ID - 3661290. @@ -87,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisablePreferences) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; DisableVerifier(); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncPreferences)); ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled)); GetClient(1)->DisableSyncForDatatype(syncer::PREFERENCES); @@ -105,7 +108,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisableSync) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; DisableVerifier(); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncPreferences)); ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled)); ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); @@ -128,12 +131,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, SignInDialog) { ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; DisableVerifier(); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncBookmarks)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncThemes)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncExtensions)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncAutofill)); - ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncPreferences)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncBookmarks)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncThemes)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncExtensions)); + ASSERT_TRUE(BooleanPrefMatches(sync_driver::prefs::kSyncAutofill)); + ASSERT_TRUE( + BooleanPrefMatches(sync_driver::prefs::kSyncKeepEverythingSynced)); GetClient(0)->DisableSyncForDatatype(syncer::PREFERENCES); GetClient(1)->EnableSyncForDatatype(syncer::PREFERENCES); @@ -148,12 +152,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, SignInDialog) { ASSERT_TRUE(AwaitQuiescence()); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncPreferences)); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncBookmarks)); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncThemes)); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncExtensions)); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncAutofill)); - ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced)); + ASSERT_FALSE(BooleanPrefMatches(sync_driver::prefs::kSyncPreferences)); + ASSERT_FALSE(BooleanPrefMatches(sync_driver::prefs::kSyncBookmarks)); + ASSERT_FALSE(BooleanPrefMatches(sync_driver::prefs::kSyncThemes)); + ASSERT_FALSE(BooleanPrefMatches(sync_driver::prefs::kSyncExtensions)); + ASSERT_FALSE(BooleanPrefMatches(sync_driver::prefs::kSyncAutofill)); + ASSERT_FALSE( + BooleanPrefMatches(sync_driver::prefs::kSyncKeepEverythingSynced)); } // TCM ID - 3666296. diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc index 3bdba1f..b1f8856 100644 --- a/chrome/browser/sync/test_profile_sync_service.cc +++ b/chrome/browser/sync/test_profile_sync_service.cc @@ -30,11 +30,12 @@ namespace browser_sync { SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( Profile* profile, - const base::WeakPtr<SyncPrefs>& sync_prefs, + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, base::Closure callback) - : browser_sync::SyncBackendHostImpl( - profile->GetDebugName(), profile, sync_prefs), - callback_(callback) {} + : browser_sync::SyncBackendHostImpl(profile->GetDebugName(), + profile, + sync_prefs), + callback_(callback) {} SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h index d6d8967..245c51e 100644 --- a/chrome/browser/sync/test_profile_sync_service.h +++ b/chrome/browser/sync/test_profile_sync_service.h @@ -13,8 +13,8 @@ #include "chrome/browser/sync/glue/data_type_manager_impl.h" #include "chrome/browser/sync/glue/sync_backend_host_impl.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/sync/sync_prefs.h" #include "components/signin/core/profile_oauth2_token_service.h" +#include "components/sync_driver/sync_prefs.h" #include "sync/test/engine/test_id_factory.h" #include "testing/gmock/include/gmock/gmock.h" @@ -38,7 +38,7 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { public: SyncBackendHostForProfileSyncTest( Profile* profile, - const base::WeakPtr<SyncPrefs>& sync_prefs, + const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, base::Closure callback); virtual ~SyncBackendHostForProfileSyncTest(); diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc index 5555eed..627442a 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc @@ -42,7 +42,6 @@ #include "chrome/browser/signin/signin_names_io_thread.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" @@ -66,6 +65,7 @@ #include "components/signin/core/signin_client.h" #include "components/signin/core/signin_error_controller.h" #include "components/signin/core/signin_manager_cookie_helper.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/page_navigator.h" diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc index 209f8aa..8848f84 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc @@ -36,6 +36,7 @@ #include "chrome/test/base/testing_profile_manager.h" #include "components/autofill/core/common/password_form.h" #include "components/signin/core/profile_oauth2_token_service.h" +#include "components/sync_driver/pref_names.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/web_contents.h" @@ -83,7 +84,7 @@ class TestProfileIOData : public ProfileIOData { google_services_username_pattern()->Init( prefs::kGoogleServicesUsernamePattern, local_state); - sync_disabled()->Init(prefs::kSyncManaged, pref_service); + sync_disabled()->Init(sync_driver::prefs::kSyncManaged, pref_service); signin_allowed()->Init(prefs::kSigninAllowed, pref_service); @@ -639,7 +640,7 @@ TEST_F(OneClickSigninHelperTest, CanOfferDisabledByPolicy) { // Simulate a policy disabling sync by writing kSyncManaged directly. profile()->GetTestingPrefService()->SetManagedPref( - prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); + sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); // Should still offer even if sync is disabled by policy. EXPECT_TRUE(OneClickSigninHelper::CanOffer( @@ -859,7 +860,7 @@ TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { // Simulate a policy disabling sync by writing kSyncManaged directly. // We should still offer to sign in the browser. profile()->GetTestingPrefService()->SetManagedPref( - prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); + sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, OneClickSigninHelper::CanOfferOnIOThreadImpl( valid_gaia_url_, &request_, io_data.get())); diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc index 23ef9f2..395b966 100644 --- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc +++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc @@ -22,7 +22,6 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/sync/sync_prefs.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_finder.h" @@ -37,6 +36,7 @@ #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" #include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" +#include "components/sync_driver/sync_prefs.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -104,7 +104,7 @@ void OneClickSigninSyncStarter::Initialize(Profile* profile, Browser* browser) { // Make sure the syncing is not suppressed, otherwise the SigninManager // will not be able to complete sucessfully. - browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); sync_prefs.SetStartSuppressed(false); } diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc index ba8d89e..7d93f06 100644 --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -175,8 +175,6 @@ NTPResourceCache::NTPResourceCache(Profile* profile) // Watch for pref changes that cause us to need to invalidate the HTML cache. profile_pref_change_registrar_.Init(profile_->GetPrefs()); - profile_pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, - callback); profile_pref_change_registrar_.Add(prefs::kShowBookmarkBar, callback); profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback); profile_pref_change_registrar_.Add(prefs::kSignInPromoShowNTPBubble, diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc index 5ae85b5..3c73742 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/sync_setup_handler.cc @@ -39,6 +39,7 @@ #include "chrome/common/url_constants.h" #include "components/signin/core/profile_oauth2_token_service.h" #include "components/signin/core/signin_error_controller.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" @@ -352,7 +353,7 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced, registered_types.Has(sync_type)); args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); } - browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); args.SetBoolean("passphraseFailed", passphrase_failed); args.SetBoolean("showSyncEverythingPage", !show_advanced); args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc index 4b753f7..a8e4687 100644 --- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc +++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc @@ -27,6 +27,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/signin/core/profile_oauth2_token_service.h" +#include "components/sync_driver/sync_prefs.h" #include "content/public/browser/web_ui.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -931,7 +932,7 @@ TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) .WillRepeatedly(Return(false)); SetupInitializedProfileSyncService(); - browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); sync_prefs.SetKeepEverythingSynced(false); SetDefaultExpectationsForConfigPage(); // This should display the sync setup dialog (not login). @@ -953,7 +954,7 @@ TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) .WillRepeatedly(Return(false)); SetupInitializedProfileSyncService(); - browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); + sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); sync_prefs.SetKeepEverythingSynced(false); SetDefaultExpectationsForConfigPage(); syncer::ModelTypeSet types; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index afd6c5b..a6d5868 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2370,8 +2370,6 @@ 'browser/sync/sync_global_error.h', 'browser/sync/sync_policy_handler.cc', 'browser/sync/sync_policy_handler.h', - 'browser/sync/sync_prefs.cc', - 'browser/sync/sync_prefs.h', 'browser/sync/sync_startup_tracker.cc', 'browser/sync/sync_startup_tracker.h', 'browser/sync/sync_ui_util.cc', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 6b721c2..80182c6 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1342,7 +1342,6 @@ 'browser/sync/startup_controller_unittest.cc', 'browser/sync/sync_global_error_unittest.cc', 'browser/sync/sync_policy_handler_unittest.cc', - 'browser/sync/sync_prefs_unittest.cc', 'browser/sync/sync_startup_tracker_unittest.cc', 'browser/sync/sync_ui_util_unittest.cc', 'browser/sync/test/test_http_bridge_factory.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index b231a17b..b1bdbe9 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -101,12 +101,6 @@ const char kRestoreStartupURLsMigrationTime[] = // data in the profile folder on disk but only in memory. const char kForceEphemeralProfiles[] = "profile.ephemeral_mode"; -// Set to true when enhanced bookmarks experiment is enabled via Chrome sync. -const char kEnhancedBookmarksExperimentEnabled[] = "enhanced_bookmarks_enabled"; - -// Enhanced bookmarks extension id passed via Chrome sync. -const char kEnhancedBookmarksExtensionId[] = "enhanced_bookmarks_extension_id"; - // The application locale. // For OS_CHROMEOS we maintain kApplicationLocale property in both local state // and user's profile. Global property determines locale of login screen, @@ -1813,68 +1807,6 @@ const char kSpdyProxyAuthWasEnabledBefore[] = "spdy_proxy.was_enabled_before"; // Boolean which stores if the user is allowed to signin to chrome. const char kSigninAllowed[] = "signin.allowed"; -// 64-bit integer serialization of the base::Time when the last sync occurred. -const char kSyncLastSyncedTime[] = "sync.last_synced_time"; - -// Boolean specifying whether the user finished setting up sync. -const char kSyncHasSetupCompleted[] = "sync.has_setup_completed"; - -// Boolean specifying whether sync has an auth error. -const char kSyncHasAuthError[] = "sync.has_auth_error"; - -// Boolean specifying whether to automatically sync all data types (including -// future ones, as they're added). If this is true, the following preferences -// (kSyncBookmarks, kSyncPasswords, etc.) can all be ignored. -const char kSyncKeepEverythingSynced[] = "sync.keep_everything_synced"; - -// Booleans specifying whether the user has selected to sync the following -// datatypes. -const char kSyncAppList[] = "sync.app_list"; -const char kSyncAppNotifications[] = "sync.app_notifications"; -const char kSyncAppSettings[] = "sync.app_settings"; -const char kSyncApps[] = "sync.apps"; -const char kSyncAutofillProfile[] = "sync.autofill_profile"; -const char kSyncAutofill[] = "sync.autofill"; -const char kSyncBookmarks[] = "sync.bookmarks"; -const char kSyncDictionary[] = "sync.dictionary"; -const char kSyncExtensionSettings[] = "sync.extension_settings"; -const char kSyncExtensions[] = "sync.extensions"; -const char kSyncFaviconImages[] = "sync.favicon_images"; -const char kSyncFaviconTracking[] = "sync.favicon_tracking"; -const char kSyncHistoryDeleteDirectives[] = "sync.history_delete_directives"; -const char kSyncManagedUserSettings[] = "sync.managed_user_settings"; -const char kSyncManagedUserSharedSettings[] = - "sync.managed_user_shared_settings"; -const char kSyncManagedUsers[] = "sync.managed_users"; -const char kSyncArticles[] = "sync.articles"; -const char kSyncPasswords[] = "sync.passwords"; -const char kSyncPreferences[] = "sync.preferences"; -const char kSyncPriorityPreferences[] = "sync.priority_preferences"; -const char kSyncSearchEngines[] = "sync.search_engines"; -const char kSyncSessions[] = "sync.sessions"; -const char kSyncSyncedNotificationAppInfo[] = - "sync.synced_notification_app_info"; -const char kSyncSyncedNotifications[] = "sync.synced_notifications"; -const char kSyncTabs[] = "sync.tabs"; -const char kSyncThemes[] = "sync.themes"; -const char kSyncTypedUrls[] = "sync.typed_urls"; - -// Boolean used by enterprise configuration management in order to lock down -// sync. -const char kSyncManaged[] = "sync.managed"; - -// Boolean to prevent sync from automatically starting up. This is -// used when sync is disabled by the user via the privacy dashboard. -const char kSyncSuppressStart[] = "sync.suppress_start"; - -// List of the currently acknowledged set of sync types, used to figure out -// if a new sync type has rolled out so we can notify the user. -const char kSyncAcknowledgedSyncTypes[] = "sync.acknowledged_types"; - -// The GUID session sync will use to identify this client, even across sync -// disable/enable events. -const char kSyncSessionsGUID[] = "sync.session_sync_guid"; - // An ID to uniquely identify this client to the invalidator service. const char kInvalidatorClientId[] = "invalidator.client_id"; @@ -1886,20 +1818,6 @@ const char kInvalidatorInvalidationState[] = "invalidator.invalidation_state"; // yet. Used to keep invalidation clients in sync in case of a restart. const char kInvalidatorSavedInvalidations[] = "invalidator.saved_invalidations"; -// A string that can be used to restore sync encryption infrastructure on -// startup so that the user doesn't need to provide credentials on each start. -const char kSyncEncryptionBootstrapToken[] = - "sync.encryption_bootstrap_token"; - -// Same as kSyncEncryptionBootstrapToken, but derived from the keystore key, -// so we don't have to do a GetKey command at restart. -const char kSyncKeystoreEncryptionBootstrapToken[] = - "sync.keystore_encryption_bootstrap_token"; - -// Boolean tracking whether the user chose to specify a secondary encryption -// passphrase. -const char kSyncUsingSecondaryPassphrase[] = "sync.using_secondary_passphrase"; - // String the identifies the last user that logged into sync and other // google services. As opposed to kGoogleServicesUsername, this value is not // cleared on signout, but while the user is signed in the two values will @@ -2186,10 +2104,6 @@ const char kDeviceActivityTimes[] = "device_status.activity_times"; // enabled. const char kDeviceLocation[] = "device_status.location"; -// A string that is used to store first-time sync startup after once sync is -// disabled. This will be refreshed every sign-in. -const char kSyncSpareBootstrapToken[] = "sync.spare_bootstrap_token"; - // A pref holding the value of the policy used to disable mounting of external // storage for the user. const char kExternalStorageDisabled[] = "hardware.external_storage_disabled"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 97110af..421f628 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -35,8 +35,6 @@ extern const char kURLsToRestoreOnStartup[]; extern const char kURLsToRestoreOnStartupOld[]; extern const char kRestoreStartupURLsMigrationTime[]; extern const char kForceEphemeralProfiles[]; -extern const char kEnhancedBookmarksExperimentEnabled[]; -extern const char kEnhancedBookmarksExtensionId[]; // For OS_CHROMEOS we maintain kApplicationLocale property in both local state // and user's profile. Global property determines locale of login screen, @@ -598,51 +596,12 @@ extern const char kSpdyProxyAuthEnabled[]; extern const char kSpdyProxyAuthWasEnabledBefore[]; #endif // defined(OS_ANDROID) || defined(OS_IOS) extern const char kSigninAllowed[]; -extern const char kSyncLastSyncedTime[]; -extern const char kSyncHasAuthError[]; -extern const char kSyncHasSetupCompleted[]; -extern const char kSyncKeepEverythingSynced[]; - -extern const char kSyncAppList[]; -extern const char kSyncAppNotifications[]; -extern const char kSyncAppSettings[]; -extern const char kSyncApps[]; -extern const char kSyncAutofillProfile[]; -extern const char kSyncAutofill[]; -extern const char kSyncBookmarks[]; -extern const char kSyncDictionary[]; -extern const char kSyncExtensionSettings[]; -extern const char kSyncExtensions[]; -extern const char kSyncFaviconImages[]; -extern const char kSyncFaviconTracking[]; -extern const char kSyncHistoryDeleteDirectives[]; -extern const char kSyncManagedUserSettings[]; -extern const char kSyncManagedUserSharedSettings[]; -extern const char kSyncManagedUsers[]; -extern const char kSyncArticles[]; -extern const char kSyncPasswords[]; -extern const char kSyncPreferences[]; -extern const char kSyncPriorityPreferences[]; -extern const char kSyncSearchEngines[]; -extern const char kSyncSessions[]; -extern const char kSyncSyncedNotificationAppInfo[]; -extern const char kSyncSyncedNotifications[]; -extern const char kSyncTabs[]; -extern const char kSyncThemes[]; -extern const char kSyncTypedUrls[]; - -extern const char kSyncManaged[]; -extern const char kSyncSuppressStart[]; + extern const char kGoogleServicesLastUsername[]; extern const char kGoogleServicesUserAccountId[]; extern const char kGoogleServicesUsername[]; extern const char kGoogleServicesUsernamePattern[]; extern const char kGoogleServicesPasswordHash[]; -extern const char kSyncUsingSecondaryPassphrase[]; -extern const char kSyncEncryptionBootstrapToken[]; -extern const char kSyncKeystoreEncryptionBootstrapToken[]; -extern const char kSyncAcknowledgedSyncTypes[]; -extern const char kSyncSessionsGUID[]; extern const char kInvalidatorClientId[]; extern const char kInvalidatorInvalidationState[]; @@ -754,7 +713,6 @@ extern const char kShouldAutoEnroll[]; extern const char kAutoEnrollmentPowerLimit[]; extern const char kDeviceActivityTimes[]; extern const char kDeviceLocation[]; -extern const char kSyncSpareBootstrapToken[]; extern const char kExternalStorageDisabled[]; extern const char kUsersWallpaperInfo[]; extern const char kAudioOutputAllowed[]; diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 450c048..267b3d2 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -109,6 +109,7 @@ 'storage_monitor/storage_monitor_unittest.cc', 'storage_monitor/storage_monitor_win_unittest.cc', 'sync_driver/model_association_manager_unittest.cc', + 'sync_driver/sync_prefs_unittest.cc', 'sync_driver/system_encryptor_unittest.cc', 'test/run_all_unittests.cc', 'translate/core/browser/language_state_unittest.cc', diff --git a/components/sync_driver.gypi b/components/sync_driver.gypi index f663734..28a3b3d 100644 --- a/components/sync_driver.gypi +++ b/components/sync_driver.gypi @@ -31,10 +31,14 @@ 'sync_driver/model_association_manager.cc', 'sync_driver/model_association_manager.h', 'sync_driver/model_associator.h', + 'sync_driver/pref_names.cc', + 'sync_driver/pref_names.h', 'sync_driver/proxy_data_type_controller.cc', 'sync_driver/proxy_data_type_controller.h', 'sync_driver/sync_frontend.cc', 'sync_driver/sync_frontend.h', + 'sync_driver/sync_prefs.cc', + 'sync_driver/sync_prefs.h', 'sync_driver/system_encryptor.cc', 'sync_driver/system_encryptor.h', 'sync_driver/user_selectable_sync_type.h', diff --git a/components/sync_driver/DEPS b/components/sync_driver/DEPS index 76dfcec..390e71b 100644 --- a/components/sync_driver/DEPS +++ b/components/sync_driver/DEPS @@ -2,5 +2,6 @@ include_rules = [ # SyncDriver is used by iOS, which does not use content. "-content", "+components/os_crypt", + "+components/user_prefs/pref_registry_syncable.h", "+sync", ] diff --git a/components/sync_driver/pref_names.cc b/components/sync_driver/pref_names.cc new file mode 100644 index 0000000..7ab3382 --- /dev/null +++ b/components/sync_driver/pref_names.cc @@ -0,0 +1,100 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/sync_driver/pref_names.h" + +namespace sync_driver { + +namespace prefs { + +// Set to true when enhanced bookmarks experiment is enabled via Chrome sync. +const char kEnhancedBookmarksExperimentEnabled[] = "enhanced_bookmarks_enabled"; + +// Enhanced bookmarks extension id passed via Chrome sync. +const char kEnhancedBookmarksExtensionId[] = "enhanced_bookmarks_extension_id"; + +// 64-bit integer serialization of the base::Time when the last sync occurred. +const char kSyncLastSyncedTime[] = "sync.last_synced_time"; + +// Boolean specifying whether the user finished setting up sync. +const char kSyncHasSetupCompleted[] = "sync.has_setup_completed"; + +// Boolean specifying whether sync has an auth error. +const char kSyncHasAuthError[] = "sync.has_auth_error"; + +// Boolean specifying whether to automatically sync all data types (including +// future ones, as they're added). If this is true, the following preferences +// (kSyncBookmarks, kSyncPasswords, etc.) can all be ignored. +const char kSyncKeepEverythingSynced[] = "sync.keep_everything_synced"; + +// Booleans specifying whether the user has selected to sync the following +// datatypes. +const char kSyncAppList[] = "sync.app_list"; +const char kSyncAppNotifications[] = "sync.app_notifications"; +const char kSyncAppSettings[] = "sync.app_settings"; +const char kSyncApps[] = "sync.apps"; +const char kSyncAutofillProfile[] = "sync.autofill_profile"; +const char kSyncAutofill[] = "sync.autofill"; +const char kSyncBookmarks[] = "sync.bookmarks"; +const char kSyncDictionary[] = "sync.dictionary"; +const char kSyncExtensionSettings[] = "sync.extension_settings"; +const char kSyncExtensions[] = "sync.extensions"; +const char kSyncFaviconImages[] = "sync.favicon_images"; +const char kSyncFaviconTracking[] = "sync.favicon_tracking"; +const char kSyncHistoryDeleteDirectives[] = "sync.history_delete_directives"; +const char kSyncManagedUserSettings[] = "sync.managed_user_settings"; +const char kSyncManagedUserSharedSettings[] = + "sync.managed_user_shared_settings"; +const char kSyncManagedUsers[] = "sync.managed_users"; +const char kSyncArticles[] = "sync.articles"; +const char kSyncPasswords[] = "sync.passwords"; +const char kSyncPreferences[] = "sync.preferences"; +const char kSyncPriorityPreferences[] = "sync.priority_preferences"; +const char kSyncSearchEngines[] = "sync.search_engines"; +const char kSyncSessions[] = "sync.sessions"; +const char kSyncSyncedNotificationAppInfo[] = + "sync.synced_notification_app_info"; +const char kSyncSyncedNotifications[] = "sync.synced_notifications"; +const char kSyncTabs[] = "sync.tabs"; +const char kSyncThemes[] = "sync.themes"; +const char kSyncTypedUrls[] = "sync.typed_urls"; + +// Boolean used by enterprise configuration management in order to lock down +// sync. +const char kSyncManaged[] = "sync.managed"; + +// Boolean to prevent sync from automatically starting up. This is +// used when sync is disabled by the user via the privacy dashboard. +const char kSyncSuppressStart[] = "sync.suppress_start"; + +// A string that can be used to restore sync encryption infrastructure on +// startup so that the user doesn't need to provide credentials on each start. +const char kSyncEncryptionBootstrapToken[] = "sync.encryption_bootstrap_token"; + +// Same as kSyncEncryptionBootstrapToken, but derived from the keystore key, +// so we don't have to do a GetKey command at restart. +const char kSyncKeystoreEncryptionBootstrapToken[] = + "sync.keystore_encryption_bootstrap_token"; + +// Boolean tracking whether the user chose to specify a secondary encryption +// passphrase. +const char kSyncUsingSecondaryPassphrase[] = "sync.using_secondary_passphrase"; + +// List of the currently acknowledged set of sync types, used to figure out +// if a new sync type has rolled out so we can notify the user. +const char kSyncAcknowledgedSyncTypes[] = "sync.acknowledged_types"; + +// The GUID session sync will use to identify this client, even across sync +// disable/enable events. +const char kSyncSessionsGUID[] = "sync.session_sync_guid"; + +#if defined(OS_CHROMEOS) +// A string that is used to store first-time sync startup after once sync is +// disabled. This will be refreshed every sign-in. +const char kSyncSpareBootstrapToken[] = "sync.spare_bootstrap_token"; +#endif // defined(OS_CHROMEOS) + +} // namespace prefs + +} // namespace sync_driver diff --git a/components/sync_driver/pref_names.h b/components/sync_driver/pref_names.h new file mode 100644 index 0000000..61594c9 --- /dev/null +++ b/components/sync_driver/pref_names.h @@ -0,0 +1,66 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Constants for the names of various sync preferences, for easier changing. + +#include "build/build_config.h" + +namespace sync_driver { + +namespace prefs { + +extern const char kEnhancedBookmarksExperimentEnabled[]; +extern const char kEnhancedBookmarksExtensionId[]; + +extern const char kSyncLastSyncedTime[]; +extern const char kSyncHasAuthError[]; +extern const char kSyncHasSetupCompleted[]; +extern const char kSyncKeepEverythingSynced[]; + +extern const char kSyncAppList[]; +extern const char kSyncAppNotifications[]; +extern const char kSyncAppSettings[]; +extern const char kSyncApps[]; +extern const char kSyncAutofillProfile[]; +extern const char kSyncAutofill[]; +extern const char kSyncBookmarks[]; +extern const char kSyncDictionary[]; +extern const char kSyncExtensionSettings[]; +extern const char kSyncExtensions[]; +extern const char kSyncFaviconImages[]; +extern const char kSyncFaviconTracking[]; +extern const char kSyncHistoryDeleteDirectives[]; +extern const char kSyncManagedUserSettings[]; +extern const char kSyncManagedUserSharedSettings[]; +extern const char kSyncManagedUsers[]; +extern const char kSyncArticles[]; +extern const char kSyncPasswords[]; +extern const char kSyncPreferences[]; +extern const char kSyncPriorityPreferences[]; +extern const char kSyncSearchEngines[]; +extern const char kSyncSessions[]; +extern const char kSyncSyncedNotificationAppInfo[]; +extern const char kSyncSyncedNotifications[]; +extern const char kSyncTabs[]; +extern const char kSyncThemes[]; +extern const char kSyncTypedUrls[]; + +extern const char kSyncManaged[]; +extern const char kSyncSuppressStart[]; + +extern const char kSyncUsingSecondaryPassphrase[]; +extern const char kSyncEncryptionBootstrapToken[]; +extern const char kSyncKeystoreEncryptionBootstrapToken[]; + +extern const char kSyncAcknowledgedSyncTypes[]; + +extern const char kSyncSessionsGUID[]; + +#if defined(OS_CHROMEOS) +extern const char kSyncSpareBootstrapToken[]; +#endif // defined(OS_CHROMEOS) + +} // namespace prefs + +} // namespace sync_driver diff --git a/chrome/browser/sync/sync_prefs.cc b/components/sync_driver/sync_prefs.cc index b3dc46e..9d34236 100644 --- a/chrome/browser/sync/sync_prefs.cc +++ b/components/sync_driver/sync_prefs.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/sync/sync_prefs.h" +#include "components/sync_driver/sync_prefs.h" #include "base/command_line.h" #include "base/logging.h" @@ -11,33 +11,25 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/profiles/profile_io_data.h" -#include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/pref_names.h" +#include "components/sync_driver/pref_names.h" #include "components/user_prefs/pref_registry_syncable.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_source.h" -namespace browser_sync { +namespace sync_driver { SyncPrefObserver::~SyncPrefObserver() {} -SyncPrefs::SyncPrefs(PrefService* pref_service) - : pref_service_(pref_service) { +SyncPrefs::SyncPrefs(PrefService* pref_service) : pref_service_(pref_service) { DCHECK(pref_service); RegisterPrefGroups(); // Watch the preference that indicates sync is managed so we can take // appropriate action. - pref_sync_managed_.Init(prefs::kSyncManaged, pref_service_, - base::Bind(&SyncPrefs::OnSyncManagedPrefChanged, - base::Unretained(this))); + pref_sync_managed_.Init( + prefs::kSyncManaged, + pref_service_, + base::Bind(&SyncPrefs::OnSyncManagedPrefChanged, base::Unretained(this))); } -SyncPrefs::~SyncPrefs() { - DCHECK(CalledOnValidThread()); -} +SyncPrefs::~SyncPrefs() { DCHECK(CalledOnValidThread()); } // static void SyncPrefs::RegisterProfilePrefs( @@ -88,8 +80,8 @@ void SyncPrefs::RegisterProfilePrefs( // explicitly enable them. GetPreferredTypes() will ensure that any new // implicit types are enabled when their pref group is, or via // KeepEverythingSynced. - for (syncer::ModelTypeSet::Iterator it = user_types.First(); - it.Good(); it.Inc()) { + for (syncer::ModelTypeSet::Iterator it = user_types.First(); it.Good(); + it.Inc()) { RegisterDataTypePreferredPref(registry, it.Get(), false); } @@ -197,16 +189,10 @@ void SyncPrefs::SetStartSuppressed(bool is_suppressed) { pref_service_->SetBoolean(prefs::kSyncSuppressStart, is_suppressed); } -std::string SyncPrefs::GetGoogleServicesUsername() const { - DCHECK(CalledOnValidThread()); - return pref_service_->GetString(prefs::kGoogleServicesUsername); -} - base::Time SyncPrefs::GetLastSyncedTime() const { DCHECK(CalledOnValidThread()); - return - base::Time::FromInternalValue( - pref_service_->GetInt64(prefs::kSyncLastSyncedTime)); + return base::Time::FromInternalValue( + pref_service_->GetInt64(prefs::kSyncLastSyncedTime)); } void SyncPrefs::SetLastSyncedTime(base::Time time) { @@ -229,20 +215,13 @@ syncer::ModelTypeSet SyncPrefs::GetPreferredDataTypes( syncer::ModelTypeSet registered_types) const { DCHECK(CalledOnValidThread()); - // First remove any datatypes that are inconsistent with the current policies - // on the client (so that "keep everything synced" doesn't include them). - if (pref_service_->HasPrefPath(prefs::kSavingBrowserHistoryDisabled) && - pref_service_->GetBoolean(prefs::kSavingBrowserHistoryDisabled)) { - registered_types.Remove(syncer::TYPED_URLS); - } - if (pref_service_->GetBoolean(prefs::kSyncKeepEverythingSynced)) { return registered_types; } syncer::ModelTypeSet preferred_types; - for (syncer::ModelTypeSet::Iterator it = registered_types.First(); - it.Good(); it.Inc()) { + for (syncer::ModelTypeSet::Iterator it = registered_types.First(); it.Good(); + it.Inc()) { if (GetDataTypePreferred(it.Get())) { preferred_types.Put(it.Get()); } @@ -250,14 +229,13 @@ syncer::ModelTypeSet SyncPrefs::GetPreferredDataTypes( return ResolvePrefGroups(registered_types, preferred_types); } -void SyncPrefs::SetPreferredDataTypes( - syncer::ModelTypeSet registered_types, - syncer::ModelTypeSet preferred_types) { +void SyncPrefs::SetPreferredDataTypes(syncer::ModelTypeSet registered_types, + syncer::ModelTypeSet preferred_types) { DCHECK(CalledOnValidThread()); DCHECK(registered_types.HasAll(preferred_types)); preferred_types = ResolvePrefGroups(registered_types, preferred_types); - for (syncer::ModelTypeSet::Iterator i = registered_types.First(); - i.Good(); i.Inc()) { + for (syncer::ModelTypeSet::Iterator i = registered_types.First(); i.Good(); + i.Inc()) { SetDataTypePreferred(i.Get(), preferred_types.Has(i.Get())); } } @@ -279,8 +257,7 @@ void SyncPrefs::SetEncryptionBootstrapToken(const std::string& token) { std::string SyncPrefs::GetKeystoreEncryptionBootstrapToken() const { DCHECK(CalledOnValidThread()); - return pref_service_->GetString( - prefs::kSyncKeystoreEncryptionBootstrapToken); + return pref_service_->GetString(prefs::kSyncKeystoreEncryptionBootstrapToken); } void SyncPrefs::SetKeystoreEncryptionBootstrapToken(const std::string& token) { @@ -390,7 +367,8 @@ void SyncPrefs::AcknowledgeSyncedTypes(syncer::ModelTypeSet types) { void SyncPrefs::OnSyncManagedPrefChanged() { DCHECK(CalledOnValidThread()); - FOR_EACH_OBSERVER(SyncPrefObserver, sync_pref_observers_, + FOR_EACH_OBSERVER(SyncPrefObserver, + sync_pref_observers_, OnSyncManagedPrefChange(*pref_sync_managed_)); } @@ -467,8 +445,8 @@ bool SyncPrefs::GetDataTypePreferred(syncer::ModelType type) const { return pref_service_->GetBoolean(pref_name); } -void SyncPrefs::SetDataTypePreferred( - syncer::ModelType type, bool is_preferred) { +void SyncPrefs::SetDataTypePreferred(syncer::ModelType type, + bool is_preferred) { DCHECK(CalledOnValidThread()); const char* pref_name = GetPrefNameForDataType(type); if (!pref_name) { @@ -484,7 +462,8 @@ syncer::ModelTypeSet SyncPrefs::ResolvePrefGroups( DCHECK(registered_types.HasAll(types)); syncer::ModelTypeSet types_with_groups = types; for (PrefGroupsMap::const_iterator i = pref_groups_.begin(); - i != pref_groups_.end(); ++i) { + i != pref_groups_.end(); + ++i) { if (types.Has(i->first)) types_with_groups.PutAll(i->second); } diff --git a/chrome/browser/sync/sync_prefs.h b/components/sync_driver/sync_prefs.h index b46c001..063c3d3 100644 --- a/chrome/browser/sync/sync_prefs.h +++ b/components/sync_driver/sync_prefs.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_SYNC_SYNC_PREFS_H_ -#define CHROME_BROWSER_SYNC_SYNC_PREFS_H_ +#ifndef COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ +#define COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -22,7 +22,7 @@ namespace user_prefs { class PrefRegistrySyncable; } -namespace browser_sync { +namespace sync_driver { class SyncPrefObserver { public: @@ -75,8 +75,6 @@ class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), bool IsStartSuppressed() const; void SetStartSuppressed(bool is_suppressed); - std::string GetGoogleServicesUsername() const; - base::Time GetLastSyncedTime() const; void SetLastSyncedTime(base::Time time); @@ -94,9 +92,8 @@ class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), // Changes are still made to the prefs even if // HasKeepEverythingSynced() is true, but won't be visible until // SetKeepEverythingSynced(false) is called. - void SetPreferredDataTypes( - syncer::ModelTypeSet registered_types, - syncer::ModelTypeSet preferred_types); + void SetPreferredDataTypes(syncer::ModelTypeSet registered_types, + syncer::ModelTypeSet preferred_types); // This pref is set outside of sync. bool IsManaged() const; @@ -144,9 +141,8 @@ class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), // Returns a ModelTypeSet based on |types| expanded to include pref groups // (see |pref_groups_|), but as a subset of |registered_types|. - syncer::ModelTypeSet ResolvePrefGroups( - syncer::ModelTypeSet registered_types, - syncer::ModelTypeSet types) const; + syncer::ModelTypeSet ResolvePrefGroups(syncer::ModelTypeSet registered_types, + syncer::ModelTypeSet types) const; void OnSyncManagedPrefChanged(); @@ -174,4 +170,4 @@ class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), } // namespace browser_sync -#endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ +#endif // COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ diff --git a/chrome/browser/sync/sync_prefs_unittest.cc b/components/sync_driver/sync_prefs_unittest.cc index 6356ebe..5396057 100644 --- a/chrome/browser/sync/sync_prefs_unittest.cc +++ b/components/sync_driver/sync_prefs_unittest.cc @@ -2,25 +2,83 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/sync/sync_prefs.h" +#include "components/sync_driver/sync_prefs.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" +#include "base/prefs/pref_notifier_impl.h" +#include "base/prefs/pref_value_store.h" +#include "base/prefs/testing_pref_service.h" #include "base/time/time.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/testing_pref_service_syncable.h" +#include "components/sync_driver/pref_names.h" +#include "components/user_prefs/pref_registry_syncable.h" #include "sync/internal_api/public/base/model_type.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -namespace browser_sync { +template <> +TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>:: + TestingPrefServiceBase(TestingPrefStore* managed_prefs, + TestingPrefStore* user_prefs, + TestingPrefStore* recommended_prefs, + user_prefs::PrefRegistrySyncable* pref_registry, + PrefNotifierImpl* pref_notifier) + : PrefService( + pref_notifier, + new PrefValueStore(managed_prefs, + NULL, // supervised_user_prefs + NULL, // extension_prefs + NULL, // command_line_prefs + user_prefs, + recommended_prefs, + pref_registry->defaults().get(), + pref_notifier), + user_prefs, + pref_registry, + base::Bind(&TestingPrefServiceBase< + PrefService, + user_prefs::PrefRegistrySyncable>::HandleReadError), + false), + managed_prefs_(managed_prefs), + user_prefs_(user_prefs), + recommended_prefs_(recommended_prefs) {} + +namespace sync_driver { namespace { using ::testing::InSequence; using ::testing::StrictMock; +// Test version of PrefServiceSyncable. +class TestingPrefServiceSyncable + : public TestingPrefServiceBase<PrefService, + user_prefs::PrefRegistrySyncable> { + public: + TestingPrefServiceSyncable(); + virtual ~TestingPrefServiceSyncable(); + + user_prefs::PrefRegistrySyncable* registry(); + + private: + DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable); +}; + +TestingPrefServiceSyncable::TestingPrefServiceSyncable() + : TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>( + new TestingPrefStore(), + new TestingPrefStore(), + new TestingPrefStore(), + new user_prefs::PrefRegistrySyncable(), + new PrefNotifierImpl()) {} + +TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {} + +user_prefs::PrefRegistrySyncable* TestingPrefServiceSyncable::registry() { + return static_cast<user_prefs::PrefRegistrySyncable*>( + DeprecatedGetPrefRegistry()); +} + class SyncPrefsTest : public testing::Test { protected: virtual void SetUp() OVERRIDE { @@ -67,8 +125,8 @@ TEST_F(SyncPrefsTest, DefaultTypes) { sync_prefs.SetKeepEverythingSynced(false); // Only bookmarks are enabled by default. - syncer::ModelTypeSet preferred_types = sync_prefs.GetPreferredDataTypes( - syncer::UserTypes()); + syncer::ModelTypeSet preferred_types = + sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); EXPECT_TRUE(preferred_types.Equals(syncer::ModelTypeSet(syncer::BOOKMARKS))); // Simulate an upgrade to delete directives + proxy tabs support. None of the @@ -81,16 +139,14 @@ TEST_F(SyncPrefsTest, DefaultTypes) { registered_types.Remove(syncer::HISTORY_DELETE_DIRECTIVES); // Enable all other types. - sync_prefs.SetPreferredDataTypes(registered_types, - registered_types); + sync_prefs.SetPreferredDataTypes(registered_types, registered_types); // Manually enable typed urls (to simulate the old world). pref_service_.SetBoolean(prefs::kSyncTypedUrls, true); // Proxy tabs should not be enabled (since sessions wasn't), but history // delete directives should (since typed urls was). - preferred_types = - sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); + preferred_types = sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); EXPECT_FALSE(preferred_types.Has(syncer::PROXY_TABS)); EXPECT_TRUE(preferred_types.Has(syncer::HISTORY_DELETE_DIRECTIVES)); @@ -99,8 +155,7 @@ TEST_F(SyncPrefsTest, DefaultTypes) { // delete directives are not enabled. pref_service_.SetBoolean(prefs::kSyncTypedUrls, false); pref_service_.SetBoolean(prefs::kSyncSessions, true); - preferred_types = - sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); + preferred_types = sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); EXPECT_TRUE(preferred_types.Has(syncer::PROXY_TABS)); EXPECT_FALSE(preferred_types.Has(syncer::HISTORY_DELETE_DIRECTIVES)); } @@ -111,16 +166,16 @@ TEST_F(SyncPrefsTest, PreferredTypesKeepEverythingSynced) { EXPECT_TRUE(sync_prefs.HasKeepEverythingSynced()); const syncer::ModelTypeSet user_types = syncer::UserTypes(); - EXPECT_TRUE(user_types.Equals( - sync_prefs.GetPreferredDataTypes(user_types))); + EXPECT_TRUE(user_types.Equals(sync_prefs.GetPreferredDataTypes(user_types))); const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); - it.Good(); it.Inc()) { + it.Good(); + it.Inc()) { syncer::ModelTypeSet preferred_types; preferred_types.Put(it.Get()); sync_prefs.SetPreferredDataTypes(user_types, preferred_types); - EXPECT_TRUE(user_types.Equals( - sync_prefs.GetPreferredDataTypes(user_types))); + EXPECT_TRUE( + user_types.Equals(sync_prefs.GetPreferredDataTypes(user_types))); } } @@ -130,11 +185,11 @@ TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) { sync_prefs.SetKeepEverythingSynced(false); const syncer::ModelTypeSet user_types = syncer::UserTypes(); - EXPECT_FALSE(user_types.Equals( - sync_prefs.GetPreferredDataTypes(user_types))); + EXPECT_FALSE(user_types.Equals(sync_prefs.GetPreferredDataTypes(user_types))); const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); - it.Good(); it.Inc()) { + it.Good(); + it.Inc()) { syncer::ModelTypeSet preferred_types; preferred_types.Put(it.Get()); syncer::ModelTypeSet expected_preferred_types(preferred_types); |