diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 16:56:03 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 16:56:03 +0000 |
commit | 332d17d2d2889750fd87da90c2d9a796163e981c (patch) | |
tree | 584667b51d7aa63b058606adc8027946ead2046f /chrome/browser/autocomplete | |
parent | ac8a16bc1ec072211e6e24a781d0bfd19c6ad9b8 (diff) | |
download | chromium_src-332d17d2d2889750fd87da90c2d9a796163e981c.zip chromium_src-332d17d2d2889750fd87da90c2d9a796163e981c.tar.gz chromium_src-332d17d2d2889750fd87da90c2d9a796163e981c.tar.bz2 |
Remove AutocompleteInput Type and PageClassification.
They are just as same as the enums defined in .proto files. Removing
the declaration of these types reduces unnecessary code dependency
to autocomplete.
BUG=384232
R=blundell@chromium.org, mpearson@chromium.org, pkasting@chromium.org
TBR=brettw@chromium.org, cpu@chromium.org, miguelg@chromium.org, mpcomplete@chromium.org
TEST=compile succeeds
Review URL: https://codereview.chromium.org/343523003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
25 files changed, 160 insertions, 170 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index 77fd3c5..a9b8ffd 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -30,6 +30,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "testing/gtest/include/gtest/gtest.h" @@ -138,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) { omnibox_view->model()->SetInputInProgress(true); autocomplete_controller->Start(AutocompleteInput( base::ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), - GURL(), AutocompleteInput::NTP, true, false, true, false)); + GURL(), metrics::OmniboxEventProto::NTP, true, false, true, false)); EXPECT_TRUE(autocomplete_controller->done()); EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); diff --git a/chrome/browser/autocomplete/autocomplete_classifier.cc b/chrome/browser/autocomplete/autocomplete_classifier.cc index 4f49844..746ae0b 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.cc +++ b/chrome/browser/autocomplete/autocomplete_classifier.cc @@ -9,6 +9,7 @@ #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_provider.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "url/gurl.h" // static @@ -37,7 +38,7 @@ void AutocompleteClassifier::Classify( const base::string16& text, bool prefer_keyword, bool allow_exact_keyword_match, - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification page_classification, AutocompleteMatch* match, GURL* alternate_nav_url) { DCHECK(!inside_classify_); diff --git a/chrome/browser/autocomplete/autocomplete_classifier.h b/chrome/browser/autocomplete/autocomplete_classifier.h index c78fe0e..b9abc237 100644 --- a/chrome/browser/autocomplete/autocomplete_classifier.h +++ b/chrome/browser/autocomplete/autocomplete_classifier.h @@ -9,8 +9,8 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" -#include "chrome/browser/autocomplete/autocomplete_input.h" #include "components/keyed_service/core/keyed_service.h" +#include "components/metrics/proto/omnibox_event.pb.h" class AutocompleteController; struct AutocompleteMatch; @@ -46,7 +46,8 @@ class AutocompleteClassifier : public KeyedService { void Classify(const base::string16& text, bool prefer_keyword, bool allow_exact_keyword_match, - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification + page_classification, AutocompleteMatch* match, GURL* alternate_nav_url); diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc index fbf04db..69fd111 100644 --- a/chrome/browser/autocomplete/autocomplete_input.cc +++ b/chrome/browser/autocomplete/autocomplete_input.cc @@ -8,6 +8,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" #include "chrome/browser/profiles/profile_io_data.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/url_fixer/url_fixer.h" #include "content/public/common/url_constants.h" #include "net/base/net_util.h" @@ -31,7 +32,7 @@ void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed, AutocompleteInput::AutocompleteInput() : cursor_position_(base::string16::npos), - current_page_classification_(AutocompleteInput::INVALID_SPEC), + current_page_classification_(metrics::OmniboxEventProto::INVALID_SPEC), type_(metrics::OmniboxInputType::INVALID), prevent_inline_autocomplete_(false), prefer_keyword_(false), @@ -44,7 +45,7 @@ AutocompleteInput::AutocompleteInput( size_t cursor_position, const base::string16& desired_tld, const GURL& current_url, - AutocompleteInput::PageClassification current_page_classification, + metrics::OmniboxEventProto::PageClassification current_page_classification, bool prevent_inline_autocomplete, bool prefer_keyword, bool allow_exact_keyword_match, @@ -99,7 +100,7 @@ AutocompleteInput::~AutocompleteInput() { // static size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary( - AutocompleteInput::Type type, + metrics::OmniboxInputType::Type type, base::string16* text) { if ((type != metrics::OmniboxInputType::FORCED_QUERY) || text->empty() || (*text)[0] != L'?') @@ -110,7 +111,8 @@ size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary( } // static -std::string AutocompleteInput::TypeToString(AutocompleteInput::Type type) { +std::string AutocompleteInput::TypeToString( + metrics::OmniboxInputType::Type type) { switch (type) { case metrics::OmniboxInputType::INVALID: return "invalid"; case metrics::OmniboxInputType::UNKNOWN: return "unknown"; @@ -124,7 +126,7 @@ std::string AutocompleteInput::TypeToString(AutocompleteInput::Type type) { } // static -AutocompleteInput::Type AutocompleteInput::Parse( +metrics::OmniboxInputType::Type AutocompleteInput::Parse( const base::string16& text, const base::string16& desired_tld, url::Parsed* parts, @@ -219,7 +221,7 @@ AutocompleteInput::Type AutocompleteInput::Parse( url::Parsed http_parts; base::string16 http_scheme; GURL http_canonicalized_url; - AutocompleteInput::Type http_type = + metrics::OmniboxInputType::Type http_type = Parse(http_scheme_prefix + text, desired_tld, &http_parts, &http_scheme, &http_canonicalized_url); DCHECK_EQ(std::string(url::kHttpScheme), @@ -530,7 +532,7 @@ void AutocompleteInput::Clear() { text_.clear(); cursor_position_ = base::string16::npos; current_url_ = GURL(); - current_page_classification_ = AutocompleteInput::INVALID_SPEC; + current_page_classification_ = metrics::OmniboxEventProto::INVALID_SPEC; type_ = metrics::OmniboxInputType::INVALID; parts_ = url::Parsed(); scheme_.clear(); diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h index accb48d..194ab8b 100644 --- a/chrome/browser/autocomplete/autocomplete_input.h +++ b/chrome/browser/autocomplete/autocomplete_input.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/strings/string16.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/metrics/proto/omnibox_input_type.pb.h" #include "url/gurl.h" #include "url/url_parse.h" @@ -17,56 +18,6 @@ // The user input for an autocomplete query. Allows copying. class AutocompleteInput { public: - typedef metrics::OmniboxInputType::Type Type; - - // The type of page currently displayed. - // Warning: when adding an element to this enum, please add it at the end - // and update omnibox_event.proto::PageClassification and - // omnibox_edit_model.cc::ClassifyPage() too. - enum PageClassification { - // An invalid URL; shouldn't happen. - INVALID_SPEC = 0, - - // chrome://newtab/. This can be either the built-in version or a - // replacement new tab page from an extension. Note that when Instant - // Extended is enabled, the new tab page will be reported as either - // INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS or - // INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS below, - // unless an extension is replacing the new tab page, in which case - // it will still be reported as NTP. - NTP = 1, - - // about:blank. - BLANK = 2, - - // The user's home page. Note that if the home page is set to any - // of the new tab page versions or to about:blank, then we'll - // classify the page into those categories, not HOME_PAGE. - HOME_PAGE = 3, - - // The catch-all entry of everything not included somewhere else - // on this list. - OTHER = 4, - - // The user is on a search result page that's doing search term - // replacement, meaning the search terms should've appeared in the omnibox - // before the user started editing it, not the URL of the page. - SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT = 6, - - // The new tab page in which this omnibox interaction first started - // with the user having focus in the omnibox. - INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS = 7, - - // The new tab page in which this omnibox interaction first started - // with the user having focus in the fakebox. - INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS = 8, - - // The user is on a search result page that's not doing search term - // replacement, meaning the URL of the page should've appeared in the - // omnibox before the user started editing it, not the search terms. - SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT = 9 - }; - AutocompleteInput(); // |text| and |cursor_position| represent the input query and location of // the cursor with the query respectively. |cursor_position| may be set to @@ -111,7 +62,8 @@ class AutocompleteInput { size_t cursor_position, const base::string16& desired_tld, const GURL& current_url, - PageClassification current_page_classification, + metrics::OmniboxEventProto::PageClassification + current_page_classification, bool prevent_inline_autocomplete, bool prefer_keyword, bool allow_exact_keyword_match, @@ -120,22 +72,24 @@ class AutocompleteInput { // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. // Returns number of leading characters removed. - static size_t RemoveForcedQueryStringIfNecessary(Type type, - base::string16* text); + static size_t RemoveForcedQueryStringIfNecessary( + metrics::OmniboxInputType::Type type, + base::string16* text); // Converts |type| to a string representation. Used in logging. - static std::string TypeToString(Type type); + static std::string TypeToString(metrics::OmniboxInputType::Type type); // Parses |text| and returns the type of input this will be interpreted as. // The components of the input are stored in the output parameter |parts|, if // it is non-NULL. The scheme is stored in |scheme| if it is non-NULL. The // canonicalized URL is stored in |canonicalized_url|; however, this URL is // not guaranteed to be valid, especially if the parsed type is, e.g., QUERY. - static Type Parse(const base::string16& text, - const base::string16& desired_tld, - url::Parsed* parts, - base::string16* scheme, - GURL* canonicalized_url); + static metrics::OmniboxInputType::Type Parse( + const base::string16& text, + const base::string16& desired_tld, + url::Parsed* parts, + base::string16* scheme, + GURL* canonicalized_url); // Parses |text| and fill |scheme| and |host| by the positions of them. // The results are almost as same as the result of Parse(), but if the scheme @@ -180,12 +134,13 @@ class AutocompleteInput { // The type of page that is currently behind displayed and how it is // displayed (e.g., with search term replacement or without). - AutocompleteInput::PageClassification current_page_classification() const { + metrics::OmniboxEventProto::PageClassification current_page_classification() + const { return current_page_classification_; } // The type of input supplied. - Type type() const { return type_; } + metrics::OmniboxInputType::Type type() const { return type_; } // Returns parsed URL components. const url::Parsed& parts() const { return parts_; } @@ -226,8 +181,8 @@ class AutocompleteInput { base::string16 text_; size_t cursor_position_; GURL current_url_; - AutocompleteInput::PageClassification current_page_classification_; - Type type_; + metrics::OmniboxEventProto::PageClassification current_page_classification_; + metrics::OmniboxInputType::Type type_; url::Parsed parts_; base::string16 scheme_; GURL canonicalized_url_; diff --git a/chrome/browser/autocomplete/autocomplete_input_unittest.cc b/chrome/browser/autocomplete/autocomplete_input_unittest.cc index b131e6b..aca0102 100644 --- a/chrome/browser/autocomplete/autocomplete_input_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_input_unittest.cc @@ -8,15 +8,18 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" +#include "components/metrics/proto/omnibox_event.pb.h" +#include "components/metrics/proto/omnibox_input_type.pb.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/url_parse.h" using base::ASCIIToUTF16; +using metrics::OmniboxEventProto; TEST(AutocompleteInputTest, InputType) { struct test_data { const base::string16 input; - const AutocompleteInput::Type type; + const metrics::OmniboxInputType::Type type; } input_cases[] = { { base::string16(), metrics::OmniboxInputType::INVALID }, { ASCIIToUTF16("?"), metrics::OmniboxInputType::FORCED_QUERY }, @@ -139,7 +142,7 @@ TEST(AutocompleteInputTest, InputType) { SCOPED_TRACE(input_cases[i].input); AutocompleteInput input(input_cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, false, true, + OmniboxEventProto::INVALID_SPEC, true, false, true, true); EXPECT_EQ(input_cases[i].type, input.type()); } @@ -148,7 +151,7 @@ TEST(AutocompleteInputTest, InputType) { TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { struct test_data { const base::string16 input; - const AutocompleteInput::Type type; + const metrics::OmniboxInputType::Type type; const std::string spec; // Unused if not a URL. } input_cases[] = { { ASCIIToUTF16("401k"), metrics::OmniboxInputType::URL, @@ -169,7 +172,7 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { SCOPED_TRACE(input_cases[i].input); AutocompleteInput input(input_cases[i].input, base::string16::npos, ASCIIToUTF16("com"), GURL(), - AutocompleteInput::INVALID_SPEC, true, false, true, + OmniboxEventProto::INVALID_SPEC, true, false, true, true); EXPECT_EQ(input_cases[i].type, input.type()); if (input_cases[i].type == metrics::OmniboxInputType::URL) @@ -182,7 +185,7 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) { TEST(AutocompleteInputTest, InputCrash) { AutocompleteInput input(base::WideToUTF16(L"\uff65@s"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, false, + OmniboxEventProto::INVALID_SPEC, true, false, true, true); } @@ -226,7 +229,7 @@ TEST(AutocompleteInputTest, ParseForEmphasizeComponent) { &host); AutocompleteInput input(input_cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, + OmniboxEventProto::INVALID_SPEC, true, false, true, true); EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); EXPECT_EQ(input_cases[i].scheme.len, scheme.len); @@ -265,7 +268,7 @@ TEST(AutocompleteInputTest, InputTypeWithCursorPosition) { AutocompleteInput input(input_cases[i].input, input_cases[i].cursor_position, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, + OmniboxEventProto::INVALID_SPEC, true, false, true, true); EXPECT_EQ(input_cases[i].normalized_input, input.text()); EXPECT_EQ(input_cases[i].normalized_cursor_position, diff --git a/chrome/browser/autocomplete/autocomplete_provider.cc b/chrome/browser/autocomplete/autocomplete_provider.cc index a44335d..a4cfac4 100644 --- a/chrome/browser/autocomplete/autocomplete_provider.cc +++ b/chrome/browser/autocomplete/autocomplete_provider.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" @@ -223,4 +224,3 @@ size_t AutocompleteProvider::TrimHttpPrefix(base::string16* url) { url->erase(scheme_pos, prefix_end - scheme_pos); return (scheme_pos == 0) ? prefix_end : 0; } - diff --git a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc index 1b381fc..aab3b3f 100644 --- a/chrome/browser/autocomplete/autocomplete_provider_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_provider_unittest.cc @@ -25,6 +25,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" @@ -404,7 +405,7 @@ void AutocompleteProviderTest::RunQuery(const base::string16 query) { result_.Reset(); controller_->Start(AutocompleteInput( query, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, false, true, true)); + metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, true)); if (!controller_->done()) // The message loop will terminate when all autocomplete input has been @@ -422,7 +423,7 @@ void AutocompleteProviderTest::RunExactKeymatchTest( // keyword or not.) controller_->Start(AutocompleteInput( base::ASCIIToUTF16("k test"), base::string16::npos, base::string16(), - GURL(), AutocompleteInput::INVALID_SPEC, true, false, + GURL(), metrics::OmniboxEventProto::INVALID_SPEC, true, false, allow_exact_keyword_match, false)); EXPECT_TRUE(controller_->done()); EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, @@ -648,7 +649,8 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL) { EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j0&", url.path()); // Test page classification set. - controller_->input_.current_page_classification_ = AutocompleteInput::OTHER; + controller_->input_.current_page_classification_ = + metrics::OmniboxEventProto::OTHER; controller_->search_provider_->field_trial_triggered_in_session_ = false; EXPECT_FALSE( controller_->search_provider_->field_trial_triggered_in_session()); diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc index 000a1fe..8658f28 100644 --- a/chrome/browser/autocomplete/autocomplete_result.cc +++ b/chrome/browser/autocomplete/autocomplete_result.cc @@ -16,8 +16,11 @@ #include "chrome/browser/omnibox/omnibox_field_trial.h" #include "chrome/browser/search/search.h" #include "chrome/common/autocomplete_match_type.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/metrics/proto/omnibox_input_type.pb.h" +using metrics::OmniboxEventProto; + namespace { // This class implements a special version of AutocompleteMatch::MoreRelevant @@ -25,7 +28,7 @@ namespace { class CompareWithDemoteByType { public: CompareWithDemoteByType( - AutocompleteInput::PageClassification current_page_classification); + OmniboxEventProto::PageClassification current_page_classification); // Returns the relevance score of |match| demoted appropriately by // |demotions_by_type_|. @@ -40,7 +43,7 @@ class CompareWithDemoteByType { }; CompareWithDemoteByType::CompareWithDemoteByType( - AutocompleteInput::PageClassification current_page_classification) { + OmniboxEventProto::PageClassification current_page_classification) { OmniboxFieldTrial::GetDemotionsByType(current_page_classification, &demotions_); } @@ -69,7 +72,7 @@ bool CompareWithDemoteByType::operator()(const AutocompleteMatch& elem1, class DestinationSort { public: DestinationSort( - AutocompleteInput::PageClassification current_page_classification); + OmniboxEventProto::PageClassification current_page_classification); bool operator()(const AutocompleteMatch& elem1, const AutocompleteMatch& elem2); @@ -78,7 +81,7 @@ class DestinationSort { }; DestinationSort::DestinationSort( - AutocompleteInput::PageClassification current_page_classification) : + OmniboxEventProto::PageClassification current_page_classification) : demote_by_type_(current_page_classification) {} bool DestinationSort::operator()(const AutocompleteMatch& elem1, @@ -364,7 +367,7 @@ GURL AutocompleteResult::ComputeAlternateNavUrl( } void AutocompleteResult::DedupMatchesByDestination( - AutocompleteInput::PageClassification page_classification, + OmniboxEventProto::PageClassification page_classification, bool set_duplicate_matches, ACMatches* matches) { DestinationSort destination_sort(page_classification); @@ -423,7 +426,7 @@ bool AutocompleteResult::HasMatchByDestination(const AutocompleteMatch& match, } void AutocompleteResult::MergeMatchesByProvider( - AutocompleteInput::PageClassification page_classification, + OmniboxEventProto::PageClassification page_classification, const ACMatches& old_matches, const ACMatches& new_matches) { if (new_matches.size() >= old_matches.size()) diff --git a/chrome/browser/autocomplete/autocomplete_result.h b/chrome/browser/autocomplete/autocomplete_result.h index 68b5096..cf15c84 100644 --- a/chrome/browser/autocomplete/autocomplete_result.h +++ b/chrome/browser/autocomplete/autocomplete_result.h @@ -12,9 +12,9 @@ #include "base/basictypes.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "url/gurl.h" -class AutocompleteInput; class AutocompleteProvider; class Profile; @@ -150,7 +150,7 @@ class AutocompleteResult { // |set_duplicate_matches| is true, the duplicate matches are stored in the // |duplicate_matches| vector of the corresponding AutocompleteMatch. static void DedupMatchesByDestination( - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification page_classification, bool set_duplicate_matches, ACMatches* matches); @@ -181,7 +181,7 @@ class AutocompleteResult { // Copies matches into this result. |old_matches| gives the matches from the // last result, and |new_matches| the results from this result. void MergeMatchesByProvider( - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification page_classification, const ACMatches& old_matches, const ACMatches& new_matches); diff --git a/chrome/browser/autocomplete/autocomplete_result_unittest.cc b/chrome/browser/autocomplete/autocomplete_result_unittest.cc index 238509b..15d0c40 100644 --- a/chrome/browser/autocomplete/autocomplete_result_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_result_unittest.cc @@ -20,10 +20,13 @@ #include "chrome/browser/search_engines/template_url_service_test_util.h" #include "chrome/common/autocomplete_match_type.h" #include "chrome/test/base/testing_profile.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; + namespace { struct AutocompleteMatchTestData { @@ -176,7 +179,7 @@ void AutocompleteResultTest::RunCopyOldMatchesTest( const TestData* expected, size_t expected_size) { AutocompleteInput input(base::ASCIIToUTF16("a"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, false, + OmniboxEventProto::INVALID_SPEC, false, false, false, true); ACMatches last_matches; @@ -212,7 +215,7 @@ TEST_F(AutocompleteResultTest, Swap) { match.allowed_to_be_default_match = true; AutocompleteInput input(base::ASCIIToUTF16("a"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, false, + OmniboxEventProto::INVALID_SPEC, false, false, false, true); matches.push_back(match); r1.AppendMatches(matches); @@ -295,7 +298,7 @@ TEST_F(AutocompleteResultTest, SortAndCullEmptyDestinationURLs) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, false, + OmniboxEventProto::INVALID_SPEC, false, false, false, true); result.SortAndCull(input, test_util_.profile()); @@ -341,7 +344,7 @@ TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, false, + OmniboxEventProto::INVALID_SPEC, false, false, false, true); result.SortAndCull(input, test_util_.profile()); @@ -393,7 +396,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, false, + OmniboxEventProto::INVALID_SPEC, false, false, false, true); result.SortAndCull(input, test_util_.profile()); @@ -447,7 +450,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDemotionsByType) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); @@ -492,7 +495,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithMatchDupsAndDemotionsByType) { result.AppendMatches(matches); AutocompleteInput input( base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS, false, + OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS, false, false, false, true); result.SortAndCull(input, test_util_.profile()); @@ -530,7 +533,7 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); AssertResultMatches(result, data, 4); @@ -546,7 +549,7 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); ASSERT_EQ(4U, result.size()); @@ -577,7 +580,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); AssertResultMatches(result, data, 4); @@ -602,7 +605,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); ASSERT_EQ(4U, result.size()); @@ -623,7 +626,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); AssertResultMatches(result, data, 4); @@ -639,7 +642,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); ASSERT_EQ(4U, result.size()); @@ -659,7 +662,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); ASSERT_EQ(4U, result.size()); @@ -684,7 +687,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); AssertResultMatches(result, data, 4); @@ -705,7 +708,7 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { result.AppendMatches(matches); AutocompleteInput input(base::string16(), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::HOME_PAGE, false, false, false, + OmniboxEventProto::HOME_PAGE, false, false, false, true); result.SortAndCull(input, test_util_.profile()); ASSERT_EQ(4U, result.size()); diff --git a/chrome/browser/autocomplete/base_search_provider.cc b/chrome/browser/autocomplete/base_search_provider.cc index c7ee41e..be8120a 100644 --- a/chrome/browser/autocomplete/base_search_provider.cc +++ b/chrome/browser/autocomplete/base_search_provider.cc @@ -31,6 +31,7 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/pref_names.h" #include "components/autocomplete/url_prefix.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/metrics/proto/omnibox_input_type.pb.h" #include "components/sync_driver/sync_prefs.h" #include "components/url_fixer/url_fixer.h" @@ -43,6 +44,8 @@ #include "net/url_request/url_fetcher_delegate.h" #include "url/gurl.h" +using metrics::OmniboxEventProto; + namespace { AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { @@ -588,7 +591,7 @@ scoped_ptr<base::Value> BaseSearchProvider::DeserializeJsonData( bool BaseSearchProvider::ZeroSuggestEnabled( const GURL& suggest_url, const TemplateURL* template_url, - AutocompleteInput::PageClassification page_classification, + OmniboxEventProto::PageClassification page_classification, Profile* profile) { if (!OmniboxFieldTrial::InZeroSuggestFieldTrial()) return false; @@ -602,9 +605,9 @@ bool BaseSearchProvider::ZeroSuggestEnabled( // TODO(hfung): Experiment with showing MostVisited zero suggest on NTP // under the conditions described in crbug.com/305366. if ((page_classification == - AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) || + OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) || (page_classification == - AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS)) + OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS)) return false; // Don't run if there's no profile or in incognito mode. @@ -633,7 +636,7 @@ bool BaseSearchProvider::CanSendURL( const GURL& current_page_url, const GURL& suggest_url, const TemplateURL* template_url, - AutocompleteInput::PageClassification page_classification, + OmniboxEventProto::PageClassification page_classification, Profile* profile) { if (!ZeroSuggestEnabled(suggest_url, template_url, page_classification, profile)) diff --git a/chrome/browser/autocomplete/base_search_provider.h b/chrome/browser/autocomplete/base_search_provider.h index 75ec5e6..a3a788a 100644 --- a/chrome/browser/autocomplete/base_search_provider.h +++ b/chrome/browser/autocomplete/base_search_provider.h @@ -19,6 +19,7 @@ #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_provider.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "net/url_request/url_fetcher_delegate.h" class AutocompleteProviderListener; @@ -379,7 +380,7 @@ class BaseSearchProvider : public AutocompleteProvider, static bool ZeroSuggestEnabled( const GURL& suggest_url, const TemplateURL* template_url, - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification page_classification, Profile* profile); // Returns whether we can send the URL of the current page in any suggest @@ -402,7 +403,7 @@ class BaseSearchProvider : public AutocompleteProvider, const GURL& current_page_url, const GURL& suggest_url, const TemplateURL* template_url, - AutocompleteInput::PageClassification page_classification, + metrics::OmniboxEventProto::PageClassification page_classification, Profile* profile); // net::URLFetcherDelegate: diff --git a/chrome/browser/autocomplete/bookmark_provider_unittest.cc b/chrome/browser/autocomplete/bookmark_provider_unittest.cc index db7e7fe..b3c625d 100644 --- a/chrome/browser/autocomplete/bookmark_provider_unittest.cc +++ b/chrome/browser/autocomplete/bookmark_provider_unittest.cc @@ -20,6 +20,7 @@ #include "components/bookmarks/browser/bookmark_match.h" #include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/test/test_bookmark_client.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "testing/gtest/include/gtest/gtest.h" using bookmarks::BookmarkMatch; @@ -261,8 +262,8 @@ TEST_F(BookmarkProviderTest, Positions) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - false, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, false, true); provider_->Start(input, false); const ACMatches& matches(provider_->matches()); // Validate number of results is as expected. @@ -338,8 +339,8 @@ TEST_F(BookmarkProviderTest, Rankings) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - false, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, false, true); provider_->Start(input, false); const ACMatches& matches(provider_->matches()); // Validate number and content of results is as expected. @@ -394,8 +395,8 @@ TEST_F(BookmarkProviderTest, InlineAutocompletion) { " and url=" + query_data[i].url; AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - false, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, false, true); const base::string16 fixed_up_input( provider_->FixupUserInput(input).second); BookmarkNode node(GURL(query_data[i].url)); @@ -440,8 +441,8 @@ TEST_F(BookmarkProviderTest, StripHttpAndAdjustOffsets) { std::string description = "for query=" + query_data[i].query; AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - false, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, false, true); provider_->Start(input, false); const ACMatches& matches(provider_->matches()); ASSERT_EQ(1U, matches.size()) << description; diff --git a/chrome/browser/autocomplete/builtin_provider_unittest.cc b/chrome/browser/autocomplete/builtin_provider_unittest.cc index 8036e33..d5b436340 100644 --- a/chrome/browser/autocomplete/builtin_provider_unittest.cc +++ b/chrome/browser/autocomplete/builtin_provider_unittest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/common/url_constants.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -37,7 +38,7 @@ class BuiltinProviderTest : public testing::Test { "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str())); const AutocompleteInput input(cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, + metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, true); provider_->Start(input, false); EXPECT_TRUE(provider_->done()); diff --git a/chrome/browser/autocomplete/extension_app_provider_unittest.cc b/chrome/browser/autocomplete/extension_app_provider_unittest.cc index 0ac201a..ea29e43 100644 --- a/chrome/browser/autocomplete/extension_app_provider_unittest.cc +++ b/chrome/browser/autocomplete/extension_app_provider_unittest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/url_database.h" #include "chrome/test/base/testing_profile.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "content/public/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -90,7 +91,7 @@ void ExtensionAppProviderTest::RunTest( for (int i = 0; i < num_cases; ++i) { AutocompleteInput input(keyword_cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, + metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, true); app_provider_->Start(input, false); EXPECT_TRUE(app_provider_->done()); @@ -141,7 +142,7 @@ TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) { AutocompleteInput input(ASCIIToUTF16("Test"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, true, + metrics::OmniboxEventProto::INVALID_SPEC, true, true, true, false); base::string16 url(ASCIIToUTF16("http://example.com")); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc index 6d1e9bf7..a8ab04c 100644 --- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc @@ -36,6 +36,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/bookmarks/test/bookmark_test_helpers.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_utils.h" @@ -262,7 +263,7 @@ void HistoryQuickProviderTest::RunTest(const base::string16 text, SCOPED_TRACE(text); // Minimal hint to query being run. base::MessageLoop::current()->RunUntilIdle(); AutocompleteInput input(text, base::string16::npos, base::string16(), - GURL(), AutocompleteInput::INVALID_SPEC, + GURL(), metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, false, true, true); provider_->Start(input, false); EXPECT_TRUE(provider_->done()); diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index ed3393a..ea5ddb6 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -25,6 +25,8 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" +#include "components/metrics/proto/omnibox_event.pb.h" +#include "components/metrics/proto/omnibox_input_type.pb.h" #include "components/url_fixer/url_fixer.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" @@ -189,7 +191,7 @@ class HistoryURLProviderTest : public testing::Test, bool prevent_inline_autocomplete, const UrlAndLegalDefault* expected_urls, size_t num_results, - AutocompleteInput::Type* identified_input_type); + metrics::OmniboxInputType::Type* identified_input_type); // A version of the above without the final |type| output parameter. void RunTest(const base::string16 text, @@ -197,7 +199,7 @@ class HistoryURLProviderTest : public testing::Test, bool prevent_inline_autocomplete, const UrlAndLegalDefault* expected_urls, size_t num_results) { - AutocompleteInput::Type type; + metrics::OmniboxInputType::Type type; return RunTest(text, desired_tld, prevent_inline_autocomplete, expected_urls, num_results, &type); } @@ -278,9 +280,9 @@ void HistoryURLProviderTest::RunTest( bool prevent_inline_autocomplete, const UrlAndLegalDefault* expected_urls, size_t num_results, - AutocompleteInput::Type* identified_input_type) { + metrics::OmniboxInputType::Type* identified_input_type) { AutocompleteInput input(text, base::string16::npos, desired_tld, GURL(), - AutocompleteInput::INVALID_SPEC, + metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, false, true, true); *identified_input_type = input.type(); autocomplete_->Start(input, false); @@ -559,8 +561,8 @@ TEST_F(HistoryURLProviderTest, EmptyVisits) { AutocompleteInput input(ASCIIToUTF16("p"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, true, - true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, true, true); autocomplete_->Start(input, false); // HistoryURLProvider shouldn't be done (waiting on async results). EXPECT_FALSE(autocomplete_->done()); @@ -601,8 +603,8 @@ TEST_F(HistoryURLProviderTestNoDB, NavigateWithoutDB) { TEST_F(HistoryURLProviderTest, DontAutocompleteOnTrailingWhitespace) { AutocompleteInput input(ASCIIToUTF16("slash "), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - true, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, true, true); autocomplete_->Start(input, false); if (!autocomplete_->done()) base::MessageLoop::current()->Run(); @@ -667,7 +669,7 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) { struct TestCase { const char* input; int relevance; - AutocompleteInput::Type type; + metrics::OmniboxInputType::Type type; } test_cases[] = { { "gooey", 1410, metrics::OmniboxInputType::UNKNOWN }, { "gooey/", 1410, metrics::OmniboxInputType::URL }, @@ -682,7 +684,7 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) { SCOPED_TRACE(test_cases[i].input); const UrlAndLegalDefault output[] = { {url_fixer::FixupURL(test_cases[i].input, std::string()).spec(), true}}; - AutocompleteInput::Type type; + metrics::OmniboxInputType::Type type; ASSERT_NO_FATAL_FAILURE( RunTest(ASCIIToUTF16(test_cases[i].input), base::string16(), false, output, arraysize(output), &type)); @@ -777,7 +779,7 @@ TEST_F(HistoryURLProviderTest, CrashDueToFixup) { for (size_t i = 0; i < arraysize(test_cases); ++i) { AutocompleteInput input(ASCIIToUTF16(test_cases[i]), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, + metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true); autocomplete_->Start(input, false); if (!autocomplete_->done()) @@ -895,8 +897,8 @@ TEST_F(HistoryURLProviderTest, SuggestExactInput) { AutocompleteInput input(ASCIIToUTF16(test_cases[i].input), base::string16::npos, base::string16(), GURL("about:blank"), - AutocompleteInput::INVALID_SPEC, false, false, true, - true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, true, true); AutocompleteMatch match(autocomplete_->SuggestExactInput( input.text(), input.canonicalized_url(), test_cases[i].trim_http)); EXPECT_EQ(ASCIIToUTF16(test_cases[i].contents), match.contents); diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc index adf5ecf..1c7afa2 100644 --- a/chrome/browser/autocomplete/keyword_provider_unittest.cc +++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_browser_process.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -81,7 +82,7 @@ void KeywordProviderTest::RunTest( SCOPED_TRACE(keyword_cases[i].input); AutocompleteInput input(keyword_cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, true, + metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, true); kw_provider_->Start(input, false); EXPECT_TRUE(kw_provider_->done()); @@ -323,8 +324,8 @@ TEST_F(KeywordProviderTest, GetSubstitutingTemplateURLForInput) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { AutocompleteInput input(ASCIIToUTF16(cases[i].text), cases[i].cursor_position, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, - cases[i].allow_exact_keyword_match, true); + metrics::OmniboxEventProto::INVALID_SPEC, false, + false, cases[i].allow_exact_keyword_match, true); const TemplateURL* url = KeywordProvider::GetSubstitutingTemplateURLForInput(model_.get(), &input); diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 4db298b..0c3c82c 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -163,7 +163,7 @@ void SearchProvider::UpdateMatchContentsClass(const base::string16& input_text, // static int SearchProvider::CalculateRelevanceForKeywordVerbatim( - AutocompleteInput::Type type, + metrics::OmniboxInputType::Type type, bool prefer_keyword) { // This function is responsible for scoring verbatim query matches // for non-extension keywords. KeywordProvider::CalculateRelevance() diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h index 0c1188c..7e5dfdf 100644 --- a/chrome/browser/autocomplete/search_provider.h +++ b/chrome/browser/autocomplete/search_provider.h @@ -138,8 +138,9 @@ class SearchProvider : public BaseSearchProvider { // Calculates the relevance score for the keyword verbatim result (if the // input matches one of the profile's keyword). - static int CalculateRelevanceForKeywordVerbatim(AutocompleteInput::Type type, - bool prefer_keyword); + static int CalculateRelevanceForKeywordVerbatim( + metrics::OmniboxInputType::Type type, + bool prefer_keyword); // AutocompleteProvider: virtual void Start(const AutocompleteInput& input, diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 04928a3..fb76df3 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -37,6 +37,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/google/core/browser/google_switches.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/search_engines/search_engine_type.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync_driver/pref_names.h" @@ -297,7 +298,7 @@ void SearchProviderTest::RunTest(TestData* cases, for (int i = 0; i < num_cases; ++i) { AutocompleteInput input(cases[i].input, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, + metrics::OmniboxEventProto::INVALID_SPEC, false, prefer_keyword, true, true); provider_->Start(input, false); matches = provider_->matches(); @@ -343,7 +344,7 @@ void SearchProviderTest::QueryForInput(const base::string16& text, bool prefer_keyword) { // Start a query. AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, + metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, prefer_keyword, true, true); provider_->Start(input, false); @@ -882,7 +883,7 @@ TEST_F(SearchProviderTest, KeywordOrderingAndDescriptions) { AutocompleteProvider::TYPE_SEARCH); controller.Start(AutocompleteInput( ASCIIToUTF16("k t"), base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, false, false, true, true)); + metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true)); const AutocompleteResult& result = controller.result(); // There should be three matches, one for the keyword history, one for @@ -2907,7 +2908,7 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); SigninManagerBase* signin = SigninManagerFactory::GetForProfile(&profile_); signin->SetAuthenticatedUsername("test"); @@ -2915,14 +2916,14 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_TRUE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); // Not in field trial. ResetFieldTrialList(); EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); field_trial = base::FieldTrialList::CreateFieldTrial( "AutocompleteDynamicTrial_2", "EnableZeroSuggest"); field_trial->group(); @@ -2931,59 +2932,59 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_FALSE(SearchProvider::CanSendURL( GURL("badpageurl"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); // Invalid page classification. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS, + metrics::OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS, &profile_)); // Invalid page classification. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS, + metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS, &profile_)); // HTTPS page URL on same domain as provider. EXPECT_TRUE(SearchProvider::CanSendURL( GURL("https://www.google.com/search"), GURL("https://www.google.com/complete/search"), - &google_template_url, AutocompleteInput::OTHER, &profile_)); + &google_template_url, metrics::OmniboxEventProto::OTHER, &profile_)); // Non-HTTP[S] page URL on same domain as provider. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("ftp://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); // Non-HTTP page URL on different domain. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("https://www.notgoogle.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); // Non-HTTPS provider. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("http://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); // Suggest disabled. profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false); EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); // Incognito. EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); + metrics::OmniboxEventProto::OTHER, profile_.GetOffTheRecordProfile())); // Tab sync not enabled. profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncKeepEverythingSynced, @@ -2992,7 +2993,7 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, true); // Tab sync is encrypted. @@ -3004,7 +3005,7 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_FALSE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); encrypted_types.Remove(syncer::SESSIONS); service->OnEncryptedTypesChanged(encrypted_types, false); @@ -3012,7 +3013,7 @@ TEST_F(SearchProviderTest, CanSendURL) { EXPECT_TRUE(SearchProvider::CanSendURL( GURL("http://www.google.com/search"), GURL("https://www.google.com/complete/search"), &google_template_url, - AutocompleteInput::OTHER, &profile_)); + metrics::OmniboxEventProto::OTHER, &profile_)); } TEST_F(SearchProviderTest, TestDeleteMatch) { diff --git a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc index bb3ca8d..73cb4e5 100644 --- a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc +++ b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc @@ -30,6 +30,7 @@ #include "chrome/browser/history/url_database.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread.h" #include "extensions/common/extension.h" @@ -360,7 +361,7 @@ void ShortcutsProviderTest::RunTest( base::string16 top_result_inline_autocompletion) { base::MessageLoop::current()->RunUntilIdle(); AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), - AutocompleteInput::INVALID_SPEC, + metrics::OmniboxEventProto::INVALID_SPEC, prevent_inline_autocomplete, false, true, true); provider_->Start(input, false); EXPECT_TRUE(provider_->done()); diff --git a/chrome/browser/autocomplete/zero_suggest_provider.h b/chrome/browser/autocomplete/zero_suggest_provider.h index 7c33d7d..1c494a1 100644 --- a/chrome/browser/autocomplete/zero_suggest_provider.h +++ b/chrome/browser/autocomplete/zero_suggest_provider.h @@ -19,6 +19,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/autocomplete/base_search_provider.h" #include "chrome/browser/autocomplete/search_provider.h" +#include "components/metrics/proto/omnibox_event.pb.h" class TemplateURLService; @@ -134,7 +135,7 @@ class ZeroSuggestProvider : public BaseSearchProvider { // The type of page the user is viewing (a search results page doing search // term replacement, an arbitrary URL, etc.). - AutocompleteInput::PageClassification current_page_classification_; + metrics::OmniboxEventProto::PageClassification current_page_classification_; // Copy of OmniboxEditModel::permanent_text_. base::string16 permanent_text_; diff --git a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc index 14df843..eebcdfd 100644 --- a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc +++ b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" +#include "components/metrics/proto/omnibox_event.pb.h" #include "components/variations/entropy_provider.h" #include "components/variations/variations_associated_data.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -112,7 +113,8 @@ TEST_F(ZeroSuggestProviderTest, TestPsuggestZeroSuggestCachingFirstRun) { std::string url("http://www.cnn.com"); AutocompleteInput input( base::ASCIIToUTF16(url), base::string16::npos, base::string16(), - GURL(url), AutocompleteInput::INVALID_SPEC, true, false, true, true); + GURL(url), metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, + true); provider_->Start(input, false); @@ -141,7 +143,8 @@ TEST_F(ZeroSuggestProviderTest, TestPsuggestZeroSuggestHasCachedResults) { std::string url("http://www.cnn.com"); AutocompleteInput input( base::ASCIIToUTF16(url), base::string16::npos, base::string16(), - GURL(url), AutocompleteInput::INVALID_SPEC, true, false, true, true); + GURL(url), metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, + true); // Set up the pref to cache the response from the previous run. std::string json_response("[\"\",[\"search1\", \"search2\", \"search3\"]," @@ -187,7 +190,8 @@ TEST_F(ZeroSuggestProviderTest, TestPsuggestZeroSuggestReceivedEmptyResults) { std::string url("http://www.cnn.com"); AutocompleteInput input( base::ASCIIToUTF16(url), base::string16::npos, base::string16(), - GURL(url), AutocompleteInput::INVALID_SPEC, true, false, true, true); + GURL(url), metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, + true); // Set up the pref to cache the response from the previous run. std::string json_response("[\"\",[\"search1\", \"search2\", \"search3\"]," |