Commit 7d467b79 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Remove more search/instant code on Android

This CL #ifdef's out a bunch of Instant-process-related functions in
chrome/search/search.h/cc on Android. This code was never used on
Android and doesn't make sense there; let's make that obvious.

Bug: 787830
Change-Id: I74d51009010df4633631102bacf051a5d1a52583
Reviewed-on: https://chromium-review.googlesource.com/803443
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarChris Pickel <sfiera@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521327}
parent c766b72c
......@@ -1151,12 +1151,14 @@ GURL ChromeContentBrowserClient::GetEffectiveURL(
if (!profile)
return url;
#if !defined(OS_ANDROID)
// If the input |url| should be assigned to the Instant renderer, make its
// effective URL distinct from other URLs on the search provider's domain.
// This needs to happen even if |url| corresponds to an isolated origin; see
// https://crbug.com/755595.
if (search::ShouldAssignURLToInstantRenderer(url, profile))
return search::GetEffectiveURLForInstant(url, profile);
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL(
......@@ -1177,8 +1179,10 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
if (!profile)
return false;
#if !defined(OS_ANDROID)
if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile))
return true;
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite(
......
......@@ -10,7 +10,6 @@
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
......@@ -222,14 +221,6 @@ struct NewTabURLDetails {
const NewTabURLState state;
};
} // namespace
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
return url.is_valid() && profile && IsInstantExtendedAPIEnabled() &&
(url.SchemeIs(chrome::kChromeSearchScheme) ||
IsNTPOrServiceWorkerURL(url, profile));
}
bool IsRenderedInInstantProcess(const content::WebContents* contents,
Profile* profile) {
#if defined(OS_ANDROID)
......@@ -249,11 +240,7 @@ bool IsRenderedInInstantProcess(const content::WebContents* contents,
#endif
}
bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) {
return ShouldAssignURLToInstantRenderer(url, profile) &&
(url.host_piece() == chrome::kChromeSearchLocalNtpHost ||
url.host_piece() == chrome::kChromeSearchRemoteNtpHost);
}
} // namespace
bool DefaultSearchProviderIsGoogle(Profile* profile) {
return DefaultSearchProviderIsGoogle(
......@@ -321,6 +308,20 @@ GURL GetNewTabPageURL(Profile* profile) {
return NewTabURLDetails::ForProfile(profile).url;
}
#if !defined(OS_ANDROID)
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
return url.is_valid() && profile && IsInstantExtendedAPIEnabled() &&
(url.SchemeIs(chrome::kChromeSearchScheme) ||
IsNTPOrServiceWorkerURL(url, profile));
}
bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) {
return ShouldAssignURLToInstantRenderer(url, profile) &&
(url.host_piece() == chrome::kChromeSearchLocalNtpHost ||
url.host_piece() == chrome::kChromeSearchRemoteNtpHost);
}
GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
CHECK(ShouldAssignURLToInstantRenderer(url, profile))
<< "Error granting Instant access.";
......@@ -388,4 +389,6 @@ bool HandleNewTabURLReverseRewrite(GURL* url,
return false;
}
#endif // !defined(OS_ANDROID)
} // namespace search
......@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SEARCH_SEARCH_H_
#define CHROME_BROWSER_SEARCH_SEARCH_H_
#include "build/build_config.h"
class GURL;
class Profile;
class TemplateURLService;
......@@ -24,17 +26,6 @@ enum CacheableNTPLoad {
CACHEABLE_NTP_LOAD_MAX = 2
};
// Returns true if |url| should be rendered in the Instant renderer process.
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile);
// Returns true if |contents| is rendered inside the Instant process for
// |profile|.
bool IsRenderedInInstantProcess(const content::WebContents* contents,
Profile* profile);
// Returns true if the Instant |url| should use process per site.
bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile);
// Returns whether Google is selected as the default search engine.
bool DefaultSearchProviderIsGoogle(Profile* profile);
bool DefaultSearchProviderIsGoogle(
......@@ -58,6 +49,16 @@ bool NavEntryIsInstantNTP(const content::WebContents* contents,
// in an Instant process.
bool IsInstantNTPURL(const GURL& url, Profile* profile);
// Returns the New Tab page URL for the given |profile|.
GURL GetNewTabPageURL(Profile* profile);
#if !defined(OS_ANDROID)
// Returns true if |url| should be rendered in the Instant renderer process.
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile);
// Returns true if the Instant |url| should use process per site.
bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile);
// Transforms the input |url| into its "effective URL". |url| must be an
// Instant URL, i.e. ShouldAssignURLToInstantRenderer must return true. The
......@@ -89,8 +90,7 @@ bool HandleNewTabURLRewrite(GURL* url,
bool HandleNewTabURLReverseRewrite(GURL* url,
content::BrowserContext* browser_context);
// Returns the New Tab page URL for the given |profile|.
GURL GetNewTabPageURL(Profile* profile);
#endif // !defined(OS_ANDROID)
} // namespace search
......
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