summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_content_browser_client_browsertest.cc
diff options
context:
space:
mode:
authorjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 17:44:16 +0000
committerjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 17:44:16 +0000
commit2767c0fdebbc6b0ee7220fbf4037203cea3ed359 (patch)
tree4e3cbfea5fcb5d56e137f669c77f345625da7aea /chrome/browser/chrome_content_browser_client_browsertest.cc
parentae53a23359accf0792d0a2d7f97d4c986548bb8b (diff)
downloadchromium_src-2767c0fdebbc6b0ee7220fbf4037203cea3ed359.zip
chromium_src-2767c0fdebbc6b0ee7220fbf4037203cea3ed359.tar.gz
chromium_src-2767c0fdebbc6b0ee7220fbf4037203cea3ed359.tar.bz2
InstantExtended: Add new_tab_url to TemplateURL.
Prepopulated engines may have an associated new tab page. Previously we were just assuming this was instant_url with no path, but with our new cacheable ntp this is no longer correct. Add a new new_tab_url field and explicitly use that instead when the cacheable ntp is being used. Also replace the --instant-new-tab-url command-line flag with a field trial specifying to use the cacheable ntp. BUG=271084,271087 R=pkasting@chromium.org, samarth@chromium.org Review URL: https://codereview.chromium.org/22945004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_content_browser_client_browsertest.cc')
-rw-r--r--chrome/browser/chrome_content_browser_client_browsertest.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/chrome/browser/chrome_content_browser_client_browsertest.cc b/chrome/browser/chrome_content_browser_client_browsertest.cc
index 9d4b494..46e9072 100644
--- a/chrome/browser/chrome_content_browser_client_browsertest.cc
+++ b/chrome/browser/chrome_content_browser_client_browsertest.cc
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
#include "chrome/browser/search/search.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
@@ -25,6 +28,20 @@ class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
return browser()->tab_strip_model()->GetWebContentsAt(0)->
GetController().GetLastCommittedEntry();
}
+
+ void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) {
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(browser()->profile());
+ ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
+
+ TemplateURLData data;
+ data.SetURL("http://foo.com/url?bar={searchTerms}");
+ data.new_tab_url = new_tab_page_url.spec();
+ TemplateURL* template_url = new TemplateURL(browser()->profile(), data);
+ // Takes ownership.
+ template_url_service->Add(template_url);
+ template_url_service->SetDefaultSearchProvider(template_url);
+ }
};
IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
@@ -81,8 +98,9 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
UberURLHandler_InstantExtendedNewTabPage) {
const GURL url_original("chrome://newtab");
const GURL url_rewritten("http://example.com/newtab");
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kInstantNewTabURL, url_rewritten.spec());
+ InstallTemplateURLWithNewTabPage(url_rewritten);
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
+ "Group1 use_cacheable_ntp:1"));
chrome::EnableInstantExtendedAPIForTesting();
ui_test_utils::NavigateToURL(browser(), url_original);
@@ -97,8 +115,10 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
UberURLHandler_InstantExtendedNewTabPageDisabled) {
const GURL url_original("chrome://newtab");
const GURL url_rewritten("http://example.com/newtab");
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kInstantNewTabURL, url_rewritten.spec());
+ InstallTemplateURLWithNewTabPage(url_rewritten);
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended",
+ "Group1 use_cacheable_ntp:1"));
+ chrome::DisableInstantExtendedAPIForTesting();
ui_test_utils::NavigateToURL(browser(), url_original);
NavigationEntry* entry = GetLastCommittedEntry();