| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 kDefaultPref3, | 688 kDefaultPref3, |
| 689 PrefService::UNSYNCABLE_PREF); | 689 PrefService::UNSYNCABLE_PREF); |
| 690 prefs()->pref_service()->RegisterStringPref(kPref4, | 690 prefs()->pref_service()->RegisterStringPref(kPref4, |
| 691 kDefaultPref4, | 691 kDefaultPref4, |
| 692 PrefService::UNSYNCABLE_PREF); | 692 PrefService::UNSYNCABLE_PREF); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void InstallExtControlledPref(Extension *ext, | 695 void InstallExtControlledPref(Extension *ext, |
| 696 const std::string& key, | 696 const std::string& key, |
| 697 Value* val) { | 697 Value* val) { |
| 698 using namespace extension_prefs_scope; |
| 698 EnsureExtensionInstalled(ext); | 699 EnsureExtensionInstalled(ext); |
| 699 prefs()->SetExtensionControlledPref(ext->id(), key, false, val); | 700 prefs()->SetExtensionControlledPref(ext->id(), key, kRegular, val); |
| 700 } | 701 } |
| 701 | 702 |
| 702 void InstallExtControlledPrefIncognito(Extension *ext, | 703 void InstallExtControlledPrefIncognito(Extension *ext, |
| 703 const std::string& key, | 704 const std::string& key, |
| 704 Value* val) { | 705 Value* val) { |
| 706 using namespace extension_prefs_scope; |
| 705 EnsureExtensionInstalled(ext); | 707 EnsureExtensionInstalled(ext); |
| 706 prefs()->SetExtensionControlledPref(ext->id(), key, true, val); | 708 prefs()->SetExtensionControlledPref(ext->id(), key, |
| 709 kIncognitoPersistent, val); |
| 707 } | 710 } |
| 708 | 711 |
| 709 void InstallExtension(Extension *ext) { | 712 void InstallExtension(Extension *ext) { |
| 710 EnsureExtensionInstalled(ext); | 713 EnsureExtensionInstalled(ext); |
| 711 } | 714 } |
| 712 | 715 |
| 713 void UninstallExtension(const std::string& extension_id) { | 716 void UninstallExtension(const std::string& extension_id) { |
| 714 EnsureExtensionUninstalled(extension_id); | 717 EnsureExtensionUninstalled(extension_id); |
| 715 } | 718 } |
| 716 | 719 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 EXPECT_EQ("val2", actual); | 781 EXPECT_EQ("val2", actual); |
| 779 } | 782 } |
| 780 virtual void Verify() { | 783 virtual void Verify() { |
| 781 // Main pref service shall see only non-incognito settings. | 784 // Main pref service shall see only non-incognito settings. |
| 782 std::string actual = prefs()->pref_service()->GetString(kPref1); | 785 std::string actual = prefs()->pref_service()->GetString(kPref1); |
| 783 EXPECT_EQ("val1", actual); | 786 EXPECT_EQ("val1", actual); |
| 784 // Incognito pref service shall see incognito values only during first run. | 787 // Incognito pref service shall see incognito values only during first run. |
| 785 // Once the pref service was reloaded, all values shall be discarded. | 788 // Once the pref service was reloaded, all values shall be discarded. |
| 786 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 789 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); |
| 787 actual = incog_prefs->GetString(kPref1); | 790 actual = incog_prefs->GetString(kPref1); |
| 788 if (iteration_ == 0) { | 791 |
| 789 EXPECT_EQ("val2", actual); | 792 // The incognito preference is persisted. |
| 790 } else { | |
| 791 EXPECT_EQ("val1", actual); | |
| 792 } | |
| 793 ++iteration_; | 793 ++iteration_; |
| 794 } | 794 } |
| 795 int iteration_; | 795 int iteration_; |
| 796 }; | 796 }; |
| 797 TEST_F(ExtensionPrefsInstallIncognito, ExtensionPrefsInstallOneExtension) {} | 797 TEST_F(ExtensionPrefsInstallIncognito, ExtensionPrefsInstallOneExtension) {} |
| 798 | 798 |
| 799 class ExtensionPrefsUninstallExtension | 799 class ExtensionPrefsUninstallExtension |
| 800 : public ExtensionPrefsPreferencesBase { | 800 : public ExtensionPrefsPreferencesBase { |
| 801 virtual void Initialize() { | 801 virtual void Initialize() { |
| 802 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); | 802 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 testing::Mock::VerifyAndClearExpectations(v1i); | 954 testing::Mock::VerifyAndClearExpectations(v1i); |
| 955 testing::Mock::VerifyAndClearExpectations(v2); | 955 testing::Mock::VerifyAndClearExpectations(v2); |
| 956 testing::Mock::VerifyAndClearExpectations(v2i); | 956 testing::Mock::VerifyAndClearExpectations(v2i); |
| 957 } | 957 } |
| 958 | 958 |
| 959 virtual void Verify() { | 959 virtual void Verify() { |
| 960 } | 960 } |
| 961 }; | 961 }; |
| 962 TEST_F(ExtensionPrefsSetExtensionControlledPref, | 962 TEST_F(ExtensionPrefsSetExtensionControlledPref, |
| 963 ExtensionPrefsSetExtensionControlledPref) {} | 963 ExtensionPrefsSetExtensionControlledPref) {} |
| OLD | NEW |