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

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

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month 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 e679f1013197b640e42116560695ba40eb344fe6..4c9507dd92c5132135fa8e01527288c58afbd356 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
-#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
@@ -53,7 +52,6 @@ namespace {
// The first token is always GroupN for some integer N, followed by a
// space-delimited list of key:value pairs which correspond to these flags:
const char kEmbeddedPageVersionFlagName[] = "espv";
-const uint64 kEmbeddedPageVersionDisabled = 0;
#if defined(OS_IOS) || defined(OS_ANDROID)
const uint64 kEmbeddedPageVersionDefault = 1;
#else
@@ -71,9 +69,11 @@ const char kRecentTabsOnNTPFlagName[] = "show_recent_tabs";
const char kUseCacheableNTP[] = "use_cacheable_ntp";
const char kPrefetchSearchResultsFlagName[] = "prefetch_results";
const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp";
-const char kSuppressInstantExtendedOnSRPFlagName[] = "suppress_on_srp";
const char kDisplaySearchButtonFlagName[] = "display_search_button";
const char kEnableOriginChipFlagName[] = "origin_chip";
+#if !defined(OS_IOS) && !defined(OS_ANDROID)
+const char kEnableQueryExtractionFlagName[] = "query_extraction";
+#endif
// Constants for the field trial name and group prefix.
// Note in M30 and below this field trial was named "InstantExtended" and in
@@ -84,15 +84,11 @@ const char kEnableOriginChipFlagName[] = "origin_chip";
// channel.
const char kInstantExtendedFieldTrialName[] = "InstantExtended";
const char kEmbeddedSearchFieldTrialName[] = "EmbeddedSearch";
-const char kGroupNumberPrefix[] = "Group";
// If the field trial's group name ends with this string its configuration will
// be ignored and Instant Extended will not be enabled by default.
const char kDisablingSuffix[] = "DISABLED";
-// Remember if we reported metrics about opt-in/out state.
-bool instant_extended_opt_in_state_gate = false;
-
// Used to set the Instant support state of the Navigation entry.
const char kInstantSupportStateKey[] = "instant_support_state";
@@ -161,22 +157,6 @@ bool MatchesAnySearchURL(const GURL& url, TemplateURL* template_url) {
return false;
}
-void RecordInstantExtendedOptInState() {
- if (instant_extended_opt_in_state_gate)
- return;
-
- instant_extended_opt_in_state_gate = true;
- OptInState state = INSTANT_EXTENDED_NOT_SET;
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI))
- state = INSTANT_EXTENDED_OPT_OUT;
- else if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI))
- state = INSTANT_EXTENDED_OPT_IN;
-
- UMA_HISTOGRAM_ENUMERATION("InstantExtended.NewOptInState", state,
- INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT);
-}
-
// Returns true if |contents| is rendered inside the Instant process for
// |profile|.
bool IsRenderedInInstantProcess(const content::WebContents* contents,
@@ -236,8 +216,7 @@ bool IsInstantURL(const GURL& url, Profile* profile) {
if (search::MatchesOriginAndPath(url, instant_url))
return true;
- return !ShouldSuppressInstantExtendedOnSRP() &&
- MatchesAnySearchURL(url, template_url);
+ return IsQueryExtractionEnabled() && MatchesAnySearchURL(url, template_url);
}
string16 GetSearchTermsImpl(const content::WebContents* contents,
@@ -292,42 +271,41 @@ bool IsInstantExtendedAPIEnabled() {
#if defined(OS_IOS) || defined(OS_ANDROID)
return false;
#else
- RecordInstantExtendedOptInState();
- return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled;
+ return true;
#endif // defined(OS_IOS) || defined(OS_ANDROID)
}
// Determine what embedded search page version to request from the user's
-// default search provider. If 0, the embedded search UI should not be enabled.
+// default search provider.
uint64 EmbeddedSearchPageVersion() {
- RecordInstantExtendedOptInState();
-
- // Check the command-line/about:flags setting first, which should have
- // precedence and allows the trial to not be reported (if it's never queried).
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI))
- return kEmbeddedPageVersionDisabled;
- if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) {
- // The user has set the about:flags switch to Enabled - give the default
- // UI version.
- return kEmbeddedPageVersionDefault;
- }
-
FieldTrialFlags flags;
- uint64 group_num = 0;
- if (GetFieldTrialInfo(&flags, &group_num)) {
- if (group_num == 0)
- return kEmbeddedPageVersionDisabled;
+ if (GetFieldTrialInfo(&flags)) {
return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName,
kEmbeddedPageVersionDefault,
flags);
}
- return kEmbeddedPageVersionDisabled;
+ return kEmbeddedPageVersionDefault;
}
bool IsQueryExtractionEnabled() {
- return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled &&
- !ShouldSuppressInstantExtendedOnSRP();
+#if defined(OS_IOS) || defined(OS_ANDROID)
+ return true;
+#else
+ if (!IsInstantExtendedAPIEnabled())
+ return false;
+
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableQueryExtraction))
+ return true;
+
+ FieldTrialFlags flags;
+ if (GetFieldTrialInfo(&flags)) {
+ return GetBoolValueForFlagWithDefault(
+ kEnableQueryExtractionFlagName, false, flags);
+ }
+
+ return false;
+#endif // defined(OS_IOS) || defined(OS_ANDROID)
}
string16 GetSearchTermsFromURL(Profile* profile, const GURL& url) {
@@ -510,7 +488,7 @@ bool ShouldPrefetchSearchResults() {
return false;
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kPrefetchSearchResultsFlagName, false, flags);
}
@@ -519,35 +497,21 @@ GURL GetLocalInstantURL(Profile* profile) {
}
bool ShouldPreferRemoteNTPOnStartup() {
- // Check the command-line/about:flags setting first, which should have
- // precedence and allows the trial to not be reported (if it's never queried).
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) ||
- command_line->HasSwitch(switches::kEnableLocalFirstLoadNTP)) {
- return false;
- }
- if (command_line->HasSwitch(switches::kDisableLocalFirstLoadNTP))
- return true;
-
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kUseRemoteNTPOnStartupFlagName, true, flags);
}
bool ShouldHideTopVerbatimMatch() {
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kHideVerbatimFlagName, false, flags);
}
bool ShouldUseCacheableNTP() {
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kUseCacheableNewTabPage))
- return true;
-
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
- kUseCacheableNTP, false, flags);
+ return !GetFieldTrialInfo(&flags) ||
+ GetBoolValueForFlagWithDefault(kUseCacheableNTP, true, flags);
}
bool ShouldShowInstantNTP() {
@@ -557,25 +521,19 @@ bool ShouldShowInstantNTP() {
return false;
FieldTrialFlags flags;
- return !GetFieldTrialInfo(&flags, NULL) ||
+ return !GetFieldTrialInfo(&flags) ||
GetBoolValueForFlagWithDefault(kShowNtpFlagName, true, flags);
}
bool ShouldShowRecentTabsOnNTP() {
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kRecentTabsOnNTPFlagName, false, flags);
}
-bool ShouldSuppressInstantExtendedOnSRP() {
- FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
- kSuppressInstantExtendedOnSRPFlagName, false, flags);
-}
-
DisplaySearchButtonConditions GetDisplaySearchButtonConditions() {
FieldTrialFlags flags;
- if (!GetFieldTrialInfo(&flags, NULL))
+ if (!GetFieldTrialInfo(&flags))
return DISPLAY_SEARCH_BUTTON_NEVER;
uint64 value =
GetUInt64ValueForFlagWithDefault(kDisplaySearchButtonFlagName, 0, flags);
@@ -586,7 +544,7 @@ DisplaySearchButtonConditions GetDisplaySearchButtonConditions() {
bool ShouldDisplayOriginChip() {
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kEnableOriginChipFlagName, false, flags);
}
@@ -626,7 +584,7 @@ GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
int GetInstantLoaderStalenessTimeoutSec() {
int timeout_sec = kStalePageTimeoutDefault;
FieldTrialFlags flags;
- if (GetFieldTrialInfo(&flags, NULL)) {
+ if (GetFieldTrialInfo(&flags)) {
timeout_sec = GetUInt64ValueForFlagWithDefault(kStalePageTimeoutFlagName,
kStalePageTimeoutDefault,
flags);
@@ -712,31 +670,17 @@ InstantSupportState GetInstantSupportStateFromNavigationEntry(
}
bool ShouldPrefetchSearchResultsOnSRP() {
- // Check the command-line/about:flags setting first, which should have
- // precedence and allows the trial to not be reported (if it's never queried).
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) ||
- command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) {
- return false;
- }
-
FieldTrialFlags flags;
- return GetFieldTrialInfo(&flags, NULL) && GetBoolValueForFlagWithDefault(
+ return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
kPrefetchSearchResultsOnSRP, false, flags);
}
-void EnableInstantExtendedAPIForTesting() {
- CommandLine* cl = CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kEnableInstantExtendedAPI);
-}
-
-void DisableInstantExtendedAPIForTesting() {
+void EnableQueryExtractionForTesting() {
CommandLine* cl = CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kDisableInstantExtendedAPI);
+ cl->AppendSwitch(switches::kEnableQueryExtraction);
}
-bool GetFieldTrialInfo(FieldTrialFlags* flags,
- uint64* group_number) {
+bool GetFieldTrialInfo(FieldTrialFlags* flags) {
// Get the group name. If the EmbeddedSearch trial doesn't exist, look for
// the older InstantExtended name.
std::string group_name = base::FieldTrialList::FindFullName(
@@ -749,10 +693,8 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags,
if (EndsWith(group_name, kDisablingSuffix, true))
return false;
- // We have a valid trial that isn't disabled.
- // First extract the flags.
+ // We have a valid trial that isn't disabled. Extract the flags.
std::string group_prefix(group_name);
-
size_t first_space = group_name.find(" ");
if (first_space != std::string::npos) {
// There is a flags section of the group name. Split that out and parse it.
@@ -765,20 +707,6 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags,
}
}
- // Now extract the group number, making sure we get a non-zero value.
- uint64 temp_group_number = 0;
- if (StartsWithASCII(group_name, kGroupNumberPrefix, true)) {
- std::string group_suffix = group_prefix.substr(strlen(kGroupNumberPrefix));
- if (!base::StringToUint64(group_suffix, &temp_group_number))
- return false;
- if (group_number)
- *group_number = temp_group_number;
- } else {
- // Instant Extended is not enabled.
- if (group_number)
- *group_number = 0;
- }
-
return true;
}
@@ -816,8 +744,4 @@ bool GetBoolValueForFlagWithDefault(const std::string& flag,
return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
}
-void ResetInstantExtendedOptInStateGateForTest() {
- instant_extended_opt_in_state_gate = false;
-}
-
} // namespace chrome
« 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