| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 19 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, | 313 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, |
| 313 pref_store_->GetValue(kProtectedAtomic, NULL)); | 314 pref_store_->GetValue(kProtectedAtomic, NULL)); |
| 314 VerifyResetRecorded( | 315 VerifyResetRecorded( |
| 315 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); | 316 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); |
| 316 | 317 |
| 317 ExpectValidationObserved(kTrackedAtomic); | 318 ExpectValidationObserved(kTrackedAtomic); |
| 318 ExpectValidationObserved(kProtectedAtomic); | 319 ExpectValidationObserved(kProtectedAtomic); |
| 319 } | 320 } |
| 320 | 321 |
| 321 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { | 322 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { |
| 322 base::DictionaryValue master_prefs; | 323 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); |
| 323 master_prefs.Set(kTrackedAtomic, new base::StringValue(kFoobar)); | 324 master_prefs->Set(kTrackedAtomic, new base::StringValue(kFoobar)); |
| 324 master_prefs.Set(kProtectedAtomic, new base::StringValue(kHelloWorld)); | 325 master_prefs->Set(kProtectedAtomic, new base::StringValue(kHelloWorld)); |
| 325 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs(master_prefs)); | 326 EXPECT_TRUE( |
| 327 manager_->InitializePrefsFromMasterPrefs(std::move(master_prefs))); |
| 326 | 328 |
| 327 LoadExistingPrefs(); | 329 LoadExistingPrefs(); |
| 328 | 330 |
| 329 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs | 331 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs |
| 330 // necessary to authenticate these values. | 332 // necessary to authenticate these values. |
| 331 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 333 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
| 332 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 334 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
| 333 VerifyResetRecorded(false); | 335 VerifyResetRecorded(false); |
| 334 } | 336 } |
| 335 | 337 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 482 |
| 481 // Trigger the logic that migrates it back to the unprotected preferences | 483 // Trigger the logic that migrates it back to the unprotected preferences |
| 482 // file. | 484 // file. |
| 483 pref_store_->SetValue(kProtectedAtomic, | 485 pref_store_->SetValue(kProtectedAtomic, |
| 484 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), | 486 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), |
| 485 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 487 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 486 LoadExistingPrefs(); | 488 LoadExistingPrefs(); |
| 487 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 489 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 488 VerifyResetRecorded(false); | 490 VerifyResetRecorded(false); |
| 489 } | 491 } |
| OLD | NEW |