Commit c9f92120 authored by samarth@chromium.org's avatar samarth@chromium.org

InstantExtended: assign all cacheable NTPs to the same process.

BUG=333397

Review URL: https://codereview.chromium.org/135383002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251537 0039d316-1c4b-4281-b951-d872f2087c98
parent 07e5563f
...@@ -453,7 +453,7 @@ bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { ...@@ -453,7 +453,7 @@ bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) { bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) {
return ShouldAssignURLToInstantRenderer(url, profile) && return ShouldAssignURLToInstantRenderer(url, profile) &&
(url.host() == chrome::kChromeSearchLocalNtpHost || (url.host() == chrome::kChromeSearchLocalNtpHost ||
url.host() == chrome::kChromeSearchOnlineNtpHost); url.host() == chrome::kChromeSearchRemoteNtpHost);
} }
bool IsNTPURL(const GURL& url, Profile* profile) { bool IsNTPURL(const GURL& url, Profile* profile) {
...@@ -684,18 +684,14 @@ GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { ...@@ -684,18 +684,14 @@ GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
replacements.SetScheme(search_scheme.data(), replacements.SetScheme(search_scheme.data(),
url_parse::Component(0, search_scheme.length())); url_parse::Component(0, search_scheme.length()));
// If the URL corresponds to an online NTP, replace the host with // If this is the URL for a server-provided NTP, replace the host with
// "online-ntp". // "remote-ntp".
std::string online_ntp_host(chrome::kChromeSearchOnlineNtpHost); std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost);
TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); NewTabURLDetails details = NewTabURLDetails::ForProfile(profile);
if (template_url) { if (details.state == NEW_TAB_URL_VALID &&
const GURL instant_url = TemplateURLRefToGURL( search::MatchesOriginAndPath(url, details.url)) {
template_url->instant_url_ref(), kDisableStartMargin, false, false); replacements.SetHost(remote_ntp_host.c_str(),
if (instant_url.is_valid() && url_parse::Component(0, remote_ntp_host.length()));
search::MatchesOriginAndPath(url, instant_url)) {
replacements.SetHost(online_ntp_host.c_str(),
url_parse::Component(0, online_ntp_host.length()));
}
} }
effective_url = effective_url.ReplaceComponents(replacements); effective_url = effective_url.ReplaceComponents(replacements);
......
...@@ -284,7 +284,7 @@ TEST_F(SearchTest, ShouldUseProcessPerSiteForInstantURL) { ...@@ -284,7 +284,7 @@ TEST_F(SearchTest, ShouldUseProcessPerSiteForInstantURL) {
const SearchTestCase kTestCases[] = { const SearchTestCase kTestCases[] = {
{"chrome-search://local-ntp", true, "Local NTP"}, {"chrome-search://local-ntp", true, "Local NTP"},
{"chrome-search://online-ntp", true, "Online NTP"}, {"chrome-search://remote-ntp", true, "Remote NTP"},
{"invalid-scheme://local-ntp", false, "Invalid Local NTP URL"}, {"invalid-scheme://local-ntp", false, "Invalid Local NTP URL"},
{"invalid-scheme://online-ntp", false, "Invalid Online NTP URL"}, {"invalid-scheme://online-ntp", false, "Invalid Online NTP URL"},
{"chrome-search://foo.com", false, "Search result page"}, {"chrome-search://foo.com", false, "Search result page"},
...@@ -327,10 +327,10 @@ const struct ProcessIsolationTestCase { ...@@ -327,10 +327,10 @@ const struct ProcessIsolationTestCase {
"chrome-search://local-ntp", true, "chrome-search://local-ntp", true,
"https://foo.com/other", false, false }, "https://foo.com/other", false, false },
{"Remote NTP -> SRP", {"Remote NTP -> SRP",
"https://foo.com/instant?strk", true, "https://foo.com/newtab?strk", true,
"https://foo.com/url?strk", true, false }, "https://foo.com/url?strk", true, false },
{"Remote NTP -> Regular", {"Remote NTP -> Regular",
"https://foo.com/instant?strk", true, "https://foo.com/newtab?strk", true,
"https://foo.com/other", false, false }, "https://foo.com/other", false, false },
{"SRP -> SRP", {"SRP -> SRP",
"https://foo.com/url?strk", true, "https://foo.com/url?strk", true,
......
...@@ -665,7 +665,7 @@ const char kChromeSearchScheme[] = "chrome-search"; ...@@ -665,7 +665,7 @@ const char kChromeSearchScheme[] = "chrome-search";
const char kChromeSearchLocalNtpHost[] = "local-ntp"; const char kChromeSearchLocalNtpHost[] = "local-ntp";
const char kChromeSearchLocalNtpUrl[] = const char kChromeSearchLocalNtpUrl[] =
"chrome-search://local-ntp/local-ntp.html"; "chrome-search://local-ntp/local-ntp.html";
const char kChromeSearchOnlineNtpHost[] = "online-ntp"; const char kChromeSearchRemoteNtpHost[] = "remote-ntp";
const char kChromeSearchMostVisitedHost[] = "most-visited"; const char kChromeSearchMostVisitedHost[] = "most-visited";
const char kChromeSearchMostVisitedUrl[] = "chrome-search://most-visited/"; const char kChromeSearchMostVisitedUrl[] = "chrome-search://most-visited/";
......
...@@ -491,7 +491,7 @@ extern const char kChromeSearchScheme[]; ...@@ -491,7 +491,7 @@ extern const char kChromeSearchScheme[];
// Pages under chrome-search. // Pages under chrome-search.
extern const char kChromeSearchLocalNtpHost[]; extern const char kChromeSearchLocalNtpHost[];
extern const char kChromeSearchLocalNtpUrl[]; extern const char kChromeSearchLocalNtpUrl[];
extern const char kChromeSearchOnlineNtpHost[]; extern const char kChromeSearchRemoteNtpHost[];
// Host and URL for most visited iframes used on the Instant Extended NTP. // Host and URL for most visited iframes used on the Instant Extended NTP.
extern const char kChromeSearchMostVisitedHost[]; extern const char kChromeSearchMostVisitedHost[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment