diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 23:14:48 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 23:14:48 +0000 |
commit | 5df96abc073fbdcf391dca744947620a9a819922 (patch) | |
tree | b695fbaeb527b2aafd8b57b710ddba3c61a400f5 /chrome/browser/ui | |
parent | 380de766e86b66047267742f09b962520310d5ef (diff) | |
download | chromium_src-5df96abc073fbdcf391dca744947620a9a819922.zip chromium_src-5df96abc073fbdcf391dca744947620a9a819922.tar.gz chromium_src-5df96abc073fbdcf391dca744947620a9a819922.tar.bz2 |
Reload Local NTP on default search provider change.
Based on the default search provider setting, LocalNTPSource will set the local NTP JS state to render Google logo and fakebox in local NTP. We no longer append "?isGoogle" in local NTP url if the search provider is Google. Local NTP url will remain the same irrespective of the default search provider setting.
BUG=222183,235282
TEST=none
Review URL: https://chromiumcodereview.appspot.com/19054012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/browser_instant_controller.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/search/instant_extended_interactive_uitest.cc | 173 | ||||
-rw-r--r-- | chrome/browser/ui/search/instant_page.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/search/instant_page_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/search/search_tab_helper.cc | 3 |
5 files changed, 115 insertions, 75 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index b1454e8..4adeb91 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -261,15 +261,6 @@ void BrowserInstantController::OnDefaultSearchProviderChanged( if (!contents) continue; - // A Local NTP always runs in the Instant process, so reloading it is - // neither useful nor necessary. However, the Local NTP does not reflect - // whether Google is the default search engine or not. This is achieved - // through a URL parameter, so reloading the existing URL won't fix that - // (i.e., the Local NTP may now show an incorrect search engine logo). - // TODO(kmadhusu): Fix. - if (contents->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl)) - continue; - if (!instant_service->IsInstantProcess( contents->GetRenderProcessHost()->GetID())) continue; diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc index 2c25a3e..f9f51f4 100644 --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc @@ -872,66 +872,6 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) { EXPECT_LT(0, on_esc_key_press_event_calls_); } -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { - InstantService* instant_service = - InstantServiceFactory::GetForProfile(browser()->profile()); - ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); - - // Setup Instant. - ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); - FocusOmniboxAndWaitForInstantNTPSupport(); - EXPECT_EQ(1, instant_service->GetInstantProcessCount()); - - // Navigating to the NTP should use the Instant render process. - ui_test_utils::NavigateToURLWithDisposition( - browser(), - GURL(chrome::kChromeUINewTabURL), - CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); - content::WebContents* ntp_contents = - browser()->tab_strip_model()->GetActiveWebContents(); - EXPECT_TRUE(chrome::IsInstantNTP(ntp_contents)); - EXPECT_TRUE(instant_service->IsInstantProcess( - ntp_contents->GetRenderProcessHost()->GetID())); - GURL ntp_url = ntp_contents->GetURL(); - - AddBlankTabAndShow(browser()); - content::WebContents* active_tab = - browser()->tab_strip_model()->GetActiveWebContents(); - EXPECT_FALSE(chrome::IsInstantNTP(active_tab)); - EXPECT_FALSE(instant_service->IsInstantProcess( - active_tab->GetRenderProcessHost()->GetID())); - - TemplateURLData data; - data.short_name = ASCIIToUTF16("t"); - data.SetURL("http://defaultturl/q={searchTerms}"); - data.suggestions_url = "http://defaultturl2/q={searchTerms}"; - data.instant_url = "http://does/not/exist"; - data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}"); - data.search_terms_replacement_key = "strk"; - - TemplateURL* template_url = new TemplateURL(browser()->profile(), data); - TemplateURLService* service = - TemplateURLServiceFactory::GetForProfile(browser()->profile()); - ui_test_utils::WaitForTemplateURLServiceToLoad(service); - service->Add(template_url); // Takes ownership of |template_url|. - - // Change the default search provider. - content::WindowedNotificationObserver observer( - content::NOTIFICATION_LOAD_STOP, - content::Source<content::NavigationController>( - &ntp_contents->GetController())); - service->SetDefaultSearchProvider(template_url); - observer.Wait(); - - // |ntp_contents| should not use the Instant render process. - EXPECT_FALSE(chrome::IsInstantNTP(ntp_contents)); - EXPECT_FALSE(instant_service->IsInstantProcess( - ntp_contents->GetRenderProcessHost()->GetID())); - // Make sure the URL remains the same. - EXPECT_EQ(ntp_url, ntp_contents->GetURL()); -} - // Test that renderer initiated navigations to an instant URL from a non // Instant page do not end up in an Instant process if they are bounced to the // browser. @@ -1740,3 +1680,116 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EXPECT_TRUE(UpdateSearchState(active_tab)); EXPECT_EQ(1, on_most_visited_change_calls_); } + +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { + InstantService* instant_service = + InstantServiceFactory::GetForProfile(browser()->profile()); + ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); + + // Setup Instant. + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); + FocusOmniboxAndWaitForInstantNTPSupport(); + EXPECT_EQ(1, instant_service->GetInstantProcessCount()); + + // Navigating to the NTP should use the Instant render process. + content::WindowedNotificationObserver new_tab_observer( + content::NOTIFICATION_NAV_ENTRY_COMMITTED, + content::NotificationService::AllSources()); + ui_test_utils::NavigateToURLWithDisposition( + browser(), + GURL(chrome::kChromeUINewTabURL), + CURRENT_TAB, + ui_test_utils::BROWSER_TEST_NONE); + new_tab_observer.Wait(); + + content::WebContents* ntp_contents = + browser()->tab_strip_model()->GetActiveWebContents(); + EXPECT_TRUE(chrome::IsInstantNTP(ntp_contents)); + EXPECT_TRUE(instant_service->IsInstantProcess( + ntp_contents->GetRenderProcessHost()->GetID())); + GURL ntp_url = ntp_contents->GetURL(); + + AddBlankTabAndShow(browser()); + content::WebContents* active_tab = + browser()->tab_strip_model()->GetActiveWebContents(); + EXPECT_FALSE(chrome::IsInstantNTP(active_tab)); + EXPECT_FALSE(instant_service->IsInstantProcess( + active_tab->GetRenderProcessHost()->GetID())); + + TemplateURLData data; + data.short_name = ASCIIToUTF16("t"); + data.SetURL("http://defaultturl/q={searchTerms}"); + data.suggestions_url = "http://defaultturl2/q={searchTerms}"; + data.instant_url = "http://does/not/exist"; + data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}"); + data.search_terms_replacement_key = "strk"; + + TemplateURL* template_url = new TemplateURL(browser()->profile(), data); + TemplateURLService* service = + TemplateURLServiceFactory::GetForProfile(browser()->profile()); + ui_test_utils::WaitForTemplateURLServiceToLoad(service); + service->Add(template_url); // Takes ownership of |template_url|. + + // Change the default search provider. + content::WindowedNotificationObserver observer( + content::NOTIFICATION_LOAD_STOP, + content::Source<content::NavigationController>( + &ntp_contents->GetController())); + service->SetDefaultSearchProvider(template_url); + observer.Wait(); + + // |ntp_contents| should not use the Instant render process. + EXPECT_FALSE(chrome::IsInstantNTP(ntp_contents)); + EXPECT_FALSE(instant_service->IsInstantProcess( + ntp_contents->GetRenderProcessHost()->GetID())); + // Make sure the URL remains the same. + EXPECT_EQ(ntp_url, ntp_contents->GetURL()); +} + +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, + ReloadLocalNTPOnSearchProviderChange) { + // Setup Instant. + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); + FocusOmniboxAndWaitForInstantNTPSupport(); + + // Navigate to Local NTP. + content::WindowedNotificationObserver new_tab_observer( + content::NOTIFICATION_NAV_ENTRY_COMMITTED, + content::NotificationService::AllSources()); + ui_test_utils::NavigateToURLWithDisposition( + browser(), + GURL(chrome::kChromeSearchLocalNtpUrl), + CURRENT_TAB, + ui_test_utils::BROWSER_TEST_NONE); + new_tab_observer.Wait(); + + content::WebContents* ntp_contents = + browser()->tab_strip_model()->GetActiveWebContents(); + GURL ntp_url = ntp_contents->GetURL(); + + TemplateURLData data; + data.short_name = ASCIIToUTF16("t"); + data.SetURL("http://defaultturl/q={searchTerms}"); + data.suggestions_url = "http://defaultturl2/q={searchTerms}"; + data.instant_url = "http://does/not/exist"; + data.alternate_urls.push_back(data.instant_url + "#q={searchTerms}"); + data.search_terms_replacement_key = "strk"; + + TemplateURL* template_url = new TemplateURL(browser()->profile(), data); + TemplateURLService* service = + TemplateURLServiceFactory::GetForProfile(browser()->profile()); + ui_test_utils::WaitForTemplateURLServiceToLoad(service); + service->Add(template_url); // Takes ownership of |template_url|. + + // Change the default search provider. This will reload the local NTP and the + // page URL will remain the same. + content::WindowedNotificationObserver observer( + content::NOTIFICATION_LOAD_STOP, + content::Source<content::NavigationController>( + &ntp_contents->GetController())); + service->SetDefaultSearchProvider(template_url); + observer.Wait(); + + // Make sure the URL remains the same. + EXPECT_EQ(ntp_url, ntp_contents->GetURL()); +} diff --git a/chrome/browser/ui/search/instant_page.cc b/chrome/browser/ui/search/instant_page.cc index cfa47ad..39fc72c 100644 --- a/chrome/browser/ui/search/instant_page.cc +++ b/chrome/browser/ui/search/instant_page.cc @@ -39,8 +39,7 @@ const std::string& InstantPage::instant_url() const { bool InstantPage::IsLocal() const { return contents() && - (contents()->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl) || - contents()->GetURL() == GURL(chrome::kChromeSearchLocalGoogleNtpUrl)); + contents()->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl); } void InstantPage::InitializeFonts() { diff --git a/chrome/browser/ui/search/instant_page_unittest.cc b/chrome/browser/ui/search/instant_page_unittest.cc index effa9c6..e16c96d 100644 --- a/chrome/browser/ui/search/instant_page_unittest.cc +++ b/chrome/browser/ui/search/instant_page_unittest.cc @@ -129,8 +129,6 @@ TEST_F(InstantPageTest, IsLocal) { EXPECT_TRUE(page->IsLocal()); NavigateAndCommit(GURL("http://example.com")); EXPECT_FALSE(page->IsLocal()); - NavigateAndCommit(GURL(chrome::kChromeSearchLocalGoogleNtpUrl)); - EXPECT_TRUE(page->IsLocal()); } TEST_F(InstantPageTest, DetermineIfPageSupportsInstant_Local) { diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc index c81a1c8..281667f 100644 --- a/chrome/browser/ui/search/search_tab_helper.cc +++ b/chrome/browser/ui/search/search_tab_helper.cc @@ -40,8 +40,7 @@ bool IsSearchResults(const content::WebContents* contents) { // namespace and remove InstantPage::IsLocal(). bool IsLocal(const content::WebContents* contents) { return contents && - (contents->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl) || - contents->GetURL() == GURL(chrome::kChromeSearchLocalGoogleNtpUrl)); + contents->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl); } } // namespace |