Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(975)

Unified Diff: chrome/browser/search/search.cc

Issue 23522025: InstantExtended: add a finch flag to disable Instant Extended on SRP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/search.cc
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index de725fb1938d464e478e1fc21ad65700beb0032e..1dcc72fdc5c0810c34f74afc233d53ddccadca95 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -64,6 +64,7 @@ const char kShowNtpFlagName[] = "show_ntp";
const char kRecentTabsOnNTPFlagName[] = "show_recent_tabs";
const char kUseCacheableNTP[] = "use_cacheable_ntp";
const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp";
+const char kSuppressInstantExtendedOnSRPFlagName[] = "suppress_on_srp";
// Constants for the field trial name and group prefix.
const char kInstantExtendedFieldTrialName[] = "InstantExtended";
@@ -230,9 +231,14 @@ bool IsInstantURL(const GURL& url, Profile* profile) {
const TemplateURLRef& instant_url_ref = template_url->instant_url_ref();
const GURL instant_url =
TemplateURLRefToGURL(instant_url_ref, kDisableStartMargin, false);
- return instant_url.is_valid() &&
- (MatchesOriginAndPath(url, instant_url) ||
- MatchesAnySearchURL(url, template_url));
+ if (!instant_url.is_valid())
+ return false;
+
+ if (MatchesOriginAndPath(url, instant_url))
+ return true;
+
+ return !ShouldSuppressInstantExtendedOnSRP() &&
+ MatchesAnySearchURL(url, template_url);
}
string16 GetSearchTermsImpl(const content::WebContents* contents,
@@ -273,10 +279,8 @@ bool IsInstantExtendedAPIEnabled() {
#if defined(OS_IOS) || defined(OS_ANDROID)
return false;
#else
- // On desktop, query extraction is part of Instant extended, so if one is
- // enabled, the other is too.
RecordInstantExtendedOptInState();
- return IsQueryExtractionEnabled();
+ return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled;
#endif // defined(OS_IOS) || defined(OS_ANDROID)
}
@@ -311,7 +315,8 @@ uint64 EmbeddedSearchPageVersion() {
}
bool IsQueryExtractionEnabled() {
- return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled;
+ return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled &&
+ !ShouldSuppressInstantExtendedOnSRP();
}
string16 GetSearchTermsFromURL(Profile* profile, const GURL& url) {
@@ -508,6 +513,18 @@ bool ShouldShowRecentTabsOnNTP() {
return false;
}
+bool ShouldSuppressInstantExtendedOnSRP() {
+ FieldTrialFlags flags;
+ if (GetFieldTrialInfo(
+ base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName),
+ &flags, NULL)) {
+ return GetBoolValueForFlagWithDefault(
+ kSuppressInstantExtendedOnSRPFlagName, false, flags);
+ }
+
+ return false;
+}
+
bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) {
return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path();
}
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698