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

Unified Diff: chrome/browser/omnibox/omnibox_field_trial.cc

Issue 22354006: Omnibox: Convert Shortcuts Scoring Field Trial to Omnibox Bundled Field Trial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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
Index: chrome/browser/omnibox/omnibox_field_trial.cc
diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc
index 5f3457b8c0c7a1f657914f9b758c3bab5619a327..ffd2f72a2f510dbc6cba5b98eea967a955fdba41 100644
--- a/chrome/browser/omnibox/omnibox_field_trial.cc
+++ b/chrome/browser/omnibox/omnibox_field_trial.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/search/search.h"
#include "chrome/common/metrics/metrics_util.h"
#include "chrome/common/metrics/variations/variation_ids.h"
@@ -23,10 +24,10 @@ const char kHUPCullRedirectsFieldTrialName[] = "OmniboxHUPCullRedirects";
const char kHUPCreateShorterMatchFieldTrialName[] =
"OmniboxHUPCreateShorterMatch";
const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
-const char kShortcutsScoringFieldTrialName[] = "OmniboxShortcutsScoring";
const char kBundledExperimentFieldTrialName[] = "OmniboxBundledExperimentV1";
// Rule names used by the bundled experiment.
+const char kShortcutsScoringMaxRelevanceRule[] = "ShortcutsScoringMaxRelevance";
const char kSearchHistoryRule[] = "SearchHistory";
const char kDemoteByTypeRule[] = "DemoteByType";
@@ -135,14 +136,9 @@ int OmniboxFieldTrial::GetDisabledProviderTypes() {
continue;
int types = 0;
if (!base::StringToInt(base::StringPiece(
- group_name.substr(strlen(kDisabledProviders))), &types)) {
- LOG(WARNING) << "Malformed DisabledProviders string: " << group_name;
+ group_name.substr(strlen(kDisabledProviders))), &types))
continue;
- }
- if (types == 0)
- LOG(WARNING) << "Expecting a non-zero bitmap; group = " << group_name;
- else
- provider_types |= types;
+ provider_types |= types;
}
return provider_types;
}
@@ -207,20 +203,18 @@ bool OmniboxFieldTrial::InZeroSuggestFieldTrial() {
return false;
}
-// If the active group name starts with "MaxRelevance_", extract the
-// int that immediately following that, returning true on success.
-bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(int* max_relevance) {
- std::string group_name =
- base::FieldTrialList::FindFullName(kShortcutsScoringFieldTrialName);
- const char kMaxRelevanceGroupPrefix[] = "MaxRelevance_";
- if (!StartsWithASCII(group_name, kMaxRelevanceGroupPrefix, true))
+bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
+ AutocompleteInput::PageClassification current_page_classification,
+ int* max_relevance) {
+ // The value of the rule is a string that encodes an integer containing
+ // the max relevance.
+ const std::string& max_relevance_str =
+ OmniboxFieldTrial::GetValueForRuleInContext(
+ kShortcutsScoringMaxRelevanceRule, current_page_classification);
+ if (max_relevance_str.empty())
return false;
- if (!base::StringToInt(base::StringPiece(
- group_name.substr(strlen(kMaxRelevanceGroupPrefix))),
- max_relevance)) {
- LOG(WARNING) << "Malformed MaxRelevance string: " << group_name;
+ if (!base::StringToInt(max_relevance_str, max_relevance))
return false;
- }
return true;
}
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.h ('k') | chrome/browser/omnibox/omnibox_field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698