diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/prefs/chrome_pref_service_unittest.cc | 53 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_metrics_service.cc | 16 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_metrics_service.h | 4 |
3 files changed, 0 insertions, 73 deletions
diff --git a/chrome/browser/prefs/chrome_pref_service_unittest.cc b/chrome/browser/prefs/chrome_pref_service_unittest.cc index 4a453fd4..0d27501 100644 --- a/chrome/browser/prefs/chrome_pref_service_unittest.cc +++ b/chrome/browser/prefs/chrome_pref_service_unittest.cc @@ -88,59 +88,6 @@ class ChromePrefServiceUserFilePrefsTest : public testing::Test { base::MessageLoop message_loop_; }; -// Verifies that ListValue and DictionaryValue pref with non emtpy default -// preserves its empty value. -TEST_F(ChromePrefServiceUserFilePrefsTest, PreserveEmptyValue) { - base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); - - ASSERT_TRUE(base::CopyFile( - data_dir_.AppendASCII("read.need_empty_value.json"), - pref_file)); - - PrefServiceMockFactory factory; - factory.SetUserPrefsFile(pref_file, - message_loop_.message_loop_proxy().get()); - scoped_refptr<user_prefs::PrefRegistrySyncable> registry( - new user_prefs::PrefRegistrySyncable); - scoped_ptr<PrefServiceSyncable> prefs(factory.CreateSyncable(registry.get())); - - // Register testing prefs. - registry->RegisterListPref("list", - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - registry->RegisterDictionaryPref( - "dict", - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - - base::ListValue* non_empty_list = new base::ListValue; - non_empty_list->Append(base::Value::CreateStringValue("test")); - registry->RegisterListPref("list_needs_empty_value", - non_empty_list, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - - base::DictionaryValue* non_empty_dict = new base::DictionaryValue; - non_empty_dict->SetString("dummy", "whatever"); - registry->RegisterDictionaryPref( - "dict_needs_empty_value", - non_empty_dict, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - - // Set all testing prefs to empty. - ClearListValue(prefs.get(), "list"); - ClearListValue(prefs.get(), "list_needs_empty_value"); - ClearDictionaryValue(prefs.get(), "dict"); - ClearDictionaryValue(prefs.get(), "dict_needs_empty_value"); - - // Write to file. - prefs->CommitPendingWrite(); - message_loop_.RunUntilIdle(); - - // Compare to expected output. - base::FilePath golden_output_file = - data_dir_.AppendASCII("write.golden.need_empty_value.json"); - ASSERT_TRUE(base::PathExists(golden_output_file)); - EXPECT_TRUE(base::TextContentsEqual(golden_output_file, pref_file)); -} - class ChromePrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { protected: virtual void SetUp() { diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc index 6bbfa4a..7c3f920 100644 --- a/chrome/browser/prefs/pref_metrics_service.cc +++ b/chrome/browser/prefs/pref_metrics_service.cc @@ -92,8 +92,6 @@ PrefMetricsService::PrefMetricsService(Profile* profile) RegisterSyncedPrefObservers(); - MarkNeedsEmptyValueForTrackedPreferences(); - // The following code might cause callbacks into this instance before we exit // the constructor. This instance should be initialized at this point. #if defined(OS_WIN) || defined(OS_MACOSX) @@ -122,7 +120,6 @@ PrefMetricsService::PrefMetricsService(Profile* profile, tracked_pref_path_count_(tracked_pref_path_count), checked_tracked_prefs_(false), weak_factory_(this) { - MarkNeedsEmptyValueForTrackedPreferences(); CheckTrackedPreferences(); } @@ -273,19 +270,6 @@ void PrefMetricsService::GetDeviceIdCallback(const std::string& device_id) { CheckTrackedPreferences(); } -void PrefMetricsService::MarkNeedsEmptyValueForTrackedPreferences() { - for (int i = 0; i < tracked_pref_path_count_; ++i) { - // Skip prefs that haven't been registered. - if (!prefs_->FindPreference(tracked_pref_paths_[i])) - continue; - - // Make sure tracked prefs are saved to disk even if empty. - // TODO(gab): Guarantee this for all prefs at a lower level and remove this - // hack. - prefs_->MarkUserStoreNeedsEmptyValue(tracked_pref_paths_[i]); - } -} - // To detect changes to Preferences that happen outside of Chrome, we hash // selected pref values and save them in local state. CheckTrackedPreferences // compares the saved values to the values observed in the profile's prefs. A diff --git a/chrome/browser/prefs/pref_metrics_service.h b/chrome/browser/prefs/pref_metrics_service.h index c776b07..d38a006 100644 --- a/chrome/browser/prefs/pref_metrics_service.h +++ b/chrome/browser/prefs/pref_metrics_service.h @@ -95,10 +95,6 @@ class PrefMetricsService : public BrowserContextKeyedService { // Callback to receive a unique device_id. void GetDeviceIdCallback(const std::string& device_id); - // Marks all tracked preferences as required to save their values even if - // empty. - void MarkNeedsEmptyValueForTrackedPreferences(); - // Checks the tracked preferences against their last known values and reports // any discrepancies. This must be called after |device_id| has been set. void CheckTrackedPreferences(); |