diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-02 20:38:04 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-02 20:38:04 +0000 |
commit | 37a71cd82bf9575d580b24a0b32d181c0404b532 (patch) | |
tree | 2c7235389b5d314e5d7ed538ab0178906e5f3302 /chrome/browser/ui/cocoa | |
parent | 09ea72c7429f01b62b89eb35efa64d99f4b3bc39 (diff) | |
download | chromium_src-37a71cd82bf9575d580b24a0b32d181c0404b532.zip chromium_src-37a71cd82bf9575d580b24a0b32d181c0404b532.tar.gz chromium_src-37a71cd82bf9575d580b24a0b32d181c0404b532.tar.bz2 |
[Mac] Remove obsolete confirm to quit pref registration and migration code.
BUG=116120
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10704063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa')
-rw-r--r-- | chrome/browser/ui/cocoa/confirm_quit.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm | 33 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm | 70 |
3 files changed, 0 insertions, 108 deletions
diff --git a/chrome/browser/ui/cocoa/confirm_quit.h b/chrome/browser/ui/cocoa/confirm_quit.h index 9ae26bd..c2b43e7 100644 --- a/chrome/browser/ui/cocoa/confirm_quit.h +++ b/chrome/browser/ui/cocoa/confirm_quit.h @@ -27,11 +27,6 @@ void RecordHistogram(ConfirmQuitMetric sample); // Registers the preference in app-wide local state. void RegisterLocalState(PrefService* local_state); -// Registers the prererence in the old profile-specific preferences. -void RegisterObsoleteUserPrefs(PrefService* user_prefs); - -// Migrates the obsolete profile-specific preference to local state. -void MigratePrefToLocalState(); } // namespace confirm_quit diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm index d521f40..eb58c2a 100644 --- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm +++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller.mm @@ -48,39 +48,6 @@ void RegisterLocalState(PrefService* local_state) { local_state->RegisterBooleanPref(prefs::kConfirmToQuitEnabled, false); } -void RegisterObsoleteUserPrefs(PrefService* user_prefs) { - user_prefs->RegisterBooleanPref(prefs::kConfirmToQuitEnabled, - false, - PrefService::SYNCABLE_PREF); -} - -void MigratePrefToLocalState() { - // If the preference has already been migrated, do nothing. - PrefService* local_state = g_browser_process->local_state(); - if (local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)) - return; - - DVLOG(1) << "Migrating kConfirmToQuitEnabled to local state"; - - bool enable = false; - - // Loop over each profile and see if any have confirm to quit enabled. - std::vector<Profile*> profiles = - g_browser_process->profile_manager()->GetLoadedProfiles(); - for (std::vector<Profile*>::iterator it = profiles.begin(); - it != profiles.end(); - ++it) { - PrefService* prefs = (*it)->GetPrefs(); - enable |= prefs->HasPrefPath(prefs::kConfirmToQuitEnabled) && - prefs->GetBoolean(prefs::kConfirmToQuitEnabled); - prefs->ClearPref(prefs::kConfirmToQuitEnabled); - } - - // Set the new preference, even if it's not enabled so that this logic does - // not run more than once. - local_state->SetBoolean(prefs::kConfirmToQuitEnabled, enable); -} - } // namespace confirm_quit // Custom Content View ///////////////////////////////////////////////////////// diff --git a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm index 4d3646d..150f92c 100644 --- a/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/confirm_quit_panel_controller_unittest.mm @@ -6,13 +6,7 @@ #include "base/memory/scoped_nsobject.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/cocoa/confirm_quit.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/testing_browser_process.h" -#include "chrome/test/base/testing_profile.h" -#include "chrome/test/base/testing_profile_manager.h" #include "testing/gtest_mac.h" #include "ui/base/accelerators/accelerator_cocoa.h" @@ -82,68 +76,4 @@ TEST_F(ConfirmQuitPanelControllerTest, KeyCombinationForAccelerator) { [controller keyCombinationForAccelerator:item]); } -TEST_F(ConfirmQuitPanelControllerTest, PrefMigration) { - TestingProfileManager manager( - static_cast<TestingBrowserProcess*>(g_browser_process)); - ASSERT_TRUE(manager.SetUp()); - - TestingProfile* profile1 = manager.CreateTestingProfile("one"); - TestingProfile* profile2 = manager.CreateTestingProfile("two"); - TestingProfile* profile3 = manager.CreateTestingProfile("three"); - - PrefService* local_state = g_browser_process->local_state(); - EXPECT_FALSE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - - // Case 1: Default (disabled) across all profiles remains set but disabled. - confirm_quit::MigratePrefToLocalState(); - EXPECT_TRUE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(local_state->GetBoolean(prefs::kConfirmToQuitEnabled)); - - local_state->ClearPref(prefs::kConfirmToQuitEnabled); - EXPECT_FALSE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - - // Case 2: One profile disabled, one enabled, and one default results in - // set and enabled. - profile2->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, true); - profile3->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, false); - confirm_quit::MigratePrefToLocalState(); - EXPECT_TRUE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile1->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile2->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile3->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_TRUE(local_state->GetBoolean(prefs::kConfirmToQuitEnabled)); - - local_state->ClearPref(prefs::kConfirmToQuitEnabled); - EXPECT_FALSE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - - // Case 3: All explicitly disabled results in set but disabled. - profile1->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, false); - profile2->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, false); - profile3->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, false); - confirm_quit::MigratePrefToLocalState(); - EXPECT_TRUE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile1->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile2->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(profile3->GetPrefs()->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(local_state->GetBoolean(prefs::kConfirmToQuitEnabled)); - - local_state->ClearPref(prefs::kConfirmToQuitEnabled); - EXPECT_FALSE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - - // Case 4: Only migrate once by migrating the default value (false) first, - // enabling it one already-migrated profile, and then migrating again. The - // new pref will remain disabled because migration happens once. - confirm_quit::MigratePrefToLocalState(); - EXPECT_TRUE(local_state->HasPrefPath(prefs::kConfirmToQuitEnabled)); - EXPECT_FALSE(local_state->GetBoolean(prefs::kConfirmToQuitEnabled)); - profile1->GetPrefs()->SetBoolean(prefs::kConfirmToQuitEnabled, true); - confirm_quit::MigratePrefToLocalState(); - EXPECT_FALSE(local_state->GetBoolean(prefs::kConfirmToQuitEnabled)); - EXPECT_TRUE(profile1->GetPrefs()->GetBoolean(prefs::kConfirmToQuitEnabled)); - - manager.DeleteTestingProfile("one"); - manager.DeleteTestingProfile("two"); - manager.DeleteTestingProfile("three"); -} - } // namespace |