diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 16:48:49 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 16:48:49 +0000 |
commit | db198b2722f4592f6b76294f6a7f9c868e05bc15 (patch) | |
tree | ce5c93732e2d202548b6e2d69ab6a80cc06ca7ea /chrome/browser/dom_ui | |
parent | ef40c4da832d2082dffe1262b0e2dbf64b5e8031 (diff) | |
download | chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.zip chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.tar.gz chromium_src-db198b2722f4592f6b76294f6a7f9c868e05bc15.tar.bz2 |
Add an ExtensionPrefStore, layered between the user prefs and the managed prefs, to manage preferences set by extensions.
Update various callers of the PrefValueStore constructor accordingly.
The initial user will be the proxy extension API.
BUG=266
TEST=covered by unit tests
Review URL: http://codereview.chromium.org/2823037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui_uitest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/dom_ui/shown_sections_handler_unittest.cc | 32 |
2 files changed, 22 insertions, 34 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc index f2e96df..39f41e2 100644 --- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc +++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc @@ -75,30 +75,26 @@ TEST_F(NewTabUITest, FLAKY_ChromeInternalLoadsNTP) { TEST_F(NewTabUITest, UpdateUserPrefsVersion) { // PrefService with JSON user-pref file only, no enforced or advised prefs. - PrefService prefs(new PrefValueStore( - NULL, /* no enforced prefs */ - new JsonPrefStore( - FilePath(), - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), - /* user prefs */ - NULL /* no advised prefs */)); + FilePath user_prefs = FilePath(); + scoped_ptr<PrefService> prefs( + PrefService::CreateUserPrefService(user_prefs)); // Does the migration - NewTabUI::RegisterUserPrefs(&prefs); + NewTabUI::RegisterUserPrefs(prefs.get()); ASSERT_EQ(NewTabUI::current_pref_version(), - prefs.GetInteger(prefs::kNTPPrefVersion)); + prefs->GetInteger(prefs::kNTPPrefVersion)); // Reset the version - prefs.ClearPref(prefs::kNTPPrefVersion); - ASSERT_EQ(0, prefs.GetInteger(prefs::kNTPPrefVersion)); + prefs->ClearPref(prefs::kNTPPrefVersion); + ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); - bool migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); + bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); ASSERT_TRUE(migrated); ASSERT_EQ(NewTabUI::current_pref_version(), - prefs.GetInteger(prefs::kNTPPrefVersion)); + prefs->GetInteger(prefs::kNTPPrefVersion)); - migrated = NewTabUI::UpdateUserPrefsVersion(&prefs); + migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); ASSERT_FALSE(migrated); } diff --git a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc index 031a2b6..42fa47a 100644 --- a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc +++ b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc @@ -19,20 +19,16 @@ class ShownSectionsHandlerTest : public testing::Test { TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) { // Create a preference value that has only user defined // preference values. - PrefService pref(new PrefValueStore( - NULL, /* no managed preference values */ - new JsonPrefStore( /* user defined preference values */ - FilePath(), - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), - NULL /* no suggested preference values */)); + FilePath user_prefs = FilePath(); + scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs)); // Set an *old* value - pref.RegisterIntegerPref(prefs::kNTPShownSections, 0); - pref.SetInteger(prefs::kNTPShownSections, THUMB); + pref->RegisterIntegerPref(prefs::kNTPShownSections, 0); + pref->SetInteger(prefs::kNTPShownSections, THUMB); - ShownSectionsHandler::MigrateUserPrefs(&pref, 0, 1); + ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1); - int shown_sections = pref.GetInteger(prefs::kNTPShownSections); + int shown_sections = pref->GetInteger(prefs::kNTPShownSections); EXPECT_TRUE(shown_sections & THUMB); EXPECT_FALSE(shown_sections & LIST); @@ -42,20 +38,16 @@ TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) { } TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) { - PrefService pref(new PrefValueStore( - NULL, /* no managed preferences */ - new JsonPrefStore( - FilePath(), - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), - NULL /* no suggested preferences */)); + FilePath user_prefs = FilePath(); + scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs)); // Set an *old* value - pref.RegisterIntegerPref(prefs::kNTPShownSections, 0); - pref.SetInteger(prefs::kNTPShownSections, LIST); + pref->RegisterIntegerPref(prefs::kNTPShownSections, 0); + pref->SetInteger(prefs::kNTPShownSections, LIST); - ShownSectionsHandler::MigrateUserPrefs(&pref, 1, 2); + ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2); - int shown_sections = pref.GetInteger(prefs::kNTPShownSections); + int shown_sections = pref->GetInteger(prefs::kNTPShownSections); EXPECT_TRUE(shown_sections & THUMB); EXPECT_FALSE(shown_sections & LIST); |