diff options
author | jitendra.ks <jitendra.ks@samsung.com> | 2015-08-10 01:24:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-10 08:24:52 +0000 |
commit | 94c0b9648ae7c0d72c3c280e014d83866eeef252 (patch) | |
tree | 62c1743a99ceaa7c5f5513a052ee37cf18224916 | |
parent | 72191c2d7d2338d21d73cf3c9ef7fcd48a989c5d (diff) | |
download | chromium_src-94c0b9648ae7c0d72c3c280e014d83866eeef252.zip chromium_src-94c0b9648ae7c0d72c3c280e014d83866eeef252.tar.gz chromium_src-94c0b9648ae7c0d72c3c280e014d83866eeef252.tar.bz2 |
Componentize //chrome/browser/prefs/tracked.
Componentize //chrome/browser/prefs/tracked and
updated corresponding .gypi files for same.
Moved the files from //chrome/browser/prefs/tracked
to //components/user_prefs/tracked.
Also added new //components/user_prefs/pref_names.* file and added BUILD.gn for same
BUG=507660
Review URL: https://codereview.chromium.org/1227973003
Cr-Commit-Position: refs/heads/master@{#342588}
-rw-r--r-- | chrome/browser/BUILD.gn | 2 | ||||
-rw-r--r-- | chrome/browser/prefs/chrome_pref_service_factory.cc | 4 | ||||
-rw-r--r-- | chrome/browser/prefs/profile_pref_store_manager.cc | 8 | ||||
-rw-r--r-- | chrome/browser/prefs/profile_pref_store_manager.h | 2 | ||||
-rw-r--r-- | chrome/browser/prefs/profile_pref_store_manager_unittest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc | 4 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.cc | 2 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 31 | ||||
-rw-r--r-- | chrome/chrome_tests_unit.gypi | 10 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 2 | ||||
-rw-r--r-- | components/BUILD.gn | 2 | ||||
-rw-r--r-- | components/components_tests.gyp | 12 | ||||
-rw-r--r-- | components/user_prefs.gypi | 66 | ||||
-rw-r--r-- | components/user_prefs/tracked/BUILD.gn | 89 | ||||
-rw-r--r-- | components/user_prefs/tracked/DEPS | 4 | ||||
-rw-r--r-- | components/user_prefs/tracked/OWNERS | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/device_id.h (renamed from chrome/browser/prefs/tracked/device_id.h) | 6 | ||||
-rw-r--r-- | components/user_prefs/tracked/device_id_stub.cc (renamed from chrome/browser/prefs/tracked/device_id_stub.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/device_id_unittest.cc (renamed from chrome/browser/prefs/tracked/device_id_unittest.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/device_id_win.cc (renamed from chrome/browser/prefs/tracked/device_id_win.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/dictionary_hash_store_contents.cc (renamed from chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/dictionary_hash_store_contents.h (renamed from chrome/browser/prefs/tracked/dictionary_hash_store_contents.h) | 8 | ||||
-rw-r--r-- | components/user_prefs/tracked/hash_store_contents.h (renamed from chrome/browser/prefs/tracked/hash_store_contents.h) | 8 | ||||
-rw-r--r-- | components/user_prefs/tracked/interceptable_pref_filter.cc (renamed from chrome/browser/prefs/tracked/interceptable_pref_filter.cc) | 14 | ||||
-rw-r--r-- | components/user_prefs/tracked/interceptable_pref_filter.h (renamed from chrome/browser/prefs/tracked/interceptable_pref_filter.h) | 12 | ||||
-rw-r--r-- | components/user_prefs/tracked/mock_validation_delegate.cc (renamed from chrome/browser/prefs/tracked/mock_validation_delegate.cc) | 10 | ||||
-rw-r--r-- | components/user_prefs/tracked/mock_validation_delegate.h (renamed from chrome/browser/prefs/tracked/mock_validation_delegate.h) | 12 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_calculator.cc (renamed from chrome/browser/prefs/tracked/pref_hash_calculator.cc) | 17 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_calculator.h (renamed from chrome/browser/prefs/tracked/pref_hash_calculator.h) | 10 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_calculator_unittest.cc (renamed from chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc) | 80 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_filter.cc (renamed from chrome/browser/prefs/tracked/pref_hash_filter.cc) | 32 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_filter.h (renamed from chrome/browser/prefs/tracked/pref_hash_filter.h) | 15 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_filter_unittest.cc (renamed from chrome/browser/prefs/tracked/pref_hash_filter_unittest.cc) | 244 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_store.h (renamed from chrome/browser/prefs/tracked/pref_hash_store.h) | 6 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_store_impl.cc (renamed from chrome/browser/prefs/tracked/pref_hash_store_impl.cc) | 29 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_store_impl.h (renamed from chrome/browser/prefs/tracked/pref_hash_store_impl.h) | 10 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_store_impl_unittest.cc (renamed from chrome/browser/prefs/tracked/pref_hash_store_impl_unittest.cc) | 11 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_hash_store_transaction.h (renamed from chrome/browser/prefs/tracked/pref_hash_store_transaction.h) | 18 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_names.cc | 13 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_names.h | 14 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_service_hash_store_contents.cc (renamed from chrome/browser/prefs/tracked/pref_service_hash_store_contents.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_service_hash_store_contents.h (renamed from chrome/browser/prefs/tracked/pref_service_hash_store_contents.h) | 8 | ||||
-rw-r--r-- | components/user_prefs/tracked/pref_service_hash_store_contents_unittest.cc (renamed from chrome/browser/prefs/tracked/pref_service_hash_store_contents_unittest.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/segregated_pref_store.cc (renamed from chrome/browser/prefs/tracked/segregated_pref_store.cc) | 15 | ||||
-rw-r--r-- | components/user_prefs/tracked/segregated_pref_store.h (renamed from chrome/browser/prefs/tracked/segregated_pref_store.h) | 6 | ||||
-rw-r--r-- | components/user_prefs/tracked/segregated_pref_store_unittest.cc (renamed from chrome/browser/prefs/tracked/segregated_pref_store_unittest.cc) | 25 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_atomic_preference.cc (renamed from chrome/browser/prefs/tracked/tracked_atomic_preference.cc) | 15 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_atomic_preference.h (renamed from chrome/browser/prefs/tracked/tracked_atomic_preference.h) | 12 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preference.h (renamed from chrome/browser/prefs/tracked/tracked_preference.h) | 6 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preference_helper.cc (renamed from chrome/browser/prefs/tracked/tracked_preference_helper.cc) | 2 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preference_helper.h (renamed from chrome/browser/prefs/tracked/tracked_preference_helper.h) | 13 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preference_validation_delegate.h (renamed from chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h) | 8 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preferences_migration.cc (renamed from chrome/browser/prefs/tracked/tracked_preferences_migration.cc) | 12 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preferences_migration.h (renamed from chrome/browser/prefs/tracked/tracked_preferences_migration.h) | 8 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_preferences_migration_unittest.cc (renamed from chrome/browser/prefs/tracked/tracked_preferences_migration_unittest.cc) | 21 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_split_preference.cc (renamed from chrome/browser/prefs/tracked/tracked_split_preference.cc) | 15 | ||||
-rw-r--r-- | components/user_prefs/tracked/tracked_split_preference.h (renamed from chrome/browser/prefs/tracked/tracked_split_preference.h) | 12 |
61 files changed, 574 insertions, 446 deletions
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 9b9bcfe..d1447cb 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -149,6 +149,7 @@ source_set("browser") { "//components/update_client", "//components/url_formatter", "//components/user_prefs", + "//components/user_prefs/tracked:user_prefs_tracked", "//components/variations", "//components/variations/net", "//components/webdata/common", @@ -1058,6 +1059,7 @@ source_set("test_support") { "//components/invalidation/impl:test_support", "//components/password_manager/core/browser:test_support", "//components/search_engines:test_support", + "//components/user_prefs/tracked:user_prefs_tracked_test_support", "//content/test:test_support", "//chrome/app/theme:theme_resources", "//net:test_support", diff --git a/chrome/browser/prefs/chrome_pref_service_factory.cc b/chrome/browser/prefs/chrome_pref_service_factory.cc index 3734776..5bd3623 100644 --- a/chrome/browser/prefs/chrome_pref_service_factory.cc +++ b/chrome/browser/prefs/chrome_pref_service_factory.cc @@ -30,7 +30,6 @@ #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/prefs/pref_service_syncable_factory.h" #include "chrome/browser/prefs/profile_pref_store_manager.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" #include "chrome/browser/profiles/file_path_verifier_win.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/glue/sync_start_util.h" @@ -45,6 +44,7 @@ #include "components/search_engines/default_search_pref_migration.h" #include "components/search_engines/search_engines_pref_names.h" #include "components/sync_driver/pref_names.h" +#include "components/user_prefs/tracked/pref_names.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "grit/browser_resources.h" @@ -190,7 +190,7 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = { // a reset in FilterOnLoad and SegregatedPrefStore will not look for it // in the protected JsonPrefStore unless it's declared as a protected // preference here. - 15, prefs::kPreferenceResetTime, + 15, user_prefs::kPreferenceResetTime, PrefHashFilter::ENFORCE_ON_LOAD, PrefHashFilter::TRACKING_STRATEGY_ATOMIC, PrefHashFilter::VALUE_IMPERSONAL diff --git a/chrome/browser/prefs/profile_pref_store_manager.cc b/chrome/browser/prefs/profile_pref_store_manager.cc index f08d102..74b1a36 100644 --- a/chrome/browser/prefs/profile_pref_store_manager.cc +++ b/chrome/browser/prefs/profile_pref_store_manager.cc @@ -14,13 +14,13 @@ #include "base/prefs/persistent_pref_store.h" #include "base/prefs/pref_registry_simple.h" #include "base/sequenced_task_runner.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_impl.h" -#include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/segregated_pref_store.h" -#include "chrome/browser/prefs/tracked/tracked_preferences_migration.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/user_prefs/tracked/pref_hash_store_impl.h" +#include "components/user_prefs/tracked/pref_service_hash_store_contents.h" +#include "components/user_prefs/tracked/segregated_pref_store.h" +#include "components/user_prefs/tracked/tracked_preferences_migration.h" namespace { diff --git a/chrome/browser/prefs/profile_pref_store_manager.h b/chrome/browser/prefs/profile_pref_store_manager.h index 164ac4a..5122800 100644 --- a/chrome/browser/prefs/profile_pref_store_manager.h +++ b/chrome/browser/prefs/profile_pref_store_manager.h @@ -12,7 +12,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" class PersistentPrefStore; class PrefHashStore; diff --git a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc index 83a9f3d..5d633bc6 100644 --- a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc +++ b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc @@ -21,11 +21,11 @@ #include "base/run_loop.h" #include "base/strings/string_util.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/mock_validation_delegate.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" -#include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" -#include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/user_prefs/tracked/mock_validation_delegate.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_names.h" +#include "components/user_prefs/tracked/pref_service_hash_store_contents.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -114,7 +114,8 @@ class ProfilePrefStoreManagerTest : public testing::Test { // registered above for this test as kPreferenceResetTime is already // registered in ProfilePrefStoreManager::RegisterProfilePrefs. PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = - {configuration_.rbegin()->reporting_id + 1, prefs::kPreferenceResetTime, + {configuration_.rbegin()->reporting_id + 1, + user_prefs::kPreferenceResetTime, PrefHashFilter::ENFORCE_ON_LOAD, PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; configuration_.push_back(pref_reset_time_config); diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 7f05c2c..b50d00d 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -52,7 +52,6 @@ #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/chrome_pref_service_factory.h" #include "chrome/browser/prefs/pref_service_syncable.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" #include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" #include "chrome/browser/profiles/chrome_version_service.h" @@ -91,6 +90,7 @@ #include "components/signin/core/browser/signin_manager.h" #include "components/ui/zoom/zoom_event_manager.h" #include "components/url_formatter/url_fixer.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" #include "components/user_prefs/user_prefs.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/dom_storage_context.h" diff --git a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc index 5f40cbf..2a2c335 100644 --- a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc +++ b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc @@ -18,7 +18,6 @@ #include "base/threading/sequenced_worker_pool.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/database_manager.h" #include "chrome/browser/safe_browsing/incident_reporting/environment_data_collection.h" @@ -30,6 +29,7 @@ #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/safe_browsing/csd.pb.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "net/url_request/url_request_context_getter.h" diff --git a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc index 60b460a..1f71f40 100644 --- a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc +++ b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc @@ -8,11 +8,11 @@ #include <vector> #include "base/json/json_writer.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/tracked_preference_helper.h" #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_incident.h" #include "chrome/common/safe_browsing/csd.pb.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/tracked_preference_helper.h" namespace safe_browsing { diff --git a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h index 1fb789e..04302c7 100644 --- a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h +++ b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h @@ -8,7 +8,7 @@ #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" class Profile; diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index c78ff00..def8192 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -21,7 +21,6 @@ #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/safe_browsing/client_side_detection_service.h" @@ -37,6 +36,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" #include "content/public/browser/notification_service.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5085d58..e52f756 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1276,7 +1276,6 @@ 'browser/renderer_context_menu/spellchecker_submenu_observer_hunspell.cc', ], 'chrome_browser_non_win_sources': [ - 'browser/prefs/tracked/device_id_stub.cc', 'browser/profiles/profile_shortcut_manager_stub.cc', ], # Sources (generally "desktop OS importers") used only on Mac & Windows. @@ -2277,35 +2276,6 @@ 'browser/prefs/synced_pref_change_registrar.cc', 'browser/prefs/synced_pref_change_registrar.h', 'browser/prefs/synced_pref_observer.h', - 'browser/prefs/tracked/device_id.h', - 'browser/prefs/tracked/device_id_win.cc', - 'browser/prefs/tracked/dictionary_hash_store_contents.cc', - 'browser/prefs/tracked/dictionary_hash_store_contents.h', - 'browser/prefs/tracked/hash_store_contents.h', - 'browser/prefs/tracked/interceptable_pref_filter.cc', - 'browser/prefs/tracked/interceptable_pref_filter.h', - 'browser/prefs/tracked/pref_hash_calculator.cc', - 'browser/prefs/tracked/pref_hash_calculator.h', - 'browser/prefs/tracked/pref_hash_filter.cc', - 'browser/prefs/tracked/pref_hash_filter.h', - 'browser/prefs/tracked/pref_hash_store.h', - 'browser/prefs/tracked/pref_hash_store_impl.cc', - 'browser/prefs/tracked/pref_hash_store_impl.h', - 'browser/prefs/tracked/pref_hash_store_transaction.h', - 'browser/prefs/tracked/pref_service_hash_store_contents.cc', - 'browser/prefs/tracked/pref_service_hash_store_contents.h', - 'browser/prefs/tracked/segregated_pref_store.cc', - 'browser/prefs/tracked/segregated_pref_store.h', - 'browser/prefs/tracked/tracked_atomic_preference.cc', - 'browser/prefs/tracked/tracked_atomic_preference.h', - 'browser/prefs/tracked/tracked_preference.h', - 'browser/prefs/tracked/tracked_preference_helper.cc', - 'browser/prefs/tracked/tracked_preference_helper.h', - 'browser/prefs/tracked/tracked_preference_validation_delegate.h', - 'browser/prefs/tracked/tracked_preferences_migration.cc', - 'browser/prefs/tracked/tracked_preferences_migration.h', - 'browser/prefs/tracked/tracked_split_preference.cc', - 'browser/prefs/tracked/tracked_split_preference.h', ], # Used both when (enable_basic_printing==1 or enable_print_preview==1). 'chrome_browser_printing_basic_sources': [ @@ -3284,6 +3254,7 @@ '../components/components.gyp:translate_content_browser', '../components/components.gyp:upload_list', '../components/components.gyp:url_matcher', + '../components/components.gyp:user_prefs_tracked', '../components/components.gyp:visitedlink_browser', '../components/components.gyp:visitedlink_common', '../components/components.gyp:web_cache_browser', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index a816def..282ff81 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -183,15 +183,6 @@ 'browser/prefs/prefs_syncable_service_unittest.cc', 'browser/prefs/profile_pref_store_manager_unittest.cc', 'browser/prefs/session_startup_pref_unittest.cc', - 'browser/prefs/tracked/device_id_unittest.cc', - 'browser/prefs/tracked/mock_validation_delegate.cc', - 'browser/prefs/tracked/mock_validation_delegate.h', - 'browser/prefs/tracked/pref_hash_calculator_unittest.cc', - 'browser/prefs/tracked/pref_hash_filter_unittest.cc', - 'browser/prefs/tracked/pref_hash_store_impl_unittest.cc', - 'browser/prefs/tracked/pref_service_hash_store_contents_unittest.cc', - 'browser/prefs/tracked/segregated_pref_store_unittest.cc', - 'browser/prefs/tracked/tracked_preferences_migration_unittest.cc', 'browser/prerender/prerender_history_unittest.cc', 'browser/prerender/prerender_resource_throttle_unittest.cc', 'browser/prerender/prerender_unittest.cc', @@ -1675,6 +1666,7 @@ '../components/components.gyp:signin_core_browser_test_support', '../components/components.gyp:sync_driver_test_support', '../components/components.gyp:update_client_test_support', + '../components/components.gyp:user_prefs_tracked_test_support', '../components/components.gyp:wallpaper', '../content/content.gyp:content_app_both', '../content/content_shell_and_tests.gyp:test_support_content', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index fc7d981..830a697 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1161,10 +1161,6 @@ const char kFullscreenAllowed[] = "fullscreen.allowed"; const char kLocalDiscoveryNotificationsEnabled[] = "local_discovery.notifications_enabled"; -// A timestamp (stored in base::Time::ToInternalValue format) of the last time -// a preference was reset. -const char kPreferenceResetTime[] = "prefs.preference_reset_time"; - // How many Service Workers are registered with the Push API (could be zero). const char kPushMessagingRegistrationCount[] = "gcm.push_messaging_registration_count"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 384a6dd..49a0cd9 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -399,8 +399,6 @@ extern const char kFullscreenAllowed[]; extern const char kLocalDiscoveryNotificationsEnabled[]; -extern const char kPreferenceResetTime[]; - extern const char kPushMessagingRegistrationCount[]; extern const char kPushMessagingAppIdentifierMap[]; diff --git a/components/BUILD.gn b/components/BUILD.gn index 7fddcb6..8806c7e 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn @@ -113,6 +113,7 @@ group("all_components") { "//components/url_matcher", "//components/user_manager", "//components/user_prefs", + "//components/user_prefs/tracked:user_prefs_tracked", "//components/variations", "//components/version_info", "//components/visitedlink/browser", @@ -323,6 +324,7 @@ test("components_unittests") { "//components/url_formatter:unit_tests", "//components/update_client:unit_tests", "//components/upload_list:unit_tests", + "//components/user_prefs/tracked:unit_tests", "//components/variations:unit_tests", "//components/webcrypto:unit_tests", "//components/web_resource:unit_tests", diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 475b750..e04bad9 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -454,6 +454,15 @@ 'precache/core/precache_fetcher_unittest.cc', 'precache/core/precache_url_table_unittest.cc', ], + 'user_prefs_unittest_sources': [ + 'user_prefs/tracked/device_id_unittest.cc', + 'user_prefs/tracked/pref_hash_calculator_unittest.cc', + 'user_prefs/tracked/pref_hash_filter_unittest.cc', + 'user_prefs/tracked/pref_hash_store_impl_unittest.cc', + 'user_prefs/tracked/pref_service_hash_store_contents_unittest.cc', + 'user_prefs/tracked/segregated_pref_store_unittest.cc', + 'user_prefs/tracked/tracked_preferences_migration_unittest.cc', + ], 'proximity_auth_unittest_sources': [ 'proximity_auth/ble/bluetooth_low_energy_characteristics_finder_unittest.cc', 'proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc', @@ -771,6 +780,7 @@ '<@(upload_list_unittest_sources)', '<@(url_formatter_unittest_sources)', '<@(url_matcher_unittest_sources)', + '<@(user_prefs_unittest_sources)', '<@(variations_unittest_sources)', '<@(wallpaper_unittest_sources)', '<@(web_resource_unittest_sources)', @@ -886,6 +896,8 @@ 'components.gyp:update_client', 'components.gyp:update_client_test_support', 'components.gyp:upload_list', + 'components.gyp:user_prefs_tracked', + 'components.gyp:user_prefs_tracked_test_support', 'components.gyp:variations', 'components.gyp:variations_http_provider', 'components.gyp:wallpaper', diff --git a/components/user_prefs.gypi b/components/user_prefs.gypi index 3554d0d..236e8eda 100644 --- a/components/user_prefs.gypi +++ b/components/user_prefs.gypi @@ -23,5 +23,71 @@ 'user_prefs/user_prefs_export.h', ], }, + { + 'target_name': 'user_prefs_tracked', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + ], + 'sources': [ + 'user_prefs/tracked/device_id.h', + 'user_prefs/tracked/device_id_stub.cc', + 'user_prefs/tracked/device_id_win.cc', + 'user_prefs/tracked/dictionary_hash_store_contents.cc', + 'user_prefs/tracked/dictionary_hash_store_contents.h', + 'user_prefs/tracked/hash_store_contents.h', + 'user_prefs/tracked/interceptable_pref_filter.cc', + 'user_prefs/tracked/interceptable_pref_filter.h', + 'user_prefs/tracked/pref_hash_calculator.cc', + 'user_prefs/tracked/pref_hash_calculator.h', + 'user_prefs/tracked/pref_hash_filter.cc', + 'user_prefs/tracked/pref_hash_filter.h', + 'user_prefs/tracked/pref_hash_store.h', + 'user_prefs/tracked/pref_hash_store_impl.cc', + 'user_prefs/tracked/pref_hash_store_impl.h', + 'user_prefs/tracked/pref_hash_store_transaction.h', + 'user_prefs/tracked/pref_names.cc', + 'user_prefs/tracked/pref_names.h', + 'user_prefs/tracked/pref_service_hash_store_contents.cc', + 'user_prefs/tracked/pref_service_hash_store_contents.h', + 'user_prefs/tracked/segregated_pref_store.cc', + 'user_prefs/tracked/segregated_pref_store.h', + 'user_prefs/tracked/tracked_atomic_preference.cc', + 'user_prefs/tracked/tracked_atomic_preference.h', + 'user_prefs/tracked/tracked_preference.h', + 'user_prefs/tracked/tracked_preference_helper.cc', + 'user_prefs/tracked/tracked_preference_helper.h', + 'user_prefs/tracked/tracked_preference_validation_delegate.h', + 'user_prefs/tracked/tracked_preferences_migration.cc', + 'user_prefs/tracked/tracked_preferences_migration.h', + 'user_prefs/tracked/tracked_split_preference.cc', + 'user_prefs/tracked/tracked_split_preference.h', + ], + 'conditions': [ + ['OS=="win"', { + 'sources!': [ + 'user_prefs/tracked/device_id_stub.cc', + ], + }], + ], + + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + 'msvs_disabled_warnings': [4267, ], + }, + { + 'target_name': 'user_prefs_tracked_test_support', + 'type': 'static_library', + 'include_dirs': [ + '..', + ], + 'dependencies': [ + ], + 'sources': [ + 'user_prefs/tracked/mock_validation_delegate.cc', + 'user_prefs/tracked/mock_validation_delegate.h', + ], + }, ], } diff --git a/components/user_prefs/tracked/BUILD.gn b/components/user_prefs/tracked/BUILD.gn new file mode 100644 index 0000000..b2083f8 --- /dev/null +++ b/components/user_prefs/tracked/BUILD.gn @@ -0,0 +1,89 @@ +# 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. + +static_library("user_prefs_tracked") { + sources = [ + "device_id.h", + "device_id_stub.cc", + "device_id_win.cc", + "dictionary_hash_store_contents.cc", + "dictionary_hash_store_contents.h", + "hash_store_contents.h", + "interceptable_pref_filter.cc", + "interceptable_pref_filter.h", + "pref_hash_calculator.cc", + "pref_hash_calculator.h", + "pref_hash_filter.cc", + "pref_hash_filter.h", + "pref_hash_store.h", + "pref_hash_store_impl.cc", + "pref_hash_store_impl.h", + "pref_hash_store_transaction.h", + "pref_names.cc", + "pref_names.h", + "pref_service_hash_store_contents.cc", + "pref_service_hash_store_contents.h", + "segregated_pref_store.cc", + "segregated_pref_store.h", + "tracked_atomic_preference.cc", + "tracked_atomic_preference.h", + "tracked_preference.h", + "tracked_preference_helper.cc", + "tracked_preference_helper.h", + "tracked_preference_validation_delegate.h", + "tracked_preferences_migration.cc", + "tracked_preferences_migration.h", + "tracked_split_preference.cc", + "tracked_split_preference.h", + ] + + if (is_win) { + sources -= [ "device_id_stub.cc" ] + } + + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + + deps = [ + "//base:base", + "//base:prefs", + "//crypto:crypto", + "//components/pref_registry", + ] +} + +source_set("user_prefs_tracked_test_support") { + testonly = true + sources = [ + "mock_validation_delegate.cc", + "mock_validation_delegate.h", + ] + + deps = [ + ":user_prefs_tracked", + "//base:base", + ] +} + +source_set("unit_tests") { + testonly = true + sources = [ + "device_id_unittest.cc", + "pref_hash_calculator_unittest.cc", + "pref_hash_filter_unittest.cc", + "pref_hash_store_impl_unittest.cc", + "pref_service_hash_store_contents_unittest.cc", + "segregated_pref_store_unittest.cc", + "tracked_preferences_migration_unittest.cc", + ] + + deps = [ + ":user_prefs_tracked", + ":user_prefs_tracked_test_support", + "//base:base", + "//base:prefs", + "//base:prefs_test_support", + "//testing/gtest", + ] +} diff --git a/components/user_prefs/tracked/DEPS b/components/user_prefs/tracked/DEPS new file mode 100644 index 0000000..6ccb05e --- /dev/null +++ b/components/user_prefs/tracked/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+components/pref_registry", + "+crypto/hmac.h", +] diff --git a/components/user_prefs/tracked/OWNERS b/components/user_prefs/tracked/OWNERS new file mode 100644 index 0000000..2845b0f --- /dev/null +++ b/components/user_prefs/tracked/OWNERS @@ -0,0 +1,2 @@ +bauerb@chromium.org +gab@chromium.org diff --git a/chrome/browser/prefs/tracked/device_id.h b/components/user_prefs/tracked/device_id.h index 6ff57b8..2d6d1b8 100644 --- a/chrome/browser/prefs/tracked/device_id.h +++ b/components/user_prefs/tracked/device_id.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_PREFS_TRACKED_DEVICE_ID_H_ -#define CHROME_BROWSER_PREFS_TRACKED_DEVICE_ID_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_DEVICE_ID_H_ +#define COMPONENTS_USER_PREFS_TRACKED_DEVICE_ID_H_ #include <string> @@ -20,4 +20,4 @@ enum class MachineIdStatus { // cases |machine_id| is left untouched). MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id); -#endif // CHROME_BROWSER_PREFS_TRACKED_DEVICE_ID_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_DEVICE_ID_H_ diff --git a/chrome/browser/prefs/tracked/device_id_stub.cc b/components/user_prefs/tracked/device_id_stub.cc index 63449cc..07ffb94 100644 --- a/chrome/browser/prefs/tracked/device_id_stub.cc +++ b/components/user_prefs/tracked/device_id_stub.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/prefs/tracked/device_id.h" +#include "components/user_prefs/tracked/device_id.h" #include "base/logging.h" MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) { diff --git a/chrome/browser/prefs/tracked/device_id_unittest.cc b/components/user_prefs/tracked/device_id_unittest.cc index 1d213bd..6e1e3cd 100644 --- a/chrome/browser/prefs/tracked/device_id_unittest.cc +++ b/components/user_prefs/tracked/device_id_unittest.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/prefs/tracked/device_id.h" +#include "components/user_prefs/tracked/device_id.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/prefs/tracked/device_id_win.cc b/components/user_prefs/tracked/device_id_win.cc index 05e70b0..579d509 100644 --- a/chrome/browser/prefs/tracked/device_id_win.cc +++ b/components/user_prefs/tracked/device_id_win.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/prefs/tracked/device_id.h" +#include "components/user_prefs/tracked/device_id.h" #include <windows.h> #include <sddl.h> // For ConvertSidToStringSidA. diff --git a/chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc b/components/user_prefs/tracked/dictionary_hash_store_contents.cc index 567b9c8..ba79127 100644 --- a/chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc +++ b/components/user_prefs/tracked/dictionary_hash_store_contents.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/prefs/tracked/dictionary_hash_store_contents.h" +#include "components/user_prefs/tracked/dictionary_hash_store_contents.h" #include "base/callback.h" #include "base/logging.h" diff --git a/chrome/browser/prefs/tracked/dictionary_hash_store_contents.h b/components/user_prefs/tracked/dictionary_hash_store_contents.h index fc29db5..09178e7 100644 --- a/chrome/browser/prefs/tracked/dictionary_hash_store_contents.h +++ b/components/user_prefs/tracked/dictionary_hash_store_contents.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ -#define CHROME_BROWSER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ +#define COMPONENTS_USER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/hash_store_contents.h" namespace base { class DictionaryValue; @@ -45,4 +45,4 @@ class DictionaryHashStoreContents : public HashStoreContents { DISALLOW_COPY_AND_ASSIGN(DictionaryHashStoreContents); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_DICTIONARY_HASH_STORE_CONTENTS_H_ diff --git a/chrome/browser/prefs/tracked/hash_store_contents.h b/components/user_prefs/tracked/hash_store_contents.h index ff6e39a..94131ab 100644 --- a/chrome/browser/prefs/tracked/hash_store_contents.h +++ b/components/user_prefs/tracked/hash_store_contents.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_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ -#define CHROME_BROWSER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ +#define COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ #include <string> @@ -11,7 +11,7 @@ namespace base { class DictionaryValue; -} // namespace base +} // namespace base // Provides access to the contents of a preference hash store. The store // contains the following data: @@ -60,4 +60,4 @@ class HashStoreContents { virtual void SetSuperMac(const std::string& super_mac) = 0; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_ diff --git a/chrome/browser/prefs/tracked/interceptable_pref_filter.cc b/components/user_prefs/tracked/interceptable_pref_filter.cc index adc6116..180ee7e 100644 --- a/chrome/browser/prefs/tracked/interceptable_pref_filter.cc +++ b/components/user_prefs/tracked/interceptable_pref_filter.cc @@ -2,20 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/prefs/tracked/interceptable_pref_filter.h" +#include "components/user_prefs/tracked/interceptable_pref_filter.h" #include "base/bind.h" -InterceptablePrefFilter::InterceptablePrefFilter() {} -InterceptablePrefFilter::~InterceptablePrefFilter() {} +InterceptablePrefFilter::InterceptablePrefFilter() { +} +InterceptablePrefFilter::~InterceptablePrefFilter() { +} void InterceptablePrefFilter::FilterOnLoad( const PostFilterOnLoadCallback& post_filter_on_load_callback, scoped_ptr<base::DictionaryValue> pref_store_contents) { if (filter_on_load_interceptor_.is_null()) { FinalizeFilterOnLoad(post_filter_on_load_callback, - pref_store_contents.Pass(), - false); + pref_store_contents.Pass(), false); } else { // Note, in practice (in the implementation as it was in May 2014) it would // be okay to pass an unretained |this| pointer below, but in order to avoid @@ -23,8 +24,7 @@ void InterceptablePrefFilter::FilterOnLoad( // model as it happens to currently be: make the relationship simpler by // weakly binding the FinalizeFilterOnLoadCallback below to |this|. const FinalizeFilterOnLoadCallback finalize_filter_on_load( - base::Bind(&InterceptablePrefFilter::FinalizeFilterOnLoad, - AsWeakPtr(), + base::Bind(&InterceptablePrefFilter::FinalizeFilterOnLoad, AsWeakPtr(), post_filter_on_load_callback)); filter_on_load_interceptor_.Run(finalize_filter_on_load, pref_store_contents.Pass()); diff --git a/chrome/browser/prefs/tracked/interceptable_pref_filter.h b/components/user_prefs/tracked/interceptable_pref_filter.h index aacbfc7..58021df 100644 --- a/chrome/browser/prefs/tracked/interceptable_pref_filter.h +++ b/components/user_prefs/tracked/interceptable_pref_filter.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_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ -#define CHROME_BROWSER_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ +#define COMPONENTS_USER_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ #include "base/callback.h" #include "base/memory/weak_ptr.h" @@ -28,9 +28,9 @@ class InterceptablePrefFilter // A callback to be invoked from FilterOnLoad. It takes ownership of prefs // and may modify them before handing them back to this // InterceptablePrefFilter via |finalize_filter_on_load|. - typedef base::Callback< - void(const FinalizeFilterOnLoadCallback& finalize_filter_on_load, - scoped_ptr<base::DictionaryValue> prefs)> FilterOnLoadInterceptor; + typedef base::Callback<void( + const FinalizeFilterOnLoadCallback& finalize_filter_on_load, + scoped_ptr<base::DictionaryValue> prefs)> FilterOnLoadInterceptor; InterceptablePrefFilter(); ~InterceptablePrefFilter() override; @@ -61,4 +61,4 @@ class InterceptablePrefFilter FilterOnLoadInterceptor filter_on_load_interceptor_; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_INTERCEPTABLE_PREF_FILTER_H_ diff --git a/chrome/browser/prefs/tracked/mock_validation_delegate.cc b/components/user_prefs/tracked/mock_validation_delegate.cc index 3930a12..d2936af 100644 --- a/chrome/browser/prefs/tracked/mock_validation_delegate.cc +++ b/components/user_prefs/tracked/mock_validation_delegate.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/prefs/tracked/mock_validation_delegate.h" +#include "components/user_prefs/tracked/mock_validation_delegate.h" MockValidationDelegate::MockValidationDelegate() { } @@ -34,9 +34,7 @@ void MockValidationDelegate::OnAtomicPreferenceValidation( const base::Value* value, PrefHashStoreTransaction::ValueState value_state, bool is_personal) { - RecordValidation(pref_path, - value_state, - is_personal, + RecordValidation(pref_path, value_state, is_personal, PrefHashFilter::TRACKING_STRATEGY_ATOMIC); } @@ -46,9 +44,7 @@ void MockValidationDelegate::OnSplitPreferenceValidation( const std::vector<std::string>& invalid_keys, PrefHashStoreTransaction::ValueState value_state, bool is_personal) { - RecordValidation(pref_path, - value_state, - is_personal, + RecordValidation(pref_path, value_state, is_personal, PrefHashFilter::TRACKING_STRATEGY_SPLIT); } diff --git a/chrome/browser/prefs/tracked/mock_validation_delegate.h b/components/user_prefs/tracked/mock_validation_delegate.h index b5fc8a7..be2051e 100644 --- a/chrome/browser/prefs/tracked/mock_validation_delegate.h +++ b/components/user_prefs/tracked/mock_validation_delegate.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" // A mock tracked preference validation delegate for use by tests. class MockValidationDelegate : public TrackedPreferenceValidationDelegate { @@ -71,4 +71,4 @@ class MockValidationDelegate : public TrackedPreferenceValidationDelegate { DISALLOW_COPY_AND_ASSIGN(MockValidationDelegate); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_MOCK_VALIDATION_DELEGATE_H_ diff --git a/chrome/browser/prefs/tracked/pref_hash_calculator.cc b/components/user_prefs/tracked/pref_hash_calculator.cc index 323eb88..6034262 100644 --- a/chrome/browser/prefs/tracked/pref_hash_calculator.cc +++ b/components/user_prefs/tracked/pref_hash_calculator.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/prefs/tracked/pref_hash_calculator.h" +#include "components/user_prefs/tracked/pref_hash_calculator.h" #include <vector> @@ -35,11 +35,10 @@ bool VerifyDigestString(const std::string& key, const std::string& digest_string) { crypto::HMAC hmac(crypto::HMAC::SHA256); std::vector<uint8> digest; - return base::HexStringToBytes(digest_string, &digest) && - hmac.Init(key) && - hmac.Verify(message, - base::StringPiece(reinterpret_cast<char*>(&digest[0]), - digest.size())); + return base::HexStringToBytes(digest_string, &digest) && hmac.Init(key) && + hmac.Verify(message, + base::StringPiece(reinterpret_cast<char*>(&digest[0]), + digest.size())); } // Renders |value| as a string. |value| may be NULL, in which case the result @@ -96,9 +95,11 @@ PrefHashCalculator::PrefHashCalculator(const std::string& seed, const std::string& device_id) : seed_(seed), device_id_(device_id), - legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) {} + legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) { +} -PrefHashCalculator::~PrefHashCalculator() {} +PrefHashCalculator::~PrefHashCalculator() { +} std::string PrefHashCalculator::Calculate(const std::string& path, const base::Value* value) const { diff --git a/chrome/browser/prefs/tracked/pref_hash_calculator.h b/components/user_prefs/tracked/pref_hash_calculator.h index 3385541..593828e 100644 --- a/chrome/browser/prefs/tracked/pref_hash_calculator.h +++ b/components/user_prefs/tracked/pref_hash_calculator.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_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ #include <string> @@ -32,8 +32,8 @@ class PrefHashCalculator { // Calculates a hash value for the supplied preference |path| and |value|. // |value| may be null if the preference has no value. - std::string Calculate(const std::string& path, const base::Value* value) - const; + std::string Calculate(const std::string& path, + const base::Value* value) const; // Validates the provided preference hash using current and legacy hashing // algorithms. @@ -49,4 +49,4 @@ class PrefHashCalculator { DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_CALCULATOR_H_ diff --git a/chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc b/components/user_prefs/tracked/pref_hash_calculator_unittest.cc index 71f9a44..4fc1ff6 100644 --- a/chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc +++ b/components/user_prefs/tracked/pref_hash_calculator_unittest.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/prefs/tracked/pref_hash_calculator.h" +#include "components/user_prefs/tracked/pref_hash_calculator.h" #include <string> @@ -31,19 +31,15 @@ TEST(PrefHashCalculatorTest, TestCurrentAlgorithm) { ASSERT_EQ(calc1.Calculate("pref_path", &string_value_1), calc1_dup.Calculate("pref_path", &string_value_1)); ASSERT_EQ(PrefHashCalculator::VALID, - calc1_dup.Validate( - "pref_path", - &string_value_1, - calc1.Calculate("pref_path", &string_value_1))); + calc1_dup.Validate("pref_path", &string_value_1, + calc1.Calculate("pref_path", &string_value_1))); // Different seeds, different hashes. ASSERT_NE(calc1.Calculate("pref_path", &string_value_1), calc2.Calculate("pref_path", &string_value_1)); ASSERT_EQ(PrefHashCalculator::INVALID, - calc2.Validate( - "pref_path", - &string_value_1, - calc1.Calculate("pref_path", &string_value_1))); + calc2.Validate("pref_path", &string_value_1, + calc1.Calculate("pref_path", &string_value_1))); // Different device IDs, different hashes. ASSERT_NE(calc1.Calculate("pref_path", &string_value_1), @@ -92,8 +88,7 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { new base::DictionaryValue); nested_empty_dict->Set("a", new base::DictionaryValue); nested_empty_dict->Set("b", new base::ListValue); - scoped_ptr<base::ListValue> nested_empty_list( - new base::ListValue); + scoped_ptr<base::ListValue> nested_empty_list(new base::ListValue); nested_empty_list->Append(new base::DictionaryValue); nested_empty_list->Append(new base::ListValue); nested_empty_list->Append(nested_empty_dict->DeepCopy()); @@ -126,44 +121,47 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { static const char kExpectedNullValue[] = "82A9F3BBC7F9FF84C76B033C854E79EEB162783FA7B3E99FF9372FA8E12C44F7"; EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", null_value.get(), kExpectedNullValue)); + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", null_value.get(), kExpectedNullValue)); static const char kExpectedBooleanValue[] = "A520D8F43EA307B0063736DC9358C330539D0A29417580514C8B9862632C4CCC"; - EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", bool_value.get(), kExpectedBooleanValue)); + EXPECT_EQ( + PrefHashCalculator::VALID, + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", bool_value.get(), kExpectedBooleanValue)); static const char kExpectedIntegerValue[] = "8D60DA1F10BF5AA29819D2D66D7CCEF9AABC5DA93C11A0D2BD21078D63D83682"; EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", int_value.get(), kExpectedIntegerValue)); + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", int_value.get(), kExpectedIntegerValue)); static const char kExpectedDoubleValue[] = "C9D94772516125BEEDAE68C109D44BC529E719EE020614E894CC7FB4098C545D"; - EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", double_value.get(), kExpectedDoubleValue)); + EXPECT_EQ( + PrefHashCalculator::VALID, + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", double_value.get(), kExpectedDoubleValue)); static const char kExpectedStringValue[] = "05ACCBD3B05C45C36CD06190F63EC577112311929D8380E26E5F13182EB68318"; - EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", string_value.get(), kExpectedStringValue)); + EXPECT_EQ( + PrefHashCalculator::VALID, + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", string_value.get(), kExpectedStringValue)); static const char kExpectedDictValue[] = "7A84DCC710D796C771F789A4DA82C952095AA956B6F1667EE42D0A19ECAA3C4A"; EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", dict_value.get(), kExpectedDictValue)); + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", dict_value.get(), kExpectedDictValue)); static const char kExpectedListValue[] = "8D5A25972DF5AE20D041C780E7CA54E40F614AD53513A0724EE8D62D4F992740"; EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", list_value.get(), kExpectedListValue)); + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", list_value.get(), kExpectedListValue)); // Also test every value type together in the same dictionary. base::DictionaryValue everything; @@ -177,21 +175,18 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { static const char kExpectedEverythingValue[] = "B97D09BE7005693574DCBDD03D8D9E44FB51F4008B73FB56A49A9FA671A1999B"; EXPECT_EQ(PrefHashCalculator::VALID, - PrefHashCalculator(kSeed, kDeviceId).Validate( - "pref.path", &everything, kExpectedEverythingValue)); + PrefHashCalculator(kSeed, kDeviceId) + .Validate("pref.path", &everything, kExpectedEverythingValue)); } TEST(PrefHashCalculatorTest, TestCompatibilityWithLegacyPrefMetricsServiceId) { static const char kSeed[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F - }; + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, + 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; static const char kDeviceId[] = "D730D9CBD98C734A4FB097A1922275FE9F7E026A4EA1BE0E84"; static const char kExpectedValue[] = @@ -200,7 +195,8 @@ TEST(PrefHashCalculatorTest, TestCompatibilityWithLegacyPrefMetricsServiceId) { base::ListValue startup_urls; startup_urls.Set(0, new base::StringValue("http://www.chromium.org/")); - EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY, - PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId). - Validate("session.startup_urls", &startup_urls, kExpectedValue)); + EXPECT_EQ( + PrefHashCalculator::VALID_SECURE_LEGACY, + PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId) + .Validate("session.startup_urls", &startup_urls, kExpectedValue)); } diff --git a/chrome/browser/prefs/tracked/pref_hash_filter.cc b/components/user_prefs/tracked/pref_hash_filter.cc index 5fe4fa1..d3cd61d 100644 --- a/chrome/browser/prefs/tracked/pref_hash_filter.cc +++ b/components/user_prefs/tracked/pref_hash_filter.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/prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" #include <algorithm> @@ -13,13 +13,13 @@ #include "base/strings/string_number_conversions.h" #include "base/time/time.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/dictionary_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/tracked_atomic_preference.h" -#include "chrome/browser/prefs/tracked/tracked_split_preference.h" -#include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/user_prefs/tracked/dictionary_hash_store_contents.h" +#include "components/user_prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/pref_names.h" +#include "components/user_prefs/tracked/tracked_atomic_preference.h" +#include "components/user_prefs/tracked/tracked_split_preference.h" namespace { @@ -29,10 +29,10 @@ void CleanupDeprecatedTrackedPreferences( // Add deprecated previously tracked preferences below for them to be cleaned // up from both the pref files and the hash store. static const char* const kDeprecatedTrackedPreferences[] = { - // TODO(grt): Remove in M44+. - "safebrowsing.incident_report_sent", - // TODO(mad): Remove in M48+. - "software_reporter.prompt_reason", + // TODO(grt): Remove in M44+. + "safebrowsing.incident_report_sent", + // TODO(mad): Remove in M48+. + "software_reporter.prompt_reason", }; for (size_t i = 0; i < arraysize(kDeprecatedTrackedPreferences); ++i) { @@ -100,7 +100,7 @@ void PrefHashFilter::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { // See GetResetTime for why this is a StringPref and not Int64Pref. registry->RegisterStringPref( - prefs::kPreferenceResetTime, + user_prefs::kPreferenceResetTime, base::Int64ToString(base::Time().ToInternalValue())); } @@ -112,7 +112,7 @@ base::Time PrefHashFilter::GetResetTime(PrefService* user_prefs) { // PrefService::SetInt64). int64 internal_value = base::Time().ToInternalValue(); if (!base::StringToInt64( - user_prefs->GetString(prefs::kPreferenceResetTime), + user_prefs->GetString(user_prefs::kPreferenceResetTime), &internal_value)) { // Somehow the value stored on disk is not a valid int64. NOTREACHED(); @@ -123,7 +123,7 @@ base::Time PrefHashFilter::GetResetTime(PrefService* user_prefs) { // static void PrefHashFilter::ClearResetTime(PrefService* user_prefs) { - user_prefs->ClearPref(prefs::kPreferenceResetTime); + user_prefs->ClearPref(user_prefs::kPreferenceResetTime); } void PrefHashFilter::Initialize(base::DictionaryValue* pref_store_contents) { @@ -211,10 +211,10 @@ void PrefHashFilter::FinalizeFilterOnLoad( } if (did_reset) { - pref_store_contents->Set(prefs::kPreferenceResetTime, + pref_store_contents->Set(user_prefs::kPreferenceResetTime, new base::StringValue(base::Int64ToString( base::Time::Now().ToInternalValue()))); - FilterUpdate(prefs::kPreferenceResetTime); + FilterUpdate(user_prefs::kPreferenceResetTime); if (!on_reset_on_load_.is_null()) on_reset_on_load_.Run(); diff --git a/chrome/browser/prefs/tracked/pref_hash_filter.h b/components/user_prefs/tracked/pref_hash_filter.h index bad3ae0..5499569 100644 --- a/chrome/browser/prefs/tracked/pref_hash_filter.h +++ b/components/user_prefs/tracked/pref_hash_filter.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_PREFS_TRACKED_PREF_HASH_FILTER_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_FILTER_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_FILTER_H_ #include <map> #include <set> @@ -14,8 +14,8 @@ #include "base/compiler_specific.h" #include "base/containers/scoped_ptr_hash_map.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/prefs/tracked/interceptable_pref_filter.h" -#include "chrome/browser/prefs/tracked/tracked_preference.h" +#include "components/user_prefs/tracked/interceptable_pref_filter.h" +#include "components/user_prefs/tracked/tracked_preference.h" class PrefHashStore; class PrefService; @@ -37,10 +37,7 @@ class PrefRegistrySyncable; // are changed. class PrefHashFilter : public InterceptablePrefFilter { public: - enum EnforcementLevel { - NO_ENFORCEMENT, - ENFORCE_ON_LOAD - }; + enum EnforcementLevel { NO_ENFORCEMENT, ENFORCE_ON_LOAD }; enum PrefTrackingStrategy { // Atomic preferences are tracked as a whole. @@ -141,4 +138,4 @@ class PrefHashFilter : public InterceptablePrefFilter { DISALLOW_COPY_AND_ASSIGN(PrefHashFilter); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_FILTER_H_ +#endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_FILTER_H_ diff --git a/chrome/browser/prefs/tracked/pref_hash_filter_unittest.cc b/components/user_prefs/tracked/pref_hash_filter_unittest.cc index 9f56493..2d1f4d3 100644 --- a/chrome/browser/prefs/tracked/pref_hash_filter_unittest.cc +++ b/components/user_prefs/tracked/pref_hash_filter_unittest.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/prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" #include <map> #include <set> @@ -22,11 +22,11 @@ #include "base/metrics/statistics_recorder.h" #include "base/prefs/testing_pref_store.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" -#include "chrome/browser/prefs/tracked/mock_validation_delegate.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/common/pref_names.h" +#include "components/user_prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/mock_validation_delegate.h" +#include "components/user_prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -40,41 +40,41 @@ const char kReportOnlySplitPref[] = "report_only_split_pref"; const char kSplitPref[] = "split_pref"; const PrefHashFilter::TrackedPreferenceMetadata kTestTrackedPrefs[] = { - { - 0, kAtomicPref, PrefHashFilter::ENFORCE_ON_LOAD, - PrefHashFilter::TRACKING_STRATEGY_ATOMIC, - PrefHashFilter::VALUE_PERSONAL - }, - { - 1, kReportOnlyPref, PrefHashFilter::NO_ENFORCEMENT, - PrefHashFilter::TRACKING_STRATEGY_ATOMIC, - PrefHashFilter::VALUE_IMPERSONAL - }, - { - 2, kSplitPref, PrefHashFilter::ENFORCE_ON_LOAD, - PrefHashFilter::TRACKING_STRATEGY_SPLIT, - PrefHashFilter::VALUE_IMPERSONAL - }, - { - 3, kReportOnlySplitPref, PrefHashFilter::NO_ENFORCEMENT, - PrefHashFilter::TRACKING_STRATEGY_SPLIT, - PrefHashFilter::VALUE_IMPERSONAL - }, - { - 4, kAtomicPref2, PrefHashFilter::ENFORCE_ON_LOAD, - PrefHashFilter::TRACKING_STRATEGY_ATOMIC, - PrefHashFilter::VALUE_IMPERSONAL - }, - { - 5, kAtomicPref3, PrefHashFilter::ENFORCE_ON_LOAD, - PrefHashFilter::TRACKING_STRATEGY_ATOMIC, - PrefHashFilter::VALUE_IMPERSONAL - }, - { - 6, kAtomicPref4, PrefHashFilter::ENFORCE_ON_LOAD, - PrefHashFilter::TRACKING_STRATEGY_ATOMIC, - PrefHashFilter::VALUE_IMPERSONAL - }, + {0, + kAtomicPref, + PrefHashFilter::ENFORCE_ON_LOAD, + PrefHashFilter::TRACKING_STRATEGY_ATOMIC, + PrefHashFilter::VALUE_PERSONAL}, + {1, + kReportOnlyPref, + PrefHashFilter::NO_ENFORCEMENT, + PrefHashFilter::TRACKING_STRATEGY_ATOMIC, + PrefHashFilter::VALUE_IMPERSONAL}, + {2, + kSplitPref, + PrefHashFilter::ENFORCE_ON_LOAD, + PrefHashFilter::TRACKING_STRATEGY_SPLIT, + PrefHashFilter::VALUE_IMPERSONAL}, + {3, + kReportOnlySplitPref, + PrefHashFilter::NO_ENFORCEMENT, + PrefHashFilter::TRACKING_STRATEGY_SPLIT, + PrefHashFilter::VALUE_IMPERSONAL}, + {4, + kAtomicPref2, + PrefHashFilter::ENFORCE_ON_LOAD, + PrefHashFilter::TRACKING_STRATEGY_ATOMIC, + PrefHashFilter::VALUE_IMPERSONAL}, + {5, + kAtomicPref3, + PrefHashFilter::ENFORCE_ON_LOAD, + PrefHashFilter::TRACKING_STRATEGY_ATOMIC, + PrefHashFilter::VALUE_IMPERSONAL}, + {6, + kAtomicPref4, + PrefHashFilter::ENFORCE_ON_LOAD, + PrefHashFilter::TRACKING_STRATEGY_ATOMIC, + PrefHashFilter::VALUE_IMPERSONAL}, }; } // namespace @@ -122,14 +122,10 @@ class MockPrefHashStore : public PrefHashStore { size_t transactions_performed() { return transactions_performed_; } // Returns the number of paths checked. - size_t checked_paths_count() const { - return checked_values_.size(); - } + size_t checked_paths_count() const { return checked_values_.size(); } // Returns the number of paths stored. - size_t stored_paths_count() const { - return stored_values_.size(); - } + size_t stored_paths_count() const { return stored_values_.size(); } // Returns the pointer value and strategy that was passed to // |CheckHash/CheckSplitHash| for |path|. The returned pointer could since @@ -140,8 +136,8 @@ class MockPrefHashStore : public PrefHashStore { if (value != checked_values_.end()) return value->second; return std::make_pair( - reinterpret_cast<void*>(0xBAD), - static_cast<PrefHashFilter::PrefTrackingStrategy>(-1)); + reinterpret_cast<void*>(0xBAD), + static_cast<PrefHashFilter::PrefTrackingStrategy>(-1)); } // Returns the pointer value that was passed to |StoreHash/StoreSplitHash| for @@ -153,8 +149,8 @@ class MockPrefHashStore : public PrefHashStore { if (value != stored_values_.end()) return value->second; return std::make_pair( - reinterpret_cast<void*>(0xBAD), - static_cast<PrefHashFilter::PrefTrackingStrategy>(-1)); + reinterpret_cast<void*>(0xBAD), + static_cast<PrefHashFilter::PrefTrackingStrategy>(-1)); } // PrefHashStore implementation. @@ -212,7 +208,7 @@ class MockPrefHashStore : public PrefHashStore { PrefHashFilter::PrefTrackingStrategy strategy); std::map<std::string, PrefHashStoreTransaction::ValueState> check_results_; - std::map<std::string, std::vector<std::string> > invalid_keys_results_; + std::map<std::string, std::vector<std::string>> invalid_keys_results_; bool stamp_super_mac_result_; bool is_super_mac_valid_result_; @@ -231,7 +227,8 @@ class MockPrefHashStore : public PrefHashStore { }; void MockPrefHashStore::SetCheckResult( - const std::string& path, PrefHashStoreTransaction::ValueState result) { + const std::string& path, + PrefHashStoreTransaction::ValueState result) { check_results_.insert(std::make_pair(path, result)); } @@ -239,9 +236,8 @@ void MockPrefHashStore::SetInvalidKeysResult( const std::string& path, const std::vector<std::string>& invalid_keys_result) { // Ensure |check_results_| has a CHANGED entry for |path|. - std::map<std::string, - PrefHashStoreTransaction::ValueState>::const_iterator result = - check_results_.find(path); + std::map<std::string, PrefHashStoreTransaction::ValueState>::const_iterator + result = check_results_.find(path); ASSERT_TRUE(result != check_results_.end()); ASSERT_EQ(PrefHashStoreTransaction::CHANGED, result->second); @@ -261,11 +257,11 @@ PrefHashStoreTransaction::ValueState MockPrefHashStore::RecordCheckValue( PrefHashFilter::PrefTrackingStrategy strategy) { // Record that |path| was checked and validate that it wasn't previously // checked. - EXPECT_TRUE(checked_values_.insert( - std::make_pair(path, std::make_pair(value, strategy))).second); - std::map<std::string, - PrefHashStoreTransaction::ValueState>::const_iterator result = - check_results_.find(path); + EXPECT_TRUE(checked_values_.insert(std::make_pair( + path, std::make_pair(value, strategy))) + .second); + std::map<std::string, PrefHashStoreTransaction::ValueState>::const_iterator + result = check_results_.find(path); if (result != check_results_.end()) return result->second; return PrefHashStoreTransaction::UNCHANGED; @@ -275,13 +271,16 @@ void MockPrefHashStore::RecordStoreHash( const std::string& path, const base::Value* new_value, PrefHashFilter::PrefTrackingStrategy strategy) { - EXPECT_TRUE(stored_values_.insert( - std::make_pair(path, std::make_pair(new_value, strategy))).second); + EXPECT_TRUE( + stored_values_.insert(std::make_pair(path, + std::make_pair(new_value, strategy))) + .second); } PrefHashStoreTransaction::ValueState MockPrefHashStore::MockPrefHashStoreTransaction::CheckValue( - const std::string& path, const base::Value* value) const { + const std::string& path, + const base::Value* value) const { return outer_->RecordCheckValue(path, value, PrefHashFilter::TRACKING_STRATEGY_ATOMIC); } @@ -300,7 +299,7 @@ MockPrefHashStore::MockPrefHashStoreTransaction::CheckSplitValue( std::vector<std::string>* invalid_keys) const { EXPECT_TRUE(invalid_keys && invalid_keys->empty()); - std::map<std::string, std::vector<std::string> >::const_iterator + std::map<std::string, std::vector<std::string>>::const_iterator invalid_keys_result = outer_->invalid_keys_results_.find(path); if (invalid_keys_result != outer_->invalid_keys_results_.end()) { invalid_keys->insert(invalid_keys->begin(), @@ -320,19 +319,19 @@ void MockPrefHashStore::MockPrefHashStoreTransaction::StoreSplitHash( } bool MockPrefHashStore::MockPrefHashStoreTransaction::HasHash( - const std::string& path) const { + const std::string& path) const { ADD_FAILURE() << "Unexpected call."; return false; } void MockPrefHashStore::MockPrefHashStoreTransaction::ImportHash( const std::string& path, - const base::Value* hash) { + const base::Value* hash) { ADD_FAILURE() << "Unexpected call."; } void MockPrefHashStore::MockPrefHashStoreTransaction::ClearHash( - const std::string& path) { + const std::string& path) { // Allow this to be called by PrefHashFilter's deprecated tracked prefs // cleanup tasks. } @@ -351,8 +350,7 @@ std::vector<PrefHashFilter::TrackedPreferenceMetadata> GetConfiguration( kTestTrackedPrefs, kTestTrackedPrefs + arraysize(kTestTrackedPrefs)); for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it = configuration.begin(); - it != configuration.end(); - ++it) { + it != configuration.end(); ++it) { if (it->enforcement_level > max_enforcement_level) it->enforcement_level = max_enforcement_level; } @@ -362,9 +360,10 @@ std::vector<PrefHashFilter::TrackedPreferenceMetadata> GetConfiguration( class PrefHashFilterTest : public testing::TestWithParam<PrefHashFilter::EnforcementLevel> { public: - PrefHashFilterTest() : mock_pref_hash_store_(NULL), - pref_store_contents_(new base::DictionaryValue), - reset_recorded_(false) {} + PrefHashFilterTest() + : mock_pref_hash_store_(NULL), + pref_store_contents_(new base::DictionaryValue), + reset_recorded_(false) {} void SetUp() override { base::StatisticsRecorder::Initialize(); @@ -387,12 +386,9 @@ class PrefHashFilterTest new MockPrefHashStore); mock_pref_hash_store_ = temp_mock_pref_hash_store.get(); pref_hash_filter_.reset(new PrefHashFilter( - temp_mock_pref_hash_store.Pass(), - configuration, + temp_mock_pref_hash_store.Pass(), configuration, base::Bind(&PrefHashFilterTest::RecordReset, base::Unretained(this)), - &mock_validation_delegate_, - arraysize(kTestTrackedPrefs), - true)); + &mock_validation_delegate_, arraysize(kTestTrackedPrefs), true)); } // Verifies whether a reset was reported by the PrefHashFiler. Also verifies @@ -400,7 +396,8 @@ class PrefHashFilterTest void VerifyRecordedReset(bool reset_expected) { EXPECT_EQ(reset_expected, reset_recorded_); EXPECT_EQ(reset_expected, - pref_store_contents_->Get(prefs::kPreferenceResetTime, NULL)); + pref_store_contents_->Get( + user_prefs::kPreferenceResetTime, NULL)); } // Calls FilterOnLoad() on |pref_hash_Filter_|. |pref_store_contents_| is @@ -452,8 +449,9 @@ TEST_P(PrefHashFilterTest, EmptyAndUnchanged) { // Since there was nothing in |pref_store_contents_| the checked value should // have been NULL for all tracked preferences. for (size_t i = 0; i < arraysize(kTestTrackedPrefs); ++i) { - ASSERT_EQ(NULL, mock_pref_hash_store_->checked_value( - kTestTrackedPrefs[i].name).first); + ASSERT_EQ( + NULL, + mock_pref_hash_store_->checked_value(kTestTrackedPrefs[i].name).first); } ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); VerifyRecordedReset(false); @@ -548,7 +546,7 @@ TEST_P(PrefHashFilterTest, FilterSplitPrefUpdate) { pref_hash_filter_->FilterSerializeData(&root_dict); ASSERT_EQ(1u, mock_pref_hash_store_->stored_paths_count()); MockPrefHashStore::ValuePtrStrategyPair stored_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(dict_value, stored_value.first); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value.second); @@ -617,7 +615,7 @@ TEST_P(PrefHashFilterTest, MultiplePrefsFilterSerializeData) { stored_value_atomic3.second); MockPrefHashStore::ValuePtrStrategyPair stored_value_split = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(dict_value, stored_value_split.first); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value_split.second); } @@ -637,23 +635,21 @@ TEST_P(PrefHashFilterTest, UnknownNullValue) { ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); ASSERT_EQ(NULL, stored_atomic_value.first); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(NULL, stored_split_value.first); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); // Delegate saw all prefs, two of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(2u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::TRUSTED_NULL_VALUE)); + ASSERT_EQ(2u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::TRUSTED_NULL_VALUE)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); @@ -697,21 +693,19 @@ TEST_P(PrefHashFilterTest, InitialValueUnknown) { // Delegate saw all prefs, two of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(2u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE)); + ASSERT_EQ(2u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); if (GetParam() == PrefHashFilter::ENFORCE_ON_LOAD) { // Ensure the prefs were cleared and the hashes for NULL were restored if // the current enforcement level denies seeding. @@ -765,9 +759,8 @@ TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { // Delegate saw all prefs, two of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(2u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE)); + ASSERT_EQ(2u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); @@ -777,7 +770,7 @@ TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { ASSERT_TRUE(pref_store_contents_->Get(kAtomicPref, &atomic_value_in_store)); ASSERT_EQ(string_value, atomic_value_in_store); MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); ASSERT_EQ(string_value, stored_atomic_value.first); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); @@ -786,10 +779,9 @@ TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, &split_value_in_store)); ASSERT_EQ(dict_value, split_value_in_store); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(dict_value, stored_split_value.first); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); } TEST_P(PrefHashFilterTest, InitialValueChanged) { @@ -824,13 +816,12 @@ TEST_P(PrefHashFilterTest, InitialValueChanged) { ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); if (GetParam() == PrefHashFilter::ENFORCE_ON_LOAD) { // Ensure the atomic pref was cleared and the hash for NULL was restored if // the current enforcement level prevents changes. @@ -887,9 +878,8 @@ TEST_P(PrefHashFilterTest, EmptyCleared) { // Delegate saw all prefs, two of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(2u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::CLEARED)); + ASSERT_EQ(2u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::CLEARED)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); @@ -898,17 +888,16 @@ TEST_P(PrefHashFilterTest, EmptyCleared) { // to restore the hash for NULL. The value itself should still be NULL. ASSERT_FALSE(pref_store_contents_->Get(kAtomicPref, NULL)); MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); ASSERT_EQ(NULL, stored_atomic_value.first); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); ASSERT_FALSE(pref_store_contents_->Get(kSplitPref, NULL)); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); + mock_pref_hash_store_->stored_value(kSplitPref); ASSERT_EQ(NULL, stored_split_value.first); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); } TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { @@ -936,9 +925,8 @@ TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { // Delegate saw all prefs, two of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(2u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::SECURE_LEGACY)); + ASSERT_EQ(2u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::SECURE_LEGACY)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); @@ -950,7 +938,7 @@ TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { // have been updated to match them. MockPrefHashStore::ValuePtrStrategyPair stored_atomic_value = - mock_pref_hash_store_->stored_value(kAtomicPref); + mock_pref_hash_store_->stored_value(kAtomicPref); ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_atomic_value.second); const base::Value* atomic_value_in_store; @@ -959,9 +947,8 @@ TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { ASSERT_EQ(string_value, stored_atomic_value.first); MockPrefHashStore::ValuePtrStrategyPair stored_split_value = - mock_pref_hash_store_->stored_value(kSplitPref); - ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, - stored_split_value.second); + mock_pref_hash_store_->stored_value(kSplitPref); + ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_split_value.second); const base::Value* split_value_in_store; ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, &split_value_in_store)); ASSERT_EQ(dict_value, split_value_in_store); @@ -1007,9 +994,8 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) { // Delegate saw all prefs, four of which had the expected value_state. ASSERT_EQ(arraysize(kTestTrackedPrefs), mock_validation_delegate_.recorded_validations_count()); - ASSERT_EQ(4u, - mock_validation_delegate_.CountValidationsOfState( - PrefHashStoreTransaction::CHANGED)); + ASSERT_EQ(4u, mock_validation_delegate_.CountValidationsOfState( + PrefHashStoreTransaction::CHANGED)); ASSERT_EQ(arraysize(kTestTrackedPrefs) - 4u, mock_validation_delegate_.CountValidationsOfState( PrefHashStoreTransaction::UNCHANGED)); @@ -1047,7 +1033,7 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) { } } -INSTANTIATE_TEST_CASE_P( - PrefHashFilterTestInstance, PrefHashFilterTest, - testing::Values(PrefHashFilter::NO_ENFORCEMENT, - PrefHashFilter::ENFORCE_ON_LOAD)); +INSTANTIATE_TEST_CASE_P(PrefHashFilterTestInstance, + PrefHashFilterTest, + testing::Values(PrefHashFilter::NO_ENFORCEMENT, + PrefHashFilter::ENFORCE_ON_LOAD)); diff --git a/chrome/browser/prefs/tracked/pref_hash_store.h b/components/user_prefs/tracked/pref_hash_store.h index e3f5d8d..9ab0f48 100644 --- a/chrome/browser/prefs/tracked/pref_hash_store.h +++ b/components/user_prefs/tracked/pref_hash_store.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_PREFS_TRACKED_PREF_HASH_STORE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_H_ +#ifndef COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ +#define COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ #include "base/memory/scoped_ptr.h" @@ -25,4 +25,4 @@ class PrefHashStore { scoped_ptr<HashStoreContents> storage) = 0; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_H_ +#endif // COMPONENTS_PREFS_TRACKED_PREF_HASH_STORE_H_ diff --git a/chrome/browser/prefs/tracked/pref_hash_store_impl.cc b/components/user_prefs/tracked/pref_hash_store_impl.cc index f43e06b1..dd86222 100644 --- a/chrome/browser/prefs/tracked/pref_hash_store_impl.cc +++ b/components/user_prefs/tracked/pref_hash_store_impl.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/prefs/tracked/pref_hash_store_impl.h" +#include "components/user_prefs/tracked/pref_hash_store_impl.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" class PrefHashStoreImpl::PrefHashStoreTransactionImpl : public PrefHashStoreTransaction { @@ -63,8 +63,7 @@ class PrefHashStoreImpl::PrefHashStoreTransactionImpl PrefHashStoreImpl::PrefHashStoreImpl(const std::string& seed, const std::string& device_id, bool use_super_mac) - : pref_hash_calculator_(seed, device_id), - use_super_mac_(use_super_mac) { + : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { } PrefHashStoreImpl::~PrefHashStoreImpl() { @@ -101,10 +100,9 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::PrefHashStoreTransactionImpl( if (super_mac.empty()) return; - super_mac_valid_ = - outer_->pref_hash_calculator_.Validate( - contents()->hash_store_id(), store_contents, super_mac) == - PrefHashCalculator::VALID; + super_mac_valid_ = outer_->pref_hash_calculator_.Validate( + contents()->hash_store_id(), store_contents, + super_mac) == PrefHashCalculator::VALID; } PrefHashStoreImpl::PrefHashStoreTransactionImpl:: @@ -195,8 +193,8 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( // Keep the common part from the old |keyed_path| and replace the key to // get the new |keyed_path|. keyed_path.replace(common_part_length, std::string::npos, it.key()); - switch (outer_->pref_hash_calculator_.Validate( - keyed_path, &it.value(), entry->second)) { + switch (outer_->pref_hash_calculator_.Validate(keyed_path, &it.value(), + entry->second)) { case PrefHashCalculator::VALID: break; case SECURE_LEGACY: @@ -218,8 +216,7 @@ PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckSplitValue( // Anything left in the map is missing from the data. for (std::map<std::string, std::string>::const_iterator it = split_macs.begin(); - it != split_macs.end(); - ++it) { + it != split_macs.end(); ++it) { invalid_keys->push_back(it->first); } @@ -244,9 +241,9 @@ void PrefHashStoreImpl::PrefHashStoreTransactionImpl::StoreSplitHash( // Keep the common part from the old |keyed_path| and replace the key to // get the new |keyed_path|. keyed_path.replace(common_part_length, std::string::npos, it.key()); - (*mutable_dictionary)->SetString( - keyed_path, - outer_->pref_hash_calculator_.Calculate(keyed_path, &it.value())); + (*mutable_dictionary) + ->SetString(keyed_path, outer_->pref_hash_calculator_.Calculate( + keyed_path, &it.value())); } } super_mac_dirty_ = true; diff --git a/chrome/browser/prefs/tracked/pref_hash_store_impl.h b/components/user_prefs/tracked/pref_hash_store_impl.h index ccef877..9744200 100644 --- a/chrome/browser/prefs/tracked/pref_hash_store_impl.h +++ b/components/user_prefs/tracked/pref_hash_store_impl.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ #include <string> #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/prefs/tracked/pref_hash_calculator.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_calculator.h" +#include "components/user_prefs/tracked/pref_hash_store.h" class HashStoreContents; class PrefHashStoreTransaction; @@ -64,4 +64,4 @@ class PrefHashStoreImpl : public PrefHashStore { DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImpl); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_IMPL_H_ diff --git a/chrome/browser/prefs/tracked/pref_hash_store_impl_unittest.cc b/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc index 94b2652..8ec8ffa 100644 --- a/chrome/browser/prefs/tracked/pref_hash_store_impl_unittest.cc +++ b/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/prefs/tracked/pref_hash_store_impl.h" +#include "components/user_prefs/tracked/pref_hash_store_impl.h" #include <string> #include "base/macros.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/dictionary_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_impl.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/dictionary_hash_store_contents.h" +#include "components/user_prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/pref_hash_store_impl.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" #include "testing/gtest/include/gtest/gtest.h" class PrefHashStoreImplTest : public testing::Test { @@ -352,7 +352,6 @@ TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { expected_invalid_keys2.push_back("c"); EXPECT_EQ(expected_invalid_keys2, invalid_keys); invalid_keys.clear(); - } { diff --git a/chrome/browser/prefs/tracked/pref_hash_store_transaction.h b/components/user_prefs/tracked/pref_hash_store_transaction.h index 62cd602..b8e2cf7 100644 --- a/chrome/browser/prefs/tracked/pref_hash_store_transaction.h +++ b/components/user_prefs/tracked/pref_hash_store_transaction.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_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ #include <string> #include <vector> @@ -42,12 +42,11 @@ class PrefHashStoreTransaction { virtual ~PrefHashStoreTransaction() {} // Checks |initial_value| against the existing stored value hash. - virtual ValueState CheckValue( - const std::string& path, const base::Value* initial_value) const = 0; + virtual ValueState CheckValue(const std::string& path, + const base::Value* initial_value) const = 0; // Stores a hash of the current |value| of the preference at |path|. - virtual void StoreHash(const std::string& path, - const base::Value* value) = 0; + virtual void StoreHash(const std::string& path, const base::Value* value) = 0; // Checks |initial_value| against the existing stored hashes for the split // preference at |path|. |initial_split_value| being an empty dictionary or @@ -62,9 +61,8 @@ class PrefHashStoreTransaction { // Stores hashes for the |value| of the split preference at |path|. // |split_value| being an empty dictionary or NULL is equivalent. - virtual void StoreSplitHash( - const std::string& path, - const base::DictionaryValue* split_value) = 0; + virtual void StoreSplitHash(const std::string& path, + const base::DictionaryValue* split_value) = 0; // Indicates whether the store contains a hash for the preference at |path|. virtual bool HasHash(const std::string& path) const = 0; @@ -93,4 +91,4 @@ class PrefHashStoreTransaction { virtual bool StampSuperMac() = 0; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_PREF_HASH_STORE_TRANSACTION_H_ diff --git a/components/user_prefs/tracked/pref_names.cc b/components/user_prefs/tracked/pref_names.cc new file mode 100644 index 0000000..a6c73a6 --- /dev/null +++ b/components/user_prefs/tracked/pref_names.cc @@ -0,0 +1,13 @@ +// Copyright 2015 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/user_prefs/tracked/pref_names.h" + +namespace user_prefs { + +// A timestamp (stored in base::Time::ToInternalValue format) of the last time +// a preference was reset. +const char kPreferenceResetTime[] = "prefs.preference_reset_time"; + +} // namespace user_prefs diff --git a/components/user_prefs/tracked/pref_names.h b/components/user_prefs/tracked/pref_names.h new file mode 100644 index 0000000..80aa6bf --- /dev/null +++ b/components/user_prefs/tracked/pref_names.h @@ -0,0 +1,14 @@ +// Copyright 2015 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. + +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_NAMES_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_NAMES_H_ + +namespace user_prefs { + +extern const char kPreferenceResetTime[]; + +} // namespace user_prefs + +#endif // COMPONENTS_USER_PREFS_TRACKED_PREF_NAMES_H_ diff --git a/chrome/browser/prefs/tracked/pref_service_hash_store_contents.cc b/components/user_prefs/tracked/pref_service_hash_store_contents.cc index 9ab446f..122fa47 100644 --- a/chrome/browser/prefs/tracked/pref_service_hash_store_contents.cc +++ b/components/user_prefs/tracked/pref_service_hash_store_contents.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/prefs/tracked/pref_service_hash_store_contents.h" +#include "components/user_prefs/tracked/pref_service_hash_store_contents.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" diff --git a/chrome/browser/prefs/tracked/pref_service_hash_store_contents.h b/components/user_prefs/tracked/pref_service_hash_store_contents.h index 5bb6c95..2b944e5 100644 --- a/chrome/browser/prefs/tracked/pref_service_hash_store_contents.h +++ b/components/user_prefs/tracked/pref_service_hash_store_contents.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ -#define CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ +#define COMPONENTS_USER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ #include <string> #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/hash_store_contents.h" class PrefRegistrySimple; class PrefService; @@ -69,4 +69,4 @@ class PrefServiceHashStoreContents : public HashStoreContents { DISALLOW_COPY_AND_ASSIGN(PrefServiceHashStoreContents); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ +#endif // COMPONENTS_PREFS_TRACKED_PREF_SERVICE_HASH_STORE_CONTENTS_H_ diff --git a/chrome/browser/prefs/tracked/pref_service_hash_store_contents_unittest.cc b/components/user_prefs/tracked/pref_service_hash_store_contents_unittest.cc index cf7f879..09003d9 100644 --- a/chrome/browser/prefs/tracked/pref_service_hash_store_contents_unittest.cc +++ b/components/user_prefs/tracked/pref_service_hash_store_contents_unittest.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/prefs/tracked/pref_service_hash_store_contents.h" +#include "components/user_prefs/tracked/pref_service_hash_store_contents.h" #include <string> diff --git a/chrome/browser/prefs/tracked/segregated_pref_store.cc b/components/user_prefs/tracked/segregated_pref_store.cc index f83fc22..99031a2 100644 --- a/chrome/browser/prefs/tracked/segregated_pref_store.cc +++ b/components/user_prefs/tracked/segregated_pref_store.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/prefs/tracked/segregated_pref_store.h" +#include "components/user_prefs/tracked/segregated_pref_store.h" #include "base/logging.h" #include "base/stl_util.h" @@ -12,7 +12,8 @@ SegregatedPrefStore::AggregatingObserver::AggregatingObserver( SegregatedPrefStore* outer) : outer_(outer), failed_sub_initializations_(0), - successful_sub_initializations_(0) {} + successful_sub_initializations_(0) { +} void SegregatedPrefStore::AggregatingObserver::OnPrefValueChanged( const std::string& key) { @@ -21,8 +22,8 @@ void SegregatedPrefStore::AggregatingObserver::OnPrefValueChanged( if (failed_sub_initializations_ + successful_sub_initializations_ < 2) return; - FOR_EACH_OBSERVER( - PrefStore::Observer, outer_->observers_, OnPrefValueChanged(key)); + FOR_EACH_OBSERVER(PrefStore::Observer, outer_->observers_, + OnPrefValueChanged(key)); } void SegregatedPrefStore::AggregatingObserver::OnInitializationCompleted( @@ -42,8 +43,7 @@ void SegregatedPrefStore::AggregatingObserver::OnInitializationCompleted( } FOR_EACH_OBSERVER( - PrefStore::Observer, - outer_->observers_, + PrefStore::Observer, outer_->observers_, OnInitializationCompleted(successful_sub_initializations_ == 2)); } } @@ -109,8 +109,7 @@ void SegregatedPrefStore::SetValueSilently(const std::string& key, } bool SegregatedPrefStore::ReadOnly() const { - return selected_pref_store_->ReadOnly() || - default_pref_store_->ReadOnly(); + return selected_pref_store_->ReadOnly() || default_pref_store_->ReadOnly(); } PersistentPrefStore::PrefReadError SegregatedPrefStore::GetReadError() const { diff --git a/chrome/browser/prefs/tracked/segregated_pref_store.h b/components/user_prefs/tracked/segregated_pref_store.h index 10e529f..d2bf013 100644 --- a/chrome/browser/prefs/tracked/segregated_pref_store.h +++ b/components/user_prefs/tracked/segregated_pref_store.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_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ #include <set> #include <string> @@ -107,4 +107,4 @@ class SegregatedPrefStore : public PersistentPrefStore { DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ +#endif // COMPONENTS_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ diff --git a/chrome/browser/prefs/tracked/segregated_pref_store_unittest.cc b/components/user_prefs/tracked/segregated_pref_store_unittest.cc index 04e0708..dc458a5 100644 --- a/chrome/browser/prefs/tracked/segregated_pref_store_unittest.cc +++ b/components/user_prefs/tracked/segregated_pref_store_unittest.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/prefs/tracked/segregated_pref_store.h" +#include "components/user_prefs/tracked/segregated_pref_store.h" #include <set> #include <string> @@ -15,7 +15,7 @@ #include "base/prefs/pref_store_observer_mock.h" #include "base/prefs/testing_pref_store.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/segregated_pref_store.h" +#include "components/user_prefs/tracked/segregated_pref_store.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -69,10 +69,8 @@ class SegregatedPrefStoreTest : public testing::Test { std::set<std::string> selected_pref_names; selected_pref_names.insert(kSelectedPref); - segregated_store_ = new SegregatedPrefStore( - default_store_, - selected_store_, - selected_pref_names); + segregated_store_ = new SegregatedPrefStore(default_store_, selected_store_, + selected_pref_names); segregated_store_->AddObserver(&observer_); } @@ -168,8 +166,7 @@ TEST_F(SegregatedPrefStoreTest, Observer) { TEST_F(SegregatedPrefStoreTest, SelectedPrefReadNoFileError) { // PREF_READ_ERROR_NO_FILE for the selected prefs file is silently converted // to PREF_READ_ERROR_NONE. - selected_store_->set_read_error( - PersistentPrefStore::PREF_READ_ERROR_NO_FILE); + selected_store_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, segregated_store_->ReadPrefs()); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, @@ -188,8 +185,7 @@ TEST_F(SegregatedPrefStoreTest, SelectedPrefReadError) { TEST_F(SegregatedPrefStoreTest, SelectedPrefReadNoFileErrorAsync) { // PREF_READ_ERROR_NO_FILE for the selected prefs file is silently converted // to PREF_READ_ERROR_NONE. - selected_store_->set_read_error( - PersistentPrefStore::PREF_READ_ERROR_NO_FILE); + selected_store_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); default_store_->SetBlockAsyncRead(true); @@ -210,8 +206,7 @@ TEST_F(SegregatedPrefStoreTest, SelectedPrefReadNoFileErrorAsync) { } TEST_F(SegregatedPrefStoreTest, UnselectedPrefReadNoFileError) { - default_store_->set_read_error( - PersistentPrefStore::PREF_READ_ERROR_NO_FILE); + default_store_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, segregated_store_->ReadPrefs()); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, @@ -228,8 +223,7 @@ TEST_F(SegregatedPrefStoreTest, UnselectedPrefReadError) { } TEST_F(SegregatedPrefStoreTest, BothPrefReadError) { - default_store_->set_read_error( - PersistentPrefStore::PREF_READ_ERROR_NO_FILE); + default_store_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); selected_store_->set_read_error( PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED); EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, @@ -239,8 +233,7 @@ TEST_F(SegregatedPrefStoreTest, BothPrefReadError) { } TEST_F(SegregatedPrefStoreTest, BothPrefReadErrorAsync) { - default_store_->set_read_error( - PersistentPrefStore::PREF_READ_ERROR_NO_FILE); + default_store_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); selected_store_->set_read_error( PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED); diff --git a/chrome/browser/prefs/tracked/tracked_atomic_preference.cc b/components/user_prefs/tracked/tracked_atomic_preference.cc index 1930659..4eb4b61 100644 --- a/chrome/browser/prefs/tracked/tracked_atomic_preference.cc +++ b/components/user_prefs/tracked/tracked_atomic_preference.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/prefs/tracked/tracked_atomic_preference.h" +#include "components/user_prefs/tracked/tracked_atomic_preference.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" TrackedAtomicPreference::TrackedAtomicPreference( const std::string& pref_path, @@ -16,7 +16,10 @@ TrackedAtomicPreference::TrackedAtomicPreference( PrefHashFilter::ValueType value_type, TrackedPreferenceValidationDelegate* delegate) : pref_path_(pref_path), - helper_(pref_path, reporting_id, reporting_ids_count, enforcement_level, + helper_(pref_path, + reporting_id, + reporting_ids_count, + enforcement_level, value_type), delegate_(delegate) { } @@ -40,8 +43,8 @@ bool TrackedAtomicPreference::EnforceAndReport( TrackedPreferenceHelper::ResetAction reset_action = helper_.GetAction(value_state); if (delegate_) { - delegate_->OnAtomicPreferenceValidation( - pref_path_, value, value_state, helper_.IsPersonal()); + delegate_->OnAtomicPreferenceValidation(pref_path_, value, value_state, + helper_.IsPersonal()); } helper_.ReportAction(reset_action); diff --git a/chrome/browser/prefs/tracked/tracked_atomic_preference.h b/components/user_prefs/tracked/tracked_atomic_preference.h index 4c27b06..3e183cf 100644 --- a/chrome/browser/prefs/tracked/tracked_atomic_preference.h +++ b/components/user_prefs/tracked/tracked_atomic_preference.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ #include <string> #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" -#include "chrome/browser/prefs/tracked/tracked_preference.h" -#include "chrome/browser/prefs/tracked/tracked_preference_helper.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/tracked_preference.h" +#include "components/user_prefs/tracked/tracked_preference_helper.h" class TrackedPreferenceValidationDelegate; @@ -41,4 +41,4 @@ class TrackedAtomicPreference : public TrackedPreference { DISALLOW_COPY_AND_ASSIGN(TrackedAtomicPreference); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_ATOMIC_PREFERENCE_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_ATOMIC_PREFERENCE_H_ diff --git a/chrome/browser/prefs/tracked/tracked_preference.h b/components/user_prefs/tracked/tracked_preference.h index 37ce00d..4773ac1 100644 --- a/chrome/browser/prefs/tracked/tracked_preference.h +++ b/components/user_prefs/tracked/tracked_preference.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_PREFS_TRACKED_TRACKED_PREFERENCE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_H_ class PrefHashStoreTransaction; @@ -33,4 +33,4 @@ class TrackedPreference { PrefHashStoreTransaction* transaction) const = 0; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_H_ diff --git a/chrome/browser/prefs/tracked/tracked_preference_helper.cc b/components/user_prefs/tracked/tracked_preference_helper.cc index b3b528e..ade75ae 100644 --- a/chrome/browser/prefs/tracked/tracked_preference_helper.cc +++ b/components/user_prefs/tracked/tracked_preference_helper.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/prefs/tracked/tracked_preference_helper.h" +#include "components/user_prefs/tracked/tracked_preference_helper.h" #include "base/logging.h" #include "base/metrics/histogram.h" diff --git a/chrome/browser/prefs/tracked/tracked_preference_helper.h b/components/user_prefs/tracked/tracked_preference_helper.h index 8f9b7b6..f2fe338 100644 --- a/chrome/browser/prefs/tracked/tracked_preference_helper.h +++ b/components/user_prefs/tracked/tracked_preference_helper.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ +#define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ #include <string> #include "base/macros.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" // A TrackedPreferenceHelper is a helper class for TrackedPreference which // handles decision making and reporting for TrackedPreference's @@ -34,8 +34,7 @@ class TrackedPreferenceHelper { // (DONT_RESET) based on observing |value_state|. Can also return WANTED_RESET // if a reset would have been desired but the current |enforcement_level| // doesn't allow it. - ResetAction GetAction( - PrefHashStoreTransaction::ValueState value_state) const; + ResetAction GetAction(PrefHashStoreTransaction::ValueState value_state) const; // Returns true if the preference value may contain personal information. bool IsPersonal() const; @@ -65,4 +64,4 @@ class TrackedPreferenceHelper { DISALLOW_COPY_AND_ASSIGN(TrackedPreferenceHelper); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_HELPER_H_ diff --git a/chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h b/components/user_prefs/tracked/tracked_preference_validation_delegate.h index fd44ab6..8ea9c80 100644 --- a/chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h +++ b/components/user_prefs/tracked/tracked_preference_validation_delegate.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ #include <string> #include <vector> -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" namespace base { class DictionaryValue; @@ -41,4 +41,4 @@ class TrackedPreferenceValidationDelegate { bool is_personal) = 0; }; -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCE_VALIDATION_DELEGATE_H_ diff --git a/chrome/browser/prefs/tracked/tracked_preferences_migration.cc b/components/user_prefs/tracked/tracked_preferences_migration.cc index e1401ef..edcbae5 100644 --- a/chrome/browser/prefs/tracked/tracked_preferences_migration.cc +++ b/components/user_prefs/tracked/tracked_preferences_migration.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/prefs/tracked/tracked_preferences_migration.h" +#include "components/user_prefs/tracked/tracked_preferences_migration.h" #include "base/bind.h" #include "base/callback.h" @@ -10,11 +10,11 @@ #include "base/memory/ref_counted.h" #include "base/metrics/histogram.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/dictionary_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" -#include "chrome/browser/prefs/tracked/interceptable_pref_filter.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/dictionary_hash_store_contents.h" +#include "components/user_prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/interceptable_pref_filter.h" +#include "components/user_prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" namespace { diff --git a/chrome/browser/prefs/tracked/tracked_preferences_migration.h b/components/user_prefs/tracked/tracked_preferences_migration.h index c086dff..fecc0022 100644 --- a/chrome/browser/prefs/tracked/tracked_preferences_migration.h +++ b/components/user_prefs/tracked/tracked_preferences_migration.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ +#define COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ #include <set> #include <string> #include "base/callback_forward.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_store.h" class HashStoreContents; class InterceptablePrefFilter; @@ -45,4 +45,4 @@ void SetupTrackedPreferencesMigration( InterceptablePrefFilter* unprotected_pref_filter, InterceptablePrefFilter* protected_pref_filter); -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ diff --git a/chrome/browser/prefs/tracked/tracked_preferences_migration_unittest.cc b/components/user_prefs/tracked/tracked_preferences_migration_unittest.cc index 871e914..7557f36 100644 --- a/chrome/browser/prefs/tracked/tracked_preferences_migration_unittest.cc +++ b/components/user_prefs/tracked/tracked_preferences_migration_unittest.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/prefs/tracked/tracked_preferences_migration.h" +#include "components/user_prefs/tracked/tracked_preferences_migration.h" #include <set> #include <string> @@ -14,15 +14,14 @@ #include "base/prefs/testing_pref_service.h" #include "base/strings/string_split.h" #include "base/values.h" -#include "chrome/browser/prefs/profile_pref_store_manager.h" -#include "chrome/browser/prefs/tracked/dictionary_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/hash_store_contents.h" -#include "chrome/browser/prefs/tracked/interceptable_pref_filter.h" -#include "chrome/browser/prefs/tracked/pref_hash_store.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_impl.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" -#include "chrome/browser/prefs/tracked/tracked_preferences_migration.h" +#include "components/user_prefs/tracked/dictionary_hash_store_contents.h" +#include "components/user_prefs/tracked/hash_store_contents.h" +#include "components/user_prefs/tracked/interceptable_pref_filter.h" +#include "components/user_prefs/tracked/pref_hash_store.h" +#include "components/user_prefs/tracked/pref_hash_store_impl.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/pref_service_hash_store_contents.h" +#include "components/user_prefs/tracked/tracked_preferences_migration.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -85,7 +84,7 @@ class TrackedPreferencesMigrationTest : public testing::Test { protected_store_migration_complete_(false) {} void SetUp() override { - ProfilePrefStoreManager::RegisterPrefs(local_state_.registry()); + PrefServiceHashStoreContents::RegisterPrefs(local_state_.registry()); Reset(); } diff --git a/chrome/browser/prefs/tracked/tracked_split_preference.cc b/components/user_prefs/tracked/tracked_split_preference.cc index 074f003..37bac10 100644 --- a/chrome/browser/prefs/tracked/tracked_split_preference.cc +++ b/components/user_prefs/tracked/tracked_split_preference.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/prefs/tracked/tracked_split_preference.h" +#include "components/user_prefs/tracked/tracked_split_preference.h" #include <vector> #include "base/logging.h" #include "base/values.h" -#include "chrome/browser/prefs/tracked/pref_hash_store_transaction.h" -#include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" +#include "components/user_prefs/tracked/pref_hash_store_transaction.h" +#include "components/user_prefs/tracked/tracked_preference_validation_delegate.h" TrackedSplitPreference::TrackedSplitPreference( const std::string& pref_path, @@ -19,7 +19,10 @@ TrackedSplitPreference::TrackedSplitPreference( PrefHashFilter::ValueType value_type, TrackedPreferenceValidationDelegate* delegate) : pref_path_(pref_path), - helper_(pref_path, reporting_id, reporting_ids_count, enforcement_level, + helper_(pref_path, + reporting_id, + reporting_ids_count, + enforcement_level, value_type), delegate_(delegate) { } @@ -68,8 +71,8 @@ bool TrackedSplitPreference::EnforceAndReport( if (value_state == PrefHashStoreTransaction::CHANGED) { DCHECK(!invalid_keys.empty()); - for (std::vector<std::string>::const_iterator it = - invalid_keys.begin(); it != invalid_keys.end(); ++it) { + for (std::vector<std::string>::const_iterator it = invalid_keys.begin(); + it != invalid_keys.end(); ++it) { dict_value->Remove(*it, NULL); } } else { diff --git a/chrome/browser/prefs/tracked/tracked_split_preference.h b/components/user_prefs/tracked/tracked_split_preference.h index 9a6f3de..04c2128 100644 --- a/chrome/browser/prefs/tracked/tracked_split_preference.h +++ b/components/user_prefs/tracked/tracked_split_preference.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ -#define CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ +#ifndef COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ +#define COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ #include <string> #include "base/compiler_specific.h" #include "base/macros.h" -#include "chrome/browser/prefs/tracked/pref_hash_filter.h" -#include "chrome/browser/prefs/tracked/tracked_preference.h" -#include "chrome/browser/prefs/tracked/tracked_preference_helper.h" +#include "components/user_prefs/tracked/pref_hash_filter.h" +#include "components/user_prefs/tracked/tracked_preference.h" +#include "components/user_prefs/tracked/tracked_preference_helper.h" class TrackedPreferenceValidationDelegate; @@ -44,4 +44,4 @@ class TrackedSplitPreference : public TrackedPreference { DISALLOW_COPY_AND_ASSIGN(TrackedSplitPreference); }; -#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ +#endif // COMPONENTS_USER_PREFS_TRACKED_TRACKED_SPLIT_PREFERENCE_H_ |