| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/profile_pref_store_manager.h" | 5 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 seed_("seed"), | 95 seed_("seed"), |
| 96 reset_recorded_(false) {} | 96 reset_recorded_(false) {} |
| 97 | 97 |
| 98 void SetUp() override { | 98 void SetUp() override { |
| 99 ProfilePrefStoreManager::RegisterPrefs(local_state_.registry()); | 99 ProfilePrefStoreManager::RegisterPrefs(local_state_.registry()); |
| 100 ProfilePrefStoreManager::RegisterProfilePrefs(profile_pref_registry_.get()); | 100 ProfilePrefStoreManager::RegisterProfilePrefs(profile_pref_registry_.get()); |
| 101 for (const PrefHashFilter::TrackedPreferenceMetadata* it = kConfiguration; | 101 for (const PrefHashFilter::TrackedPreferenceMetadata* it = kConfiguration; |
| 102 it != kConfiguration + arraysize(kConfiguration); | 102 it != kConfiguration + arraysize(kConfiguration); |
| 103 ++it) { | 103 ++it) { |
| 104 if (it->strategy == PrefHashFilter::TRACKING_STRATEGY_ATOMIC) { | 104 if (it->strategy == PrefHashFilter::TRACKING_STRATEGY_ATOMIC) { |
| 105 profile_pref_registry_->RegisterStringPref( | 105 profile_pref_registry_->RegisterStringPref(it->name, std::string()); |
| 106 it->name, | |
| 107 std::string(), | |
| 108 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 109 } else { | 106 } else { |
| 110 profile_pref_registry_->RegisterDictionaryPref( | 107 profile_pref_registry_->RegisterDictionaryPref(it->name); |
| 111 it->name, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 112 } | 108 } |
| 113 } | 109 } |
| 114 profile_pref_registry_->RegisterStringPref( | 110 profile_pref_registry_->RegisterStringPref(kUnprotectedPref, std::string()); |
| 115 kUnprotectedPref, | |
| 116 std::string(), | |
| 117 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 118 | 111 |
| 119 // As in chrome_pref_service_factory.cc, kPreferencesResetTime needs to be | 112 // As in chrome_pref_service_factory.cc, kPreferencesResetTime needs to be |
| 120 // declared as protected in order to be read from the proper store by the | 113 // declared as protected in order to be read from the proper store by the |
| 121 // SegregatedPrefStore. Only declare it after configured prefs have been | 114 // SegregatedPrefStore. Only declare it after configured prefs have been |
| 122 // registered above for this test as kPreferenceResetTime is already | 115 // registered above for this test as kPreferenceResetTime is already |
| 123 // registered in ProfilePrefStoreManager::RegisterProfilePrefs. | 116 // registered in ProfilePrefStoreManager::RegisterProfilePrefs. |
| 124 PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = | 117 PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = |
| 125 {configuration_.rbegin()->reporting_id + 1, prefs::kPreferenceResetTime, | 118 {configuration_.rbegin()->reporting_id + 1, prefs::kPreferenceResetTime, |
| 126 PrefHashFilter::ENFORCE_ON_LOAD, | 119 PrefHashFilter::ENFORCE_ON_LOAD, |
| 127 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; | 120 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 LoadExistingPrefs(); | 571 LoadExistingPrefs(); |
| 579 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 572 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
| 580 | 573 |
| 581 // Trigger the logic that migrates it back to the unprotected preferences | 574 // Trigger the logic that migrates it back to the unprotected preferences |
| 582 // file. | 575 // file. |
| 583 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld)); | 576 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld)); |
| 584 LoadExistingPrefs(); | 577 LoadExistingPrefs(); |
| 585 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 578 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 586 VerifyResetRecorded(false); | 579 VerifyResetRecorded(false); |
| 587 } | 580 } |
| OLD | NEW |