diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index dc61c6012be378..03ad2851532a83 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -3269,56 +3269,6 @@ class RestoreOnStartupPolicyTest RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs))); } - void HomepageIsNotNTP() { - // Verifies that policy can set the startup pages to the homepage, when - // the homepage is not the NTP. - PolicyMap policies; - policies.Set( - key::kRestoreOnStartup, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_USER, - POLICY_SOURCE_CLOUD, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), - NULL); - policies.Set(key::kHomepageIsNewTabPage, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_USER, - POLICY_SOURCE_CLOUD, - new base::FundamentalValue(false), - NULL); - policies.Set(key::kHomepageLocation, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_USER, - POLICY_SOURCE_CLOUD, - new base::StringValue(kRestoredURLs[1]), - NULL); - provider_.UpdateChromePolicy(policies); - - expected_urls_.push_back(GURL(kRestoredURLs[1])); - } - - void HomepageIsNTP() { - // Verifies that policy can set the startup pages to the homepage, when - // the homepage is the NTP. - PolicyMap policies; - policies.Set( - key::kRestoreOnStartup, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_USER, - POLICY_SOURCE_CLOUD, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage), - NULL); - policies.Set(key::kHomepageIsNewTabPage, - POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_USER, - POLICY_SOURCE_CLOUD, - new base::FundamentalValue(true), - NULL); - provider_.UpdateChromePolicy(policies); - - expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); - } - void ListOfURLs() { // Verifies that policy can set the startup pages to a list of URLs. base::ListValue urls; @@ -3405,9 +3355,7 @@ IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, RunTest) { INSTANTIATE_TEST_CASE_P( RestoreOnStartupPolicyTestInstance, RestoreOnStartupPolicyTest, - testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, - &RestoreOnStartupPolicyTest::HomepageIsNTP, - &RestoreOnStartupPolicyTest::ListOfURLs, + testing::Values(&RestoreOnStartupPolicyTest::ListOfURLs, &RestoreOnStartupPolicyTest::NTP, &RestoreOnStartupPolicyTest::Last)); diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 57862ffc33f04a..6358cf6b040df3 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -242,6 +242,9 @@ const char kURLsToRestoreOnStartupOld[] = "session.urls_to_restore_on_startup"; const char kRestoreStartupURLsMigrationTime[] = "session.startup_urls_migration_time"; +// Deprecated 12/2015. +const char kRestoreOnStartupMigrated[] = "session.restore_on_startup_migrated"; + } // namespace namespace chrome { @@ -542,6 +545,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { registry->RegisterListPref(kURLsToRestoreOnStartupOld); registry->RegisterInt64Pref(kRestoreStartupURLsMigrationTime, 0); + registry->RegisterBooleanPref(kRestoreOnStartupMigrated, false); } void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { @@ -593,6 +597,9 @@ void MigrateObsoleteProfilePrefs(Profile* profile) { // Added 12/1015. profile_prefs->ClearPref(kURLsToRestoreOnStartupOld); profile_prefs->ClearPref(kRestoreStartupURLsMigrationTime); + + // Added 12/2015. + profile_prefs->ClearPref(kRestoreOnStartupMigrated); } } // namespace chrome diff --git a/chrome/browser/prefs/session_startup_pref.cc b/chrome/browser/prefs/session_startup_pref.cc index 6e307127eaebcd..51fb6c5558ff86 100644 --- a/chrome/browser/prefs/session_startup_pref.cc +++ b/chrome/browser/prefs/session_startup_pref.cc @@ -25,16 +25,6 @@ int TypeToPrefValue(SessionStartupPref::Type type) { } } -void SetNewURLList(PrefService* prefs) { - if (prefs->IsUserModifiablePreference(prefs::kURLsToRestoreOnStartup)) { - base::ListValue new_url_pref_list; - base::StringValue* home_page = - new base::StringValue(prefs->GetString(prefs::kHomePage)); - new_url_pref_list.Append(home_page); - prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); - } -} - void URLListToPref(const base::ListValue* url_list, SessionStartupPref* pref) { pref->urls.clear(); for (size_t i = 0; i < url_list->GetSize(); ++i) { @@ -57,7 +47,6 @@ void SessionStartupPref::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterListPref(prefs::kURLsToRestoreOnStartup, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); - registry->RegisterBooleanPref(prefs::kRestoreOnStartupMigrated, false); } // static @@ -110,8 +99,6 @@ SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { DCHECK(prefs); - MigrateIfNecessary(prefs); - SessionStartupPref pref( PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup))); @@ -124,54 +111,6 @@ SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { return pref; } -// static -void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) { - DCHECK(prefs); - - if (!prefs->GetBoolean(prefs::kRestoreOnStartupMigrated)) { - // Read existing values. - const base::Value* homepage_is_new_tab_page_value = - prefs->GetUserPrefValue(prefs::kHomePageIsNewTabPage); - bool homepage_is_new_tab_page = true; - if (homepage_is_new_tab_page_value) { - if (!homepage_is_new_tab_page_value->GetAsBoolean( - &homepage_is_new_tab_page)) - NOTREACHED(); - } - - const base::Value* restore_on_startup_value = - prefs->GetUserPrefValue(prefs::kRestoreOnStartup); - int restore_on_startup = -1; - if (restore_on_startup_value) { - if (!restore_on_startup_value->GetAsInteger(&restore_on_startup)) - NOTREACHED(); - } - - // If restore_on_startup has the deprecated value kPrefValueHomePage, - // migrate it to open the homepage on startup. If 'homepage is NTP' is set, - // that means just opening the NTP. If not, it means opening a one-item URL - // list containing the homepage. - if (restore_on_startup == kPrefValueHomePage) { - if (homepage_is_new_tab_page) { - prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueNewTab); - } else { - prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs); - SetNewURLList(prefs); - } - } else if (!restore_on_startup_value && !homepage_is_new_tab_page && - GetDefaultStartupType() == DEFAULT) { - // kRestoreOnStartup was never set by the user, but the homepage was set. - // Migrate to the list of URLs. (If restore_on_startup was never set, - // and homepage_is_new_tab_page is true, no action is needed. The new - // default value is "open the new tab page" which is what we want.) - prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs); - SetNewURLList(prefs); - } - - prefs->SetBoolean(prefs::kRestoreOnStartupMigrated, true); - } -} - // static bool SessionStartupPref::TypeIsManaged(PrefService* prefs) { DCHECK(prefs); @@ -204,7 +143,6 @@ SessionStartupPref::Type SessionStartupPref::PrefValueToType(int pref_value) { switch (pref_value) { case kPrefValueLast: return SessionStartupPref::LAST; case kPrefValueURLs: return SessionStartupPref::URLS; - case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; default: return SessionStartupPref::DEFAULT; } } diff --git a/chrome/browser/prefs/session_startup_pref.h b/chrome/browser/prefs/session_startup_pref.h index 0a7aeec08663ca..67ebeaaed67c4d 100644 --- a/chrome/browser/prefs/session_startup_pref.h +++ b/chrome/browser/prefs/session_startup_pref.h @@ -23,25 +23,18 @@ struct SessionStartupPref { // Indicates the user wants to open the New Tab page. DEFAULT, - // Deprecated. See comment in session_startup_pref.cc - HOMEPAGE, - // Indicates the user wants to restore the last session. LAST, // Indicates the user wants to restore a specific set of URLs. The URLs // are contained in urls. URLS, - - // Number of values in this enum. - TYPE_COUNT }; // For historical reasons the enum and value registered in the prefs don't // line up. These are the values registered in prefs. // The values are also recorded in Settings.StartupPageLoadSettings histogram, // so make sure to update histograms.xml if you change these. - static const int kPrefValueHomePage = 0; // Deprecated static const int kPrefValueLast = 1; static const int kPrefValueURLs = 4; static const int kPrefValueNewTab = 5; @@ -59,11 +52,6 @@ struct SessionStartupPref { static SessionStartupPref GetStartupPref(Profile* profile); static SessionStartupPref GetStartupPref(PrefService* prefs); - // If the user had the "restore on startup" property set to the deprecated - // "Open the home page" value, this migrates them to a value that will have - // the same effect. - static void MigrateIfNecessary(PrefService* prefs); - // Whether the startup type and URLs are managed via policy. static bool TypeIsManaged(PrefService* prefs); static bool URLsAreManaged(PrefService* prefs); diff --git a/chrome/browser/prefs/session_startup_pref_unittest.cc b/chrome/browser/prefs/session_startup_pref_unittest.cc index 1e8d2214ebf818..31385b4c3978eb 100644 --- a/chrome/browser/prefs/session_startup_pref_unittest.cc +++ b/chrome/browser/prefs/session_startup_pref_unittest.cc @@ -18,15 +18,6 @@ class SessionStartupPrefTest : public testing::Test { registry()->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true); } - bool IsUseLastOpenDefault() { - // On ChromeOS, the default SessionStartupPref is LAST. -#if defined(OS_CHROMEOS) - return true; -#else - return false; -#endif - } - user_prefs::PrefRegistrySyncable* registry() { return pref_service_->registry(); } @@ -71,88 +62,3 @@ TEST_F(SessionStartupPrefTest, URLListManagedOverridesUser) { result = SessionStartupPref::GetStartupPref(pref_service_.get()); EXPECT_EQ(3u, result.urls.size()); } - -// Checks to make sure that if the user had previously not selected anything -// (so that, in effect, the default value "Open the homepage" was selected), -// their preferences are migrated on upgrade to m19. -TEST_F(SessionStartupPrefTest, DefaultMigration) { - registry()->RegisterStringPref(prefs::kHomePage, "http://google.com/"); - pref_service_->SetString(prefs::kHomePage, "http://chromium.org/"); - pref_service_->SetBoolean(prefs::kHomePageIsNewTabPage, false); - - EXPECT_FALSE(pref_service_->HasPrefPath(prefs::kRestoreOnStartup)); - - SessionStartupPref pref = SessionStartupPref::GetStartupPref( - pref_service_.get()); - - if (IsUseLastOpenDefault()) { - EXPECT_EQ(SessionStartupPref::LAST, pref.type); - EXPECT_EQ(0U, pref.urls.size()); - } else { - EXPECT_EQ(SessionStartupPref::URLS, pref.type); - EXPECT_EQ(1U, pref.urls.size()); - EXPECT_EQ(GURL("http://chromium.org/"), pref.urls[0]); - } -} - -// Checks to make sure that if the user had previously not selected anything -// (so that, in effect, the default value "Open the homepage" was selected), -// and the NTP is being used for the homepage, their preferences are migrated -// to "Open the New Tab Page" on upgrade to M19. -TEST_F(SessionStartupPrefTest, DefaultMigrationHomepageIsNTP) { - registry()->RegisterStringPref(prefs::kHomePage, "http://google.com/"); - pref_service_->SetString(prefs::kHomePage, "http://chromium.org/"); - pref_service_->SetBoolean(prefs::kHomePageIsNewTabPage, true); - - EXPECT_FALSE(pref_service_->HasPrefPath(prefs::kRestoreOnStartup)); - - SessionStartupPref pref = SessionStartupPref::GetStartupPref( - pref_service_.get()); - - if (IsUseLastOpenDefault()) - EXPECT_EQ(SessionStartupPref::LAST, pref.type); - else - EXPECT_EQ(SessionStartupPref::DEFAULT, pref.type); - - // The "URLs to restore on startup" shouldn't get migrated. - EXPECT_EQ(0U, pref.urls.size()); -} - -// Checks to make sure that if the user had previously selected "Open the -// "homepage", their preferences are migrated on upgrade to M19. -TEST_F(SessionStartupPrefTest, HomePageMigration) { - registry()->RegisterStringPref(prefs::kHomePage, "http://google.com/"); - - // By design, it's impossible to set the 'restore on startup' pref to 0 - // ("open the homepage") using SessionStartupPref::SetStartupPref(), so set it - // using the pref service directly. - pref_service_->SetInteger(prefs::kRestoreOnStartup, /*kPrefValueHomePage*/ 0); - pref_service_->SetString(prefs::kHomePage, "http://chromium.org/"); - pref_service_->SetBoolean(prefs::kHomePageIsNewTabPage, false); - - SessionStartupPref pref = SessionStartupPref::GetStartupPref( - pref_service_.get()); - - EXPECT_EQ(SessionStartupPref::URLS, pref.type); - EXPECT_EQ(1U, pref.urls.size()); - EXPECT_EQ(GURL("http://chromium.org/"), pref.urls[0]); -} - -// Checks to make sure that if the user had previously selected "Open the -// "homepage", and the NTP is being used for the homepage, their preferences -// are migrated on upgrade to M19. -TEST_F(SessionStartupPrefTest, HomePageMigrationHomepageIsNTP) { - registry()->RegisterStringPref(prefs::kHomePage, "http://google.com/"); - - // By design, it's impossible to set the 'restore on startup' pref to 0 - // ("open the homepage") using SessionStartupPref::SetStartupPref(), so set it - // using the pref service directly. - pref_service_->SetInteger(prefs::kRestoreOnStartup, /*kPrefValueHomePage*/ 0); - pref_service_->SetString(prefs::kHomePage, "http://chromium.org/"); - pref_service_->SetBoolean(prefs::kHomePageIsNewTabPage, true); - - SessionStartupPref pref = SessionStartupPref::GetStartupPref( - pref_service_.get()); - - EXPECT_EQ(SessionStartupPref::DEFAULT, pref.type); -} diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc index bbbf0c4fc624cf..346f47cf34405d 100644 --- a/chrome/browser/profile_resetter/profile_resetter.cc +++ b/chrome/browser/profile_resetter/profile_resetter.cc @@ -282,7 +282,6 @@ void ProfileResetter::ResetStartupPages() { else prefs->ClearPref(prefs::kRestoreOnStartup); - prefs->SetBoolean(prefs::kRestoreOnStartupMigrated, true); MarkAsDone(STARTUP_PAGES); } diff --git a/chrome/browser/sessions/restore_on_startup_policy_handler.cc b/chrome/browser/sessions/restore_on_startup_policy_handler.cc index 4e9a2d4eec1ea3..57c435aef2f969 100644 --- a/chrome/browser/sessions/restore_on_startup_policy_handler.cc +++ b/chrome/browser/sessions/restore_on_startup_policy_handler.cc @@ -32,45 +32,7 @@ void RestoreOnStartupPolicyHandler::ApplyPolicySettings( int restore_on_startup; if (!restore_on_startup_value->GetAsInteger(&restore_on_startup)) return; - - if (restore_on_startup == SessionStartupPref::kPrefValueHomePage) - ApplyPolicySettingsFromHomePage(policies, prefs); - else - prefs->SetInteger(prefs::kRestoreOnStartup, restore_on_startup); - } -} - -void RestoreOnStartupPolicyHandler::ApplyPolicySettingsFromHomePage( - const PolicyMap& policies, - PrefValueMap* prefs) { - const base::Value* homepage_is_new_tab_page_value = - policies.GetValue(key::kHomepageIsNewTabPage); - if (!homepage_is_new_tab_page_value) { - // The policy is enforcing 'open the homepage on startup' but not - // enforcing what the homepage should be. Don't set any prefs. - return; - } - - bool homepage_is_new_tab_page; - if (!homepage_is_new_tab_page_value->GetAsBoolean(&homepage_is_new_tab_page)) - return; - - if (homepage_is_new_tab_page) { - prefs->SetInteger(prefs::kRestoreOnStartup, - SessionStartupPref::kPrefValueNewTab); - } else { - const base::Value* homepage_value = - policies.GetValue(key::kHomepageLocation); - if (!homepage_value || !homepage_value->IsType(base::Value::TYPE_STRING)) { - // The policy is enforcing 'open the homepage on startup' but not - // enforcing what the homepage should be. Don't set any prefs. - return; - } - scoped_ptr url_list(new base::ListValue()); - url_list->Append(homepage_value->CreateDeepCopy()); - prefs->SetInteger(prefs::kRestoreOnStartup, - SessionStartupPref::kPrefValueURLs); - prefs->SetValue(prefs::kURLsToRestoreOnStartup, url_list.Pass()); + prefs->SetInteger(prefs::kRestoreOnStartup, restore_on_startup); } } @@ -86,7 +48,7 @@ bool RestoreOnStartupPolicyHandler::CheckPolicySettings( int restore_value; CHECK(restore_policy->GetAsInteger(&restore_value)); // Passed type check. switch (restore_value) { - case SessionStartupPref::kPrefValueHomePage: + case 0: // Deprecated kPrefValueHomePage. errors->AddError(policy_name(), IDS_POLICY_VALUE_DEPRECATED); break; case SessionStartupPref::kPrefValueLast: { diff --git a/chrome/browser/sessions/restore_on_startup_policy_handler.h b/chrome/browser/sessions/restore_on_startup_policy_handler.h index 3fea8069bdd3d1..adde95bfcd9029 100644 --- a/chrome/browser/sessions/restore_on_startup_policy_handler.h +++ b/chrome/browser/sessions/restore_on_startup_policy_handler.h @@ -27,9 +27,6 @@ class RestoreOnStartupPolicyHandler : public TypeCheckingPolicyHandler { PrefValueMap* prefs) override; private: - void ApplyPolicySettingsFromHomePage(const PolicyMap& policies, - PrefValueMap* prefs); - DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupPolicyHandler); }; diff --git a/chrome/browser/sessions/restore_on_startup_policy_handler_unittest.cc b/chrome/browser/sessions/restore_on_startup_policy_handler_unittest.cc index 0c35d581bd1d7f..63e94c2478963f 100644 --- a/chrome/browser/sessions/restore_on_startup_policy_handler_unittest.cc +++ b/chrome/browser/sessions/restore_on_startup_policy_handler_unittest.cc @@ -70,8 +70,7 @@ TEST_F(RestoreOnStartupPolicyHandlerTest, CheckPolicySettings_Unspecified) { TEST_F(RestoreOnStartupPolicyHandlerTest, CheckPolicySettings_UnknownValue) { // Specify an unknown value for the policy. - int impossible_value = SessionStartupPref::kPrefValueHomePage + - SessionStartupPref::kPrefValueLast + + int impossible_value = SessionStartupPref::kPrefValueLast + SessionStartupPref::kPrefValueURLs + SessionStartupPref::kPrefValueNewTab; SetPolicyValue(key::kRestoreOnStartup, @@ -89,7 +88,7 @@ TEST_F(RestoreOnStartupPolicyHandlerTest, CheckPolicySettings_HomePage) { // Specify the HomePage value. SetPolicyValue( key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); + new base::FundamentalValue(0)); // kPrefValueHomePage, deprecated. // Checking should succeed but add an error to the error map. EXPECT_TRUE(CheckPolicySettings()); EXPECT_EQ(1U, errors().size()); @@ -116,6 +115,18 @@ TEST_F(RestoreOnStartupPolicyHandlerTest, errors().begin()->second); } +TEST_F(RestoreOnStartupPolicyHandlerTest, ApplyPolicySettings_NotHomePage) { + // Specify anything except the HomePage value. + int not_home_page = 1; // kPrefValueHomePage + 1, deprecated. + SetPolicyValue(key::kRestoreOnStartup, + new base::FundamentalValue(not_home_page)); + ApplyPolicySettings(); + // The resulting prefs should have the value we specified. + int result; + EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); + EXPECT_EQ(not_home_page, result); +} + TEST_F(RestoreOnStartupPolicyHandlerTest, CheckPolicySettings_RestoreLastSession_ClearDataOnExit) { // Specify the Last value and the Clear-Data-On-Exit value. @@ -178,116 +189,4 @@ TEST_F(RestoreOnStartupPolicyHandlerTest, ApplyPolicySettings_WrongType) { EXPECT_TRUE(prefs().begin() == prefs().end()); } -TEST_F(RestoreOnStartupPolicyHandlerTest, ApplyPolicySettings_NotHomePage) { - // Specify anything except the HomePage value. - int not_home_page = SessionStartupPref::kPrefValueHomePage + 1; - SetPolicyValue(key::kRestoreOnStartup, - new base::FundamentalValue(not_home_page)); - ApplyPolicySettings(); - // The resulting prefs should have the value we specified. - int result; - EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); - EXPECT_EQ(not_home_page, result); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_NoHomePageValue) { - // Specify the HomePage value but no HomePageIsNewTabPage value. - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - ApplyPolicySettings(); - // The resulting prefs should be empty. - EXPECT_TRUE(prefs().begin() == prefs().end()); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_HomePageValueIsWrongType) { - // Specify the HomePage value and an integer for the home page value. - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - SetPolicyValue( - key::kHomepageIsNewTabPage, - new base::FundamentalValue(314159)); - ApplyPolicySettings(); - // The resulting prefs should be empty. - EXPECT_TRUE(prefs().begin() == prefs().end()); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_HomePageIsNewTabPage) { - // Specify the HomePage value and the home page as the new tab page. - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - SetPolicyValue( - key::kHomepageIsNewTabPage, - new base::FundamentalValue(true)); - ApplyPolicySettings(); - // The resulting prefs should have the restore value as NTP. - int result; - EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); - int expected = SessionStartupPref::kPrefValueNewTab; - EXPECT_EQ(expected, result); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_HomePageIsNotNewTabPage_NotDefined) { - // Specify the HomePage value but don't specify the home page to use. - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - SetPolicyValue( - key::kHomepageIsNewTabPage, - new base::FundamentalValue(false)); - ApplyPolicySettings(); - // The resulting prefs should be empty. - EXPECT_TRUE(prefs().begin() == prefs().end()); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_HomePageIsNotNewTabPage_WrongType) { - // Specify the HomePage value but specify a boolean as the home page. - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - SetPolicyValue( - key::kHomepageIsNewTabPage, - new base::FundamentalValue(false)); - SetPolicyValue( - key::kHomepageLocation, - new base::FundamentalValue(false)); - ApplyPolicySettings(); - // The resulting prefs should be empty. - EXPECT_TRUE(prefs().begin() == prefs().end()); -} - -TEST_F(RestoreOnStartupPolicyHandlerTest, - ApplyPolicySettings_HomePage_HomePageIsNotNewTabPage) { - SetPolicyValue( - key::kRestoreOnStartup, - new base::FundamentalValue(SessionStartupPref::kPrefValueHomePage)); - SetPolicyValue(key::kHomepageIsNewTabPage, new base::FundamentalValue(false)); - SetPolicyValue(key::kHomepageLocation, - new base::StringValue("http://foo.com")); - ApplyPolicySettings(); - - // The resulting prefs should have have URLs specified for startup. - int result; - EXPECT_TRUE(prefs().GetInteger(prefs::kRestoreOnStartup, &result)); - int expected = SessionStartupPref::kPrefValueURLs; - EXPECT_EQ(expected, result); - - // The resulting prefs should have the URL we specified as the home page. - base::Value* url_result; - EXPECT_TRUE(prefs().GetValue(prefs::kURLsToRestoreOnStartup, &url_result)); - base::ListValue* url_list_result; - EXPECT_TRUE(url_result->GetAsList(&url_list_result)); - EXPECT_EQ(1U, url_list_result->GetSize()); - std::string expected_url; - EXPECT_TRUE(url_list_result->GetString(0, &expected_url)); - EXPECT_EQ(std::string("http://foo.com"), expected_url); -} - } // namespace policy diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 98cb2c42790b45..f5ab94c1c41513 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -681,10 +681,6 @@ Browser* StartupBrowserCreatorImpl::ProcessSpecifiedURLs( // specified on the command line. Filter out any urls that are to be // restored by virtue of having been previously pinned. AddUniqueURLs(pref.urls, &tabs); - } else if (pref.type == SessionStartupPref::HOMEPAGE) { - // If 'homepage' selected, either by the user or by a policy, we should - // have migrated them to another value. - NOTREACHED() << "SessionStartupPref has deprecated type HOMEPAGE"; } if (tabs.empty()) diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 059c961582557b..111e4e041b8cc9 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -69,7 +69,7 @@ const char kSessionExitedCleanly[] = "profile.exited_cleanly"; const char kSessionExitType[] = "profile.exit_type"; // An integer pref. Holds one of several values: -// 0: (deprecated) open the homepage on startup. +// 0: unused, previously indicated to open the homepage on startup // 1: restore the last session. // 2: this was used to indicate a specific session should be restored. It is // no longer used, but saved to avoid conflict with old preferences. @@ -78,12 +78,6 @@ const char kSessionExitType[] = "profile.exit_type"; // 5: open the New Tab Page on startup. const char kRestoreOnStartup[] = "session.restore_on_startup"; -// A preference to keep track of whether we have already checked whether we -// need to migrate the user from kRestoreOnStartup=0 to kRestoreOnStartup=4. -// We only need to do this check once, on upgrade from m18 or lower to m19 or -// higher. -const char kRestoreOnStartupMigrated[] = "session.restore_on_startup_migrated"; - // The URLs to restore on startup or when the home button is pressed. The URLs // are only restored on startup if kRestoreOnStartup is 4. const char kURLsToRestoreOnStartup[] = "session.startup_urls"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index c59cbb488f852e..729f37fe50606b 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -29,7 +29,6 @@ extern const char kLastProfileResetTimestamp[]; #endif extern const char kProfileIconVersion[]; extern const char kRestoreOnStartup[]; -extern const char kRestoreOnStartupMigrated[]; extern const char kSessionExitedCleanly[]; extern const char kSessionExitType[]; extern const char kSupervisedUserCustodianEmail[];