summaryrefslogtreecommitdiffstats
path: root/chrome/browser/omnibox
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/omnibox')
-rw-r--r--chrome/browser/omnibox/omnibox_field_trial.cc20
-rw-r--r--chrome/browser/omnibox/omnibox_field_trial.h16
-rw-r--r--chrome/browser/omnibox/omnibox_field_trial_unittest.cc62
-rw-r--r--chrome/browser/omnibox/omnibox_log.cc2
-rw-r--r--chrome/browser/omnibox/omnibox_log.h7
5 files changed, 58 insertions, 49 deletions
diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc
index 2edca38..0f5b67b 100644
--- a/chrome/browser/omnibox/omnibox_field_trial.cc
+++ b/chrome/browser/omnibox/omnibox_field_trial.cc
@@ -14,14 +14,16 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/search/search.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/variations/variation_ids.h"
+#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/variations/active_field_trials.h"
#include "components/variations/metrics_util.h"
#include "components/variations/variations_associated_data.h"
+using metrics::OmniboxEventProto;
+
namespace {
typedef std::map<std::string, std::string> VariationParams;
@@ -308,7 +310,7 @@ bool OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial() {
}
bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
- AutocompleteInput::PageClassification current_page_classification,
+ OmniboxEventProto::PageClassification current_page_classification,
int* max_relevance) {
// The value of the rule is a string that encodes an integer containing
// the max relevance.
@@ -323,19 +325,19 @@ bool OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
}
bool OmniboxFieldTrial::SearchHistoryPreventInlining(
- AutocompleteInput::PageClassification current_page_classification) {
+ OmniboxEventProto::PageClassification current_page_classification) {
return OmniboxFieldTrial::GetValueForRuleInContext(
kSearchHistoryRule, current_page_classification) == "PreventInlining";
}
bool OmniboxFieldTrial::SearchHistoryDisable(
- AutocompleteInput::PageClassification current_page_classification) {
+ OmniboxEventProto::PageClassification current_page_classification) {
return OmniboxFieldTrial::GetValueForRuleInContext(
kSearchHistoryRule, current_page_classification) == "Disable";
}
void OmniboxFieldTrial::GetDemotionsByType(
- AutocompleteInput::PageClassification current_page_classification,
+ OmniboxEventProto::PageClassification current_page_classification,
DemotionMultipliers* demotions_by_type) {
demotions_by_type->clear();
std::string demotion_rule = OmniboxFieldTrial::GetValueForRuleInContext(
@@ -345,7 +347,7 @@ void OmniboxFieldTrial::GetDemotionsByType(
// only for the fakebox-focus context.
if (demotion_rule.empty() &&
(current_page_classification ==
- AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS))
+ OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS))
demotion_rule = "1:61,2:61,3:61,4:61,12:61";
// The value of the DemoteByType rule is a comma-separated list of
@@ -484,12 +486,12 @@ const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] =
// (kBundledExperimentFieldTrialName), each experiment group comes with a
// list of parameters in the form:
// key=<Rule>:
-// <AutocompleteInput::PageClassification (as an int)>:
+// <OmniboxEventProto::PageClassification (as an int)>:
// <whether Instant Extended is enabled (as a 1 or 0)>
// (note that there are no linebreaks in keys; this format is for
// presentation only>
// value=<arbitrary string>
-// Both the AutocompleteInput::PageClassification and the Instant Extended
+// Both the OmniboxEventProto::PageClassification and the Instant Extended
// entries can be "*", which means this rule applies for all values of the
// matching portion of the context.
// One example parameter is
@@ -512,7 +514,7 @@ const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] =
// and failing that it returns the empty string.
std::string OmniboxFieldTrial::GetValueForRuleInContext(
const std::string& rule,
- AutocompleteInput::PageClassification page_classification) {
+ OmniboxEventProto::PageClassification page_classification) {
VariationParams params;
if (!chrome_variations::GetVariationParams(kBundledExperimentFieldTrialName,
&params)) {
diff --git a/chrome/browser/omnibox/omnibox_field_trial.h b/chrome/browser/omnibox/omnibox_field_trial.h
index f6599eaf..917608d 100644
--- a/chrome/browser/omnibox/omnibox_field_trial.h
+++ b/chrome/browser/omnibox/omnibox_field_trial.h
@@ -11,8 +11,8 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/common/autocomplete_match_type.h"
+#include "components/metrics/proto/omnibox_event.pb.h"
namespace base {
class TimeDelta;
@@ -190,7 +190,8 @@ class OmniboxFieldTrial {
// for non-inlineable results. Shortcuts results are not allowed to be
// inlined.)
static bool ShortcutsScoringMaxRelevance(
- AutocompleteInput::PageClassification current_page_classification,
+ metrics::OmniboxEventProto::PageClassification
+ current_page_classification,
int* max_relevance);
// ---------------------------------------------------------
@@ -201,13 +202,15 @@ class OmniboxFieldTrial {
// provided |current_page_classification| context, scores search history
// query suggestions less aggressively so that they don't inline.
static bool SearchHistoryPreventInlining(
- AutocompleteInput::PageClassification current_page_classification);
+ metrics::OmniboxEventProto::PageClassification
+ current_page_classification);
// Returns true if the user is in the experiment group that, given the
// provided |current_page_classification| context, disables all query
// suggestions from search history.
static bool SearchHistoryDisable(
- AutocompleteInput::PageClassification current_page_classification);
+ metrics::OmniboxEventProto::PageClassification
+ current_page_classification);
// ---------------------------------------------------------
// For the DemoteByType experiment that's part of the bundled omnibox field
@@ -219,7 +222,8 @@ class OmniboxFieldTrial {
// appropriately. Otherwise, sets |demotions_by_type| to its default
// value based on the context.
static void GetDemotionsByType(
- AutocompleteInput::PageClassification current_page_classification,
+ metrics::OmniboxEventProto::PageClassification
+ current_page_classification,
DemotionMultipliers* demotions_by_type);
// ---------------------------------------------------------
@@ -337,7 +341,7 @@ class OmniboxFieldTrial {
// interpret the value is left to the caller; this is rule-dependent.
static std::string GetValueForRuleInContext(
const std::string& rule,
- AutocompleteInput::PageClassification page_classification);
+ metrics::OmniboxEventProto::PageClassification page_classification);
DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial);
};
diff --git a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc
index 748ba84..32e43df 100644
--- a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc
+++ b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc
@@ -9,13 +9,15 @@
#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string16.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/search/search.h"
#include "chrome/common/chrome_switches.h"
+#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/variations/entropy_provider.h"
#include "components/variations/variations_associated_data.h"
#include "testing/gtest/include/gtest/gtest.h"
+using metrics::OmniboxEventProto;
+
class OmniboxFieldTrialTest : public testing::Test {
public:
OmniboxFieldTrialTest() {
@@ -52,7 +54,7 @@ class OmniboxFieldTrialTest : public testing::Test {
static void ExpectRuleValue(
const std::string& rule_value,
const std::string& rule,
- AutocompleteInput::PageClassification page_classification);
+ OmniboxEventProto::PageClassification page_classification);
private:
scoped_ptr<base::FieldTrialList> field_trial_list_;
@@ -75,7 +77,7 @@ void OmniboxFieldTrialTest::VerifyDemotion(
void OmniboxFieldTrialTest::ExpectRuleValue(
const std::string& rule_value,
const std::string& rule,
- AutocompleteInput::PageClassification page_classification) {
+ OmniboxEventProto::PageClassification page_classification) {
EXPECT_EQ(rule_value,
OmniboxFieldTrial::GetValueForRuleInContext(
rule, page_classification));
@@ -210,16 +212,16 @@ TEST_F(OmniboxFieldTrialTest, GetDemotionsByTypeWithFallback) {
OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
OmniboxFieldTrial::DemotionMultipliers demotions_by_type;
OmniboxFieldTrial::GetDemotionsByType(
- AutocompleteInput::NTP, &demotions_by_type);
+ OmniboxEventProto::NTP, &demotions_by_type);
ASSERT_EQ(2u, demotions_by_type.size());
VerifyDemotion(demotions_by_type, AutocompleteMatchType::HISTORY_URL, 0.5);
VerifyDemotion(demotions_by_type, AutocompleteMatchType::HISTORY_TITLE, 0.0);
OmniboxFieldTrial::GetDemotionsByType(
- AutocompleteInput::HOME_PAGE, &demotions_by_type);
+ OmniboxEventProto::HOME_PAGE, &demotions_by_type);
ASSERT_EQ(1u, demotions_by_type.size());
VerifyDemotion(demotions_by_type, AutocompleteMatchType::NAVSUGGEST, 1.0);
OmniboxFieldTrial::GetDemotionsByType(
- AutocompleteInput::BLANK, &demotions_by_type);
+ OmniboxEventProto::BLANK, &demotions_by_type);
ASSERT_EQ(1u, demotions_by_type.size());
VerifyDemotion(demotions_by_type, AutocompleteMatchType::HISTORY_URL, 0.25);
}
@@ -255,82 +257,82 @@ TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) {
// Tests with Instant Extended enabled.
// Tests for rule 1.
ExpectRuleValue("rule1-4-1-value",
- "rule1", AutocompleteInput::OTHER); // exact match
+ "rule1", OmniboxEventProto::OTHER); // exact match
ExpectRuleValue("rule1-*-1-value",
- "rule1", AutocompleteInput::BLANK); // partial fallback
+ "rule1", OmniboxEventProto::BLANK); // partial fallback
ExpectRuleValue("rule1-*-1-value",
"rule1",
- AutocompleteInput::NTP); // partial fallback
+ OmniboxEventProto::NTP); // partial fallback
// Tests for rule 2.
ExpectRuleValue("rule2-1-*-value",
"rule2",
- AutocompleteInput::NTP); // partial fallback
+ OmniboxEventProto::NTP); // partial fallback
ExpectRuleValue("rule2-*-*-value",
- "rule2", AutocompleteInput::OTHER); // global fallback
+ "rule2", OmniboxEventProto::OTHER); // global fallback
// Tests for rule 3.
ExpectRuleValue("rule3-*-*-value",
"rule3",
- AutocompleteInput::HOME_PAGE); // global fallback
+ OmniboxEventProto::HOME_PAGE); // global fallback
ExpectRuleValue("rule3-*-*-value",
"rule3",
- AutocompleteInput::OTHER); // global fallback
+ OmniboxEventProto::OTHER); // global fallback
// Tests for rule 4.
ExpectRuleValue("",
"rule4",
- AutocompleteInput::BLANK); // no global fallback
+ OmniboxEventProto::BLANK); // no global fallback
ExpectRuleValue("",
"rule4",
- AutocompleteInput::HOME_PAGE); // no global fallback
+ OmniboxEventProto::HOME_PAGE); // no global fallback
// Tests for rule 5 (a missing rule).
ExpectRuleValue("",
- "rule5", AutocompleteInput::OTHER); // no rule at all
+ "rule5", OmniboxEventProto::OTHER); // no rule at all
} else {
// Tests for rule 1.
ExpectRuleValue("rule1-1-0-value",
- "rule1", AutocompleteInput::NTP); // exact match
+ "rule1", OmniboxEventProto::NTP); // exact match
ExpectRuleValue("rule1-1-0-value",
- "rule1", AutocompleteInput::NTP); // exact match
+ "rule1", OmniboxEventProto::NTP); // exact match
ExpectRuleValue("rule1-*-*-value",
- "rule1", AutocompleteInput::BLANK); // fallback to global
+ "rule1", OmniboxEventProto::BLANK); // fallback to global
ExpectRuleValue("rule1-3-0-value",
"rule1",
- AutocompleteInput::HOME_PAGE); // exact match
+ OmniboxEventProto::HOME_PAGE); // exact match
ExpectRuleValue("rule1-4-*-value",
- "rule1", AutocompleteInput::OTHER); // partial fallback
+ "rule1", OmniboxEventProto::OTHER); // partial fallback
ExpectRuleValue("rule1-*-*-value",
"rule1",
- AutocompleteInput:: // fallback to global
+ OmniboxEventProto:: // fallback to global
SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT);
// Tests for rule 2.
ExpectRuleValue("rule2-*-0-value",
"rule2",
- AutocompleteInput::HOME_PAGE); // partial fallback
+ OmniboxEventProto::HOME_PAGE); // partial fallback
ExpectRuleValue("rule2-*-0-value",
- "rule2", AutocompleteInput::OTHER); // partial fallback
+ "rule2", OmniboxEventProto::OTHER); // partial fallback
// Tests for rule 3.
ExpectRuleValue("rule3-*-*-value",
"rule3",
- AutocompleteInput::HOME_PAGE); // fallback to global
+ OmniboxEventProto::HOME_PAGE); // fallback to global
ExpectRuleValue("rule3-*-*-value",
- "rule3", AutocompleteInput::OTHER); // fallback to global
+ "rule3", OmniboxEventProto::OTHER); // fallback to global
// Tests for rule 4.
ExpectRuleValue("",
- "rule4", AutocompleteInput::BLANK); // no global fallback
+ "rule4", OmniboxEventProto::BLANK); // no global fallback
ExpectRuleValue("",
"rule4",
- AutocompleteInput::HOME_PAGE); // no global fallback
+ OmniboxEventProto::HOME_PAGE); // no global fallback
ExpectRuleValue("rule4-4-0-value",
- "rule4", AutocompleteInput::OTHER); // exact match
+ "rule4", OmniboxEventProto::OTHER); // exact match
// Tests for rule 5 (a missing rule).
ExpectRuleValue("",
- "rule5", AutocompleteInput::OTHER); // no rule at all
+ "rule5", OmniboxEventProto::OTHER); // no rule at all
}
}
diff --git a/chrome/browser/omnibox/omnibox_log.cc b/chrome/browser/omnibox/omnibox_log.cc
index ef0a08d..90d4b7e 100644
--- a/chrome/browser/omnibox/omnibox_log.cc
+++ b/chrome/browser/omnibox/omnibox_log.cc
@@ -12,7 +12,7 @@ OmniboxLog::OmniboxLog(
size_t selected_index,
bool is_paste_and_go,
SessionID::id_type tab_id,
- AutocompleteInput::PageClassification current_page_classification,
+ metrics::OmniboxEventProto::PageClassification current_page_classification,
base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
size_t completed_length,
base::TimeDelta elapsed_time_since_last_change_to_default_match,
diff --git a/chrome/browser/omnibox/omnibox_log.h b/chrome/browser/omnibox/omnibox_log.h
index 3c641ce..1923695 100644
--- a/chrome/browser/omnibox/omnibox_log.h
+++ b/chrome/browser/omnibox/omnibox_log.h
@@ -9,9 +9,9 @@
#include "base/strings/string16.h"
#include "base/time/time.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/sessions/session_id.h"
+#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
class AutocompleteResult;
@@ -27,7 +27,8 @@ struct OmniboxLog {
size_t selected_index,
bool is_paste_and_go,
SessionID::id_type tab_id,
- AutocompleteInput::PageClassification current_page_classification,
+ metrics::OmniboxEventProto::PageClassification
+ current_page_classification,
base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
size_t completed_length,
base::TimeDelta elapsed_time_since_last_change_to_default_match,
@@ -61,7 +62,7 @@ struct OmniboxLog {
// The type of page (e.g., new tab page, regular web page) that the
// user was viewing before going somewhere with the omnibox.
- AutocompleteInput::PageClassification current_page_classification;
+ metrics::OmniboxEventProto::PageClassification current_page_classification;
// The amount of time since the user first began modifying the text
// in the omnibox. If at some point after modifying the text, the