diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 3 | ||||
-rw-r--r-- | chrome/browser/browser_url_handler.cc | 12 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui_uitest.cc | 23 |
3 files changed, 36 insertions, 2 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 4343eec..1f6ef98 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1296,7 +1296,8 @@ void Browser::RegisterPrefs(PrefService* prefs) { // static void Browser::RegisterUserPrefs(PrefService* prefs) { - prefs->RegisterStringPref(prefs::kHomePage, L"chrome-internal:"); + prefs->RegisterStringPref(prefs::kHomePage, + ASCIIToWide(chrome::kChromeUINewTabURL)); prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true); prefs->RegisterIntegerPref(prefs::kCookieBehavior, net::CookiePolicy::ALLOW_ALL_COOKIES); diff --git a/chrome/browser/browser_url_handler.cc b/chrome/browser/browser_url_handler.cc index 17f6fda..a8a96e2 100644 --- a/chrome/browser/browser_url_handler.cc +++ b/chrome/browser/browser_url_handler.cc @@ -43,10 +43,20 @@ static bool HandleViewSource(GURL* url, Profile* profile) { return false; } -// Handles URLs for DOM UI. These URLs need no rewriting. +// Handles rewriting DOM UI URLs. static bool HandleDOMUI(GURL* url, Profile* profile) { if (!DOMUIFactory::UseDOMUIForURL(*url)) return false; + + // Special case the new tab page. In older versions of Chrome, the new tab + // page was hosted at chrome-internal:<blah>. This might be in people's saved + // sessions or bookmarks, so we say any URL with that scheme triggers the new + // tab page. + if (url->SchemeIs(chrome::kChromeInternalScheme)) { + // Rewrite it with the proper new tab URL. + *url = GURL(chrome::kChromeUINewTabURL); + } + return true; } diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc index 83a5ef7..14cda31 100644 --- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc +++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc @@ -59,6 +59,29 @@ TEST_F(NewTabUITest, NTPHasThumbnails) { EXPECT_EQ(0, filler_thumbnails_count); } +TEST_F(NewTabUITest, ChromeInternalLoadsNTP) { + scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); + + int tab_count = -1; + ASSERT_TRUE(window->GetTabCount(&tab_count)); + ASSERT_EQ(1, tab_count); + + // Go to the "new tab page" using its old url, rather than chrome://newtab. + scoped_refptr<TabProxy> tab = window->GetTab(0); + tab->NavigateToURLAsync(GURL("chrome-internal:")); + int load_time; + ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); + + // Ensure there are some thumbnails loaded in the page. + int thumbnails_count = -1; + ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", + L"window.domAutomationController.send(" + L"document.getElementsByClassName('thumbnail-container').length)", + &thumbnails_count)); + EXPECT_GT(thumbnails_count, 0); +} + TEST_F(NewTabUITest, UpdateUserPrefsVersion) { PrefService prefs((FilePath())); |