Commit 3dc75b1c authored by mpearson@chromium.org's avatar mpearson@chromium.org

Omnibox: Combine Two Input Type Enums into One

There are two input type enums:
* one in the autocomplete code
* one in the metrics code that's used for UMA logging;
  this one is meant to remain stable

As part of fixing the linked bug, I created
https://codereview.chromium.org/314773002/
whch needed an input type enum, one which would remain stable.
It didn't necessarily have to be the metrics enum.

After discussion with the UMA folks (who deal with how to handle
stable enum problems all the time), we reached the conclusion
that we should have one stable enum and use it everywhere.  That's
the cleanest answer.

This single enum has to live in the metrics directory because metrics
is a component.

This change combines the two existing enums into one, putting the
new enum in a new file in the metrics directory.  The reason for
a new file is so we can include it without include the whole
OmniboxEventProto or any other metrics code.

The main files to review are autocomplete_input.h and *.proto.
All other changes are a mechanical result of the changes in
those three files.

The internal proto change has been submitted.

TBR=stevenjb
for the trivial change to chrome/browser/ui/app_list/search/omnibox_provider.cc
that removes an unnecessary include

BUG=284781
NOTRY=True

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=275696

Review URL: https://codereview.chromium.org/319523005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275713 0039d316-1c4b-4281-b951-d872f2087c98
parent 702484bd
...@@ -10,23 +10,14 @@ ...@@ -10,23 +10,14 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/url_parse.h" #include "url/url_parse.h"
// The user input for an autocomplete query. Allows copying. // The user input for an autocomplete query. Allows copying.
class AutocompleteInput { class AutocompleteInput {
public: public:
// Note that the type below may be misleading. For example, "http:/" alone typedef metrics::OmniboxInputType::Type Type;
// cannot be opened as a URL, so it is marked as a QUERY; yet the user
// probably intends to type more and have it eventually become a URL, so we
// need to make sure we still run it through inline autocomplete.
enum Type {
INVALID, // Empty input
UNKNOWN, // Valid input whose type cannot be determined
URL, // Input autodetected as a URL
QUERY, // Input autodetected as a query
FORCED_QUERY, // Input forced to be a query by an initial '?'
};
// The type of page currently displayed. // The type of page currently displayed.
// Note: when adding an element to this enum, please add it at the end // Note: when adding an element to this enum, please add it at the end
......
...@@ -154,7 +154,7 @@ AutocompleteProvider::FixupReturn AutocompleteProvider::FixupUserInput( ...@@ -154,7 +154,7 @@ AutocompleteProvider::FixupReturn AutocompleteProvider::FixupUserInput(
// for hostname beginning with numbers (e.g. input of "17173" will be matched // for hostname beginning with numbers (e.g. input of "17173" will be matched
// against "0.0.67.21" instead of the original "17173", failing to find // against "0.0.67.21" instead of the original "17173", failing to find
// "17173.com"), swap the original hostname in for the fixed-up one. // "17173.com"), swap the original hostname in for the fixed-up one.
if ((input.type() != AutocompleteInput::URL) && if ((input.type() != metrics::OmniboxInputType::URL) &&
canonical_gurl.HostIsIPAddress()) { canonical_gurl.HostIsIPAddress()) {
std::string original_hostname = std::string original_hostname =
base::UTF16ToUTF8(input_text.substr(input.parts().host.begin, base::UTF16ToUTF8(input_text.substr(input.parts().host.begin,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/omnibox/omnibox_field_trial.h" #include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
#include "chrome/common/autocomplete_match_type.h" #include "chrome/common/autocomplete_match_type.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
namespace { namespace {
...@@ -254,9 +255,10 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input, ...@@ -254,9 +255,10 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input,
// We shouldn't get query matches for URL inputs, or non-query matches // We shouldn't get query matches for URL inputs, or non-query matches
// for query inputs. // for query inputs.
if (AutocompleteMatch::IsSearchType(default_match_->type)) { if (AutocompleteMatch::IsSearchType(default_match_->type)) {
DCHECK_NE(AutocompleteInput::URL, input.type()) << debug_info; DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
} else { } else {
DCHECK_NE(AutocompleteInput::FORCED_QUERY, input.type()) << debug_info; DCHECK_NE(metrics::OmniboxInputType::FORCED_QUERY, input.type())
<< debug_info;
} }
} }
} }
...@@ -354,7 +356,7 @@ void AutocompleteResult::Validate() const { ...@@ -354,7 +356,7 @@ void AutocompleteResult::Validate() const {
GURL AutocompleteResult::ComputeAlternateNavUrl( GURL AutocompleteResult::ComputeAlternateNavUrl(
const AutocompleteInput& input, const AutocompleteInput& input,
const AutocompleteMatch& match) { const AutocompleteMatch& match) {
return ((input.type() == AutocompleteInput::UNKNOWN) && return ((input.type() == metrics::OmniboxInputType::UNKNOWN) &&
(AutocompleteMatch::IsSearchType(match.type)) && (AutocompleteMatch::IsSearchType(match.type)) &&
(match.transition != content::PAGE_TRANSITION_KEYWORD) && (match.transition != content::PAGE_TRANSITION_KEYWORD) &&
(input.canonicalized_url() != match.destination_url)) ? (input.canonicalized_url() != match.destination_url)) ?
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "components/sync_driver/sync_prefs.h" #include "components/sync_driver/sync_prefs.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/base/escape.h" #include "net/base/escape.h"
...@@ -337,7 +338,7 @@ int BaseSearchProvider::SuggestResult::CalculateRelevance( ...@@ -337,7 +338,7 @@ int BaseSearchProvider::SuggestResult::CalculateRelevance(
bool keyword_provider_requested) const { bool keyword_provider_requested) const {
if (!from_keyword_provider_ && keyword_provider_requested) if (!from_keyword_provider_ && keyword_provider_requested)
return 100; return 100;
return ((input.type() == AutocompleteInput::URL) ? 300 : 600); return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600);
} }
// BaseSearchProvider::NavigationResult ---------------------------------------- // BaseSearchProvider::NavigationResult ----------------------------------------
...@@ -518,7 +519,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion( ...@@ -518,7 +519,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
// When the user forced a query, we need to make sure all the fill_into_edit // When the user forced a query, we need to make sure all the fill_into_edit
// values preserve that property. Otherwise, if the user starts editing a // values preserve that property. Otherwise, if the user starts editing a
// suggestion, non-Search results will suddenly appear. // suggestion, non-Search results will suddenly appear.
if (input.type() == AutocompleteInput::FORCED_QUERY) if (input.type() == metrics::OmniboxInputType::FORCED_QUERY)
match.fill_into_edit.assign(base::ASCIIToUTF16("?")); match.fill_into_edit.assign(base::ASCIIToUTF16("?"));
if (suggestion.from_keyword_provider()) if (suggestion.from_keyword_provider())
match.fill_into_edit.append(match.keyword + base::char16(' ')); match.fill_into_edit.append(match.keyword + base::char16(' '));
...@@ -853,7 +854,8 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val, ...@@ -853,7 +854,8 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val,
std::string type; std::string type;
int relevance = GetDefaultResultRelevance(); int relevance = GetDefaultResultRelevance();
// Prohibit navsuggest in FORCED_QUERY mode. Users wants queries, not URLs. // Prohibit navsuggest in FORCED_QUERY mode. Users wants queries, not URLs.
const bool allow_navsuggest = input.type() != AutocompleteInput::FORCED_QUERY; const bool allow_navsuggest =
input.type() != metrics::OmniboxInputType::FORCED_QUERY;
const std::string languages( const std::string languages(
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
const base::string16& trimmed_input = const base::string16& trimmed_input =
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_match.h" #include "components/bookmarks/browser/bookmark_match.h"
#include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_model.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
typedef std::vector<BookmarkMatch> BookmarkMatches; typedef std::vector<BookmarkMatch> BookmarkMatches;
...@@ -45,7 +46,7 @@ void BookmarkProvider::Start(const AutocompleteInput& input, ...@@ -45,7 +46,7 @@ void BookmarkProvider::Start(const AutocompleteInput& input,
matches_.clear(); matches_.clear();
if (input.text().empty() || if (input.text().empty() ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return; return;
DoAutocomplete(input); DoAutocomplete(input);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/history_provider.h" #include "chrome/browser/autocomplete/history_provider.h"
#include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
namespace { namespace {
...@@ -64,9 +65,9 @@ BuiltinProvider::BuiltinProvider(AutocompleteProviderListener* listener, ...@@ -64,9 +65,9 @@ BuiltinProvider::BuiltinProvider(AutocompleteProviderListener* listener,
void BuiltinProvider::Start(const AutocompleteInput& input, void BuiltinProvider::Start(const AutocompleteInput& input,
bool minimal_changes) { bool minimal_changes) {
matches_.clear(); matches_.clear();
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY) || (input.type() == metrics::OmniboxInputType::FORCED_QUERY) ||
(input.type() == AutocompleteInput::QUERY)) (input.type() == metrics::OmniboxInputType::QUERY))
return; return;
const size_t kAboutSchemeLength = strlen(content::kAboutScheme); const size_t kAboutSchemeLength = strlen(content::kAboutScheme);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
...@@ -106,8 +107,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input, ...@@ -106,8 +107,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input,
bool minimal_changes) { bool minimal_changes) {
matches_.clear(); matches_.clear();
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return; return;
if (input.text().empty()) if (input.text().empty())
...@@ -133,8 +134,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input, ...@@ -133,8 +134,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input,
std::search(url.begin(), url.end(), std::search(url.begin(), url.end(),
input.text().begin(), input.text().end(), input.text().begin(), input.text().end(),
base::CaseInsensitiveCompare<base::char16>()); base::CaseInsensitiveCompare<base::char16>());
matches_url = url_iter != url.end() && matches_url = (url_iter != url.end()) &&
input.type() != AutocompleteInput::FORCED_QUERY; (input.type() != metrics::OmniboxInputType::FORCED_QUERY);
url_match_index = matches_url ? url_match_index = matches_url ?
static_cast<size_t>(url_iter - url.begin()) : base::string16::npos; static_cast<size_t>(url_iter - url.begin()) : base::string16::npos;
} }
...@@ -191,10 +192,11 @@ void ExtensionAppProvider::Observe(int type, ...@@ -191,10 +192,11 @@ void ExtensionAppProvider::Observe(int type,
RefreshAppList(); RefreshAppList();
} }
int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type, int ExtensionAppProvider::CalculateRelevance(
int input_length, metrics::OmniboxInputType::Type type,
int target_length, int input_length,
const GURL& url) { int target_length,
const GURL& url) {
// If you update the algorithm here, please remember to update the tables in // If you update the algorithm here, please remember to update the tables in
// autocomplete.h also. // autocomplete.h also.
const int kMaxRelevance = 1425; const int kMaxRelevance = 1425;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
...@@ -71,7 +72,7 @@ class ExtensionAppProvider : public AutocompleteProvider, ...@@ -71,7 +72,7 @@ class ExtensionAppProvider : public AutocompleteProvider,
void RefreshAppList(); void RefreshAppList();
// Calculate the relevance of the match. // Calculate the relevance of the match.
int CalculateRelevance(AutocompleteInput::Type type, int CalculateRelevance(metrics::OmniboxInputType::Type type,
int input_length, int input_length,
int target_length, int target_length,
const GURL& url); const GURL& url);
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "net/base/escape.h" #include "net/base/escape.h"
...@@ -65,8 +66,8 @@ void HistoryQuickProvider::Start(const AutocompleteInput& input, ...@@ -65,8 +66,8 @@ void HistoryQuickProvider::Start(const AutocompleteInput& input,
return; return;
// Don't bother with INVALID and FORCED_QUERY. // Don't bother with INVALID and FORCED_QUERY.
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return; return;
autocomplete_input_ = input; autocomplete_input_ = input;
...@@ -121,7 +122,7 @@ void HistoryQuickProvider::DoAutocomplete() { ...@@ -121,7 +122,7 @@ void HistoryQuickProvider::DoAutocomplete() {
// provider won't promote the URL-what-you-typed match to first // provider won't promote the URL-what-you-typed match to first
// for these inputs. // for these inputs.
const bool can_have_url_what_you_typed_match_first = const bool can_have_url_what_you_typed_match_first =
(autocomplete_input_.type() != AutocompleteInput::QUERY) && (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) &&
(!autocomplete_input_.parts().username.is_nonempty() || (!autocomplete_input_.parts().username.is_nonempty() ||
autocomplete_input_.parts().password.is_nonempty() || autocomplete_input_.parts().password.is_nonempty() ||
autocomplete_input_.parts().path.is_nonempty()); autocomplete_input_.parts().path.is_nonempty());
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/bookmarks/browser/bookmark_utils.h" #include "components/bookmarks/browser/bookmark_utils.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -336,7 +337,7 @@ HistoryURLProvider::VisitClassifier::VisitClassifier( ...@@ -336,7 +337,7 @@ HistoryURLProvider::VisitClassifier::VisitClassifier(
// and because the history backend strips auth creds, we'll get a bogus exact // and because the history backend strips auth creds, we'll get a bogus exact
// match below if the user has visited "site". // match below if the user has visited "site".
if (!url.is_valid() || if (!url.is_valid() ||
((input.type() == AutocompleteInput::UNKNOWN) && ((input.type() == metrics::OmniboxInputType::UNKNOWN) &&
input.parts().username.is_nonempty() && input.parts().username.is_nonempty() &&
!input.parts().password.is_nonempty() && !input.parts().password.is_nonempty() &&
!input.parts().path.is_nonempty())) !input.parts().path.is_nonempty()))
...@@ -410,8 +411,8 @@ void HistoryURLProvider::Start(const AutocompleteInput& input, ...@@ -410,8 +411,8 @@ void HistoryURLProvider::Start(const AutocompleteInput& input,
matches_.clear(); matches_.clear();
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return; return;
// Create a match for exactly what the user typed. This will only be used as // Create a match for exactly what the user typed. This will only be used as
...@@ -420,7 +421,7 @@ void HistoryURLProvider::Start(const AutocompleteInput& input, ...@@ -420,7 +421,7 @@ void HistoryURLProvider::Start(const AutocompleteInput& input,
const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text()); const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text());
// Don't do this for queries -- while we can sometimes mark up a match for // Don't do this for queries -- while we can sometimes mark up a match for
// this, it's not what the user wants, and just adds noise. // this, it's not what the user wants, and just adds noise.
if (input.type() != AutocompleteInput::QUERY) { if (input.type() != metrics::OmniboxInputType::QUERY) {
AutocompleteMatch what_you_typed(SuggestExactInput( AutocompleteMatch what_you_typed(SuggestExactInput(
input.text(), input.canonicalized_url(), trim_http)); input.text(), input.canonicalized_url(), trim_http));
what_you_typed.relevance = CalculateRelevance(WHAT_YOU_TYPED, 0); what_you_typed.relevance = CalculateRelevance(WHAT_YOU_TYPED, 0);
...@@ -596,8 +597,8 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, ...@@ -596,8 +597,8 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
// Otherwise, this is just low-quality noise. In the cases where we've parsed // Otherwise, this is just low-quality noise. In the cases where we've parsed
// as UNKNOWN, we'll still show an accidental search infobar if need be. // as UNKNOWN, we'll still show an accidental search infobar if need be.
bool have_what_you_typed_match = bool have_what_you_typed_match =
(params->input.type() != AutocompleteInput::QUERY) && (params->input.type() != metrics::OmniboxInputType::QUERY) &&
((params->input.type() != AutocompleteInput::UNKNOWN) || ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) ||
(classifier.type() == VisitClassifier::UNVISITED_INTRANET) || (classifier.type() == VisitClassifier::UNVISITED_INTRANET) ||
!params->trim_http || !params->trim_http ||
(AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0)); (AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0));
...@@ -827,9 +828,9 @@ bool HistoryURLProvider::FixupExactSuggestion( ...@@ -827,9 +828,9 @@ bool HistoryURLProvider::FixupExactSuggestion(
// between the input "c" and the input "c#", both of which will have empty // between the input "c" and the input "c#", both of which will have empty
// reference fragments.) // reference fragments.)
if ((type == UNVISITED_INTRANET) && if ((type == UNVISITED_INTRANET) &&
(input.type() != AutocompleteInput::URL) && url.username().empty() && (input.type() != metrics::OmniboxInputType::URL) &&
url.password().empty() && url.port().empty() && (url.path() == "/") && url.username().empty() && url.password().empty() && url.port().empty() &&
url.query().empty() && (url.path() == "/") && url.query().empty() &&
(parsed.CountCharactersBefore(url::Parsed::REF, true) != (parsed.CountCharactersBefore(url::Parsed::REF, true) !=
parsed.CountCharactersBefore(url::Parsed::REF, false))) { parsed.CountCharactersBefore(url::Parsed::REF, false))) {
return false; return false;
...@@ -858,7 +859,7 @@ bool HistoryURLProvider::CanFindIntranetURL( ...@@ -858,7 +859,7 @@ bool HistoryURLProvider::CanFindIntranetURL(
// third condition, but because FixupUserInput() can run and modify the // third condition, but because FixupUserInput() can run and modify the
// input's text and parts between Parse() and here, it seems better to be // input's text and parts between Parse() and here, it seems better to be
// paranoid and check. // paranoid and check.
if ((input.type() != AutocompleteInput::UNKNOWN) || if ((input.type() != metrics::OmniboxInputType::UNKNOWN) ||
!LowerCaseEqualsASCII(input.scheme(), url::kHttpScheme) || !LowerCaseEqualsASCII(input.scheme(), url::kHttpScheme) ||
!input.parts().host.is_nonempty()) !input.parts().host.is_nonempty())
return false; return false;
......
...@@ -670,14 +670,14 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) { ...@@ -670,14 +670,14 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) {
int relevance; int relevance;
AutocompleteInput::Type type; AutocompleteInput::Type type;
} test_cases[] = { } test_cases[] = {
{ "gooey", 1410, AutocompleteInput::UNKNOWN }, { "gooey", 1410, metrics::OmniboxInputType::UNKNOWN },
{ "gooey/", 1410, AutocompleteInput::URL }, { "gooey/", 1410, metrics::OmniboxInputType::URL },
{ "gooey#", 1200, AutocompleteInput::UNKNOWN }, { "gooey#", 1200, metrics::OmniboxInputType::UNKNOWN },
{ "gooey/#", 1200, AutocompleteInput::URL }, { "gooey/#", 1200, metrics::OmniboxInputType::URL },
{ "gooey#foo", 1200, AutocompleteInput::UNKNOWN }, { "gooey#foo", 1200, metrics::OmniboxInputType::UNKNOWN },
{ "gooey/#foo", 1200, AutocompleteInput::URL }, { "gooey/#foo", 1200, metrics::OmniboxInputType::URL },
{ "gooey# foo", 1200, AutocompleteInput::UNKNOWN }, { "gooey# foo", 1200, metrics::OmniboxInputType::UNKNOWN },
{ "gooey/# foo", 1200, AutocompleteInput::URL }, { "gooey/# foo", 1200, metrics::OmniboxInputType::URL },
}; };
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
SCOPED_TRACE(test_cases[i].input); SCOPED_TRACE(test_cases[i].input);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
...@@ -340,8 +341,8 @@ KeywordProvider::~KeywordProvider() {} ...@@ -340,8 +341,8 @@ KeywordProvider::~KeywordProvider() {}
bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
base::string16* keyword, base::string16* keyword,
base::string16* remaining_input) { base::string16* remaining_input) {
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return false; return false;
*keyword = TemplateURLService::CleanUserInputKeyword( *keyword = TemplateURLService::CleanUserInputKeyword(
...@@ -350,7 +351,7 @@ bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input, ...@@ -350,7 +351,7 @@ bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
} }
// static // static
int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type, int KeywordProvider::CalculateRelevance(metrics::OmniboxInputType::Type type,
bool complete, bool complete,
bool supports_replacement, bool supports_replacement,
bool prefer_keyword, bool prefer_keyword,
...@@ -365,10 +366,11 @@ int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type, ...@@ -365,10 +366,11 @@ int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type,
// make such a change, however, you should update this comment to // make such a change, however, you should update this comment to
// describe it, so it's clear why the functions diverge. // describe it, so it's clear why the functions diverge.
if (!complete) if (!complete)
return (type == AutocompleteInput::URL) ? 700 : 450; return (type == metrics::OmniboxInputType::URL) ? 700 : 450;
if (!supports_replacement || (allow_exact_keyword_match && prefer_keyword)) if (!supports_replacement || (allow_exact_keyword_match && prefer_keyword))
return 1500; return 1500;
return (allow_exact_keyword_match && (type == AutocompleteInput::QUERY)) ? return (allow_exact_keyword_match &&
(type == metrics::OmniboxInputType::QUERY)) ?
1450 : 1100; 1450 : 1100;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
class KeywordExtensionsDelegate; class KeywordExtensionsDelegate;
class Profile; class Profile;
...@@ -114,7 +115,7 @@ class KeywordProvider : public AutocompleteProvider { ...@@ -114,7 +115,7 @@ class KeywordProvider : public AutocompleteProvider {
// matches" mode, and whether the keyword supports replacement. // matches" mode, and whether the keyword supports replacement.
// If |allow_exact_keyword_match| is false, the relevance for complete // If |allow_exact_keyword_match| is false, the relevance for complete
// keywords that support replacements is degraded. // keywords that support replacements is degraded.
static int CalculateRelevance(AutocompleteInput::Type type, static int CalculateRelevance(metrics::OmniboxInputType::Type type,
bool complete, bool complete,
bool support_replacement, bool support_replacement,
bool prefer_keyword, bool prefer_keyword,
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "chrome/browser/ui/search/instant_controller.h" #include "chrome/browser/ui/search/instant_controller.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "net/base/escape.h" #include "net/base/escape.h"
...@@ -176,7 +177,7 @@ int SearchProvider::CalculateRelevanceForKeywordVerbatim( ...@@ -176,7 +177,7 @@ int SearchProvider::CalculateRelevanceForKeywordVerbatim(
// describe it, so it's clear why the functions diverge. // describe it, so it's clear why the functions diverge.
if (prefer_keyword) if (prefer_keyword)
return 1500; return 1500;
return (type == AutocompleteInput::QUERY) ? 1450 : 1100; return (type == metrics::OmniboxInputType::QUERY) ? 1450 : 1100;
} }
void SearchProvider::Start(const AutocompleteInput& input, void SearchProvider::Start(const AutocompleteInput& input,
...@@ -191,7 +192,7 @@ void SearchProvider::Start(const AutocompleteInput& input, ...@@ -191,7 +192,7 @@ void SearchProvider::Start(const AutocompleteInput& input,
field_trial_triggered_ = false; field_trial_triggered_ = false;
// Can't return search/suggest results for bogus input or without a profile. // Can't return search/suggest results for bogus input or without a profile.
if (!profile_ || (input.type() == AutocompleteInput::INVALID)) { if (!profile_ || (input.type() == metrics::OmniboxInputType::INVALID)) {
Stop(true); Stop(true);
return; return;
} }
...@@ -549,7 +550,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const { ...@@ -549,7 +550,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
// FORCED_QUERY means the user is explicitly asking us to search for this, so // FORCED_QUERY means the user is explicitly asking us to search for this, so
// we assume it isn't a URL and/or there isn't private data. // we assume it isn't a URL and/or there isn't private data.
if (input_.type() == AutocompleteInput::FORCED_QUERY) if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY)
return true; return true;
// Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't // Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't
...@@ -565,7 +566,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const { ...@@ -565,7 +566,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) && if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) &&
!LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) && !LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
!LowerCaseEqualsASCII(input_.scheme(), url::kFtpScheme)) !LowerCaseEqualsASCII(input_.scheme(), url::kFtpScheme))
return (input_.type() == AutocompleteInput::QUERY); return (input_.type() == metrics::OmniboxInputType::QUERY);
// Don't send URLs with usernames, queries or refs. Some of these are // Don't send URLs with usernames, queries or refs. Some of these are
// private, and the Suggest server is unlikely to have any useful results // private, and the Suggest server is unlikely to have any useful results
...@@ -579,7 +580,8 @@ bool SearchProvider::IsQuerySuitableForSuggest() const { ...@@ -579,7 +580,8 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
const url::Parsed& parts = input_.parts(); const url::Parsed& parts = input_.parts();
if (parts.username.is_nonempty() || parts.port.is_nonempty() || if (parts.username.is_nonempty() || parts.port.is_nonempty() ||
parts.query.is_nonempty() || parts.query.is_nonempty() ||
(parts.ref.is_nonempty() && (input_.type() == AutocompleteInput::URL))) (parts.ref.is_nonempty() &&
(input_.type() == metrics::OmniboxInputType::URL)))
return false; return false;
// Don't send anything for https except the hostname. Hostnames are OK // Don't send anything for https except the hostname. Hostnames are OK
...@@ -812,7 +814,7 @@ bool SearchProvider::HasKeywordDefaultMatchInKeywordMode() const { ...@@ -812,7 +814,7 @@ bool SearchProvider::HasKeywordDefaultMatchInKeywordMode() const {
bool SearchProvider::IsTopMatchSearchWithURLInput() const { bool SearchProvider::IsTopMatchSearchWithURLInput() const {
ACMatches::const_iterator first_match = FindTopMatch(); ACMatches::const_iterator first_match = FindTopMatch();
return (input_.type() == AutocompleteInput::URL) && return (input_.type() == metrics::OmniboxInputType::URL) &&
(first_match != matches_.end()) && (first_match != matches_.end()) &&
(first_match->relevance > CalculateRelevanceForVerbatim()) && (first_match->relevance > CalculateRelevanceForVerbatim()) &&
(first_match->type != AutocompleteMatchType::NAVSUGGEST) && (first_match->type != AutocompleteMatchType::NAVSUGGEST) &&
...@@ -841,7 +843,7 @@ void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results, ...@@ -841,7 +843,7 @@ void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results,
base::TimeTicks start_time(base::TimeTicks::Now()); base::TimeTicks start_time(base::TimeTicks::Now());
bool prevent_inline_autocomplete = input_.prevent_inline_autocomplete() || bool prevent_inline_autocomplete = input_.prevent_inline_autocomplete() ||
(input_.type() == AutocompleteInput::URL); (input_.type() == metrics::OmniboxInputType::URL);
const base::string16& input_text = const base::string16& input_text =
is_keyword ? keyword_input_.text() : input_.text(); is_keyword ? keyword_input_.text() : input_.text();
bool input_multiple_words = HasMultipleWords(input_text); bool input_multiple_words = HasMultipleWords(input_text);
...@@ -987,12 +989,12 @@ int SearchProvider::CalculateRelevanceForVerbatim() const { ...@@ -987,12 +989,12 @@ int SearchProvider::CalculateRelevanceForVerbatim() const {
int SearchProvider:: int SearchProvider::
CalculateRelevanceForVerbatimIgnoringKeywordModeState() const { CalculateRelevanceForVerbatimIgnoringKeywordModeState() const {
switch (input_.type()) { switch (input_.type()) {
case AutocompleteInput::UNKNOWN: case metrics::OmniboxInputType::UNKNOWN:
case AutocompleteInput::QUERY: case metrics::OmniboxInputType::QUERY:
case AutocompleteInput::FORCED_QUERY: case metrics::OmniboxInputType::FORCED_QUERY:
return kNonURLVerbatimRelevance; return kNonURLVerbatimRelevance;
case AutocompleteInput::URL: case metrics::OmniboxInputType::URL:
return 850; return 850;
default: default:
...@@ -1059,7 +1061,7 @@ int SearchProvider::CalculateRelevanceForHistory( ...@@ -1059,7 +1061,7 @@ int SearchProvider::CalculateRelevanceForHistory(
// a different way. // a different way.
int base_score; int base_score;
if (is_primary_provider) if (is_primary_provider)
base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050; base_score = (input_.type() == metrics::OmniboxInputType::URL) ? 750 : 1050;
else else
base_score = 200; base_score = 200;
return std::max(0, base_score - score_discount); return std::max(0, base_score - score_discount);
...@@ -1099,7 +1101,7 @@ AutocompleteMatch SearchProvider::NavigationToMatch( ...@@ -1099,7 +1101,7 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
&inline_autocomplete_offset)); &inline_autocomplete_offset));
// Preserve the forced query '?' prefix in |match.fill_into_edit|. // Preserve the forced query '?' prefix in |match.fill_into_edit|.
// Otherwise, user edits to a suggestion would show non-Search results. // Otherwise, user edits to a suggestion would show non-Search results.
if (input_.type() == AutocompleteInput::FORCED_QUERY) { if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY) {
match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); match.fill_into_edit.insert(0, base::ASCIIToUTF16("?"));
if (inline_autocomplete_offset != base::string16::npos) if (inline_autocomplete_offset != base::string16::npos)
++inline_autocomplete_offset; ++inline_autocomplete_offset;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/autocomplete/base_search_provider.h" #include "chrome/browser/autocomplete/base_search_provider.h"
#include "chrome/browser/history/history_types.h" #include "chrome/browser/history/history_types.h"
#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
class Profile; class Profile;
class SearchProviderTest; class SearchProviderTest;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "url/url_parse.h" #include "url/url_parse.h"
namespace { namespace {
...@@ -70,8 +71,8 @@ void ShortcutsProvider::Start(const AutocompleteInput& input, ...@@ -70,8 +71,8 @@ void ShortcutsProvider::Start(const AutocompleteInput& input,
bool minimal_changes) { bool minimal_changes) {
matches_.clear(); matches_.clear();
if ((input.type() == AutocompleteInput::INVALID) || if ((input.type() == metrics::OmniboxInputType::INVALID) ||
(input.type() == AutocompleteInput::FORCED_QUERY)) (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return; return;
if (input.text().empty()) if (input.text().empty())
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
#include "net/base/escape.h" #include "net/base/escape.h"
...@@ -93,7 +94,7 @@ void ZeroSuggestProvider::RegisterProfilePrefs( ...@@ -93,7 +94,7 @@ void ZeroSuggestProvider::RegisterProfilePrefs(
void ZeroSuggestProvider::Start(const AutocompleteInput& input, void ZeroSuggestProvider::Start(const AutocompleteInput& input,
bool minimal_changes) { bool minimal_changes) {
matches_.clear(); matches_.clear();
if (input.type() == AutocompleteInput::INVALID) if (input.type() == metrics::OmniboxInputType::INVALID)
return; return;
Stop(true); Stop(true);
......
...@@ -17,30 +17,14 @@ ...@@ -17,30 +17,14 @@
#include "chrome/browser/omnibox/omnibox_log.h" #include "chrome/browser/omnibox/omnibox_log.h"
#include "chrome/browser/ui/browser_otr_state.h" #include "chrome/browser/ui/browser_otr_state.h"
#include "components/metrics/metrics_log.h" #include "components/metrics/metrics_log.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
using metrics::OmniboxEventProto; using metrics::OmniboxEventProto;
namespace { namespace {
OmniboxEventProto::InputType AsOmniboxEventInputType(
AutocompleteInput::Type type) {
switch (type) {
case AutocompleteInput::INVALID:
return OmniboxEventProto::INVALID;
case AutocompleteInput::UNKNOWN:
return OmniboxEventProto::UNKNOWN;
case AutocompleteInput::URL:
return OmniboxEventProto::URL;
case AutocompleteInput::QUERY:
return OmniboxEventProto::QUERY;
case AutocompleteInput::FORCED_QUERY:
return OmniboxEventProto::FORCED_QUERY;
}
NOTREACHED();
return OmniboxEventProto::INVALID;
}
OmniboxEventProto::Suggestion::ResultType AsOmniboxEventResultType( OmniboxEventProto::Suggestion::ResultType AsOmniboxEventResultType(
AutocompleteMatch::Type type) { AutocompleteMatch::Type type) {
switch (type) { switch (type) {
...@@ -182,7 +166,7 @@ void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) { ...@@ -182,7 +166,7 @@ void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) {
} }
omnibox_event->set_current_page_classification( omnibox_event->set_current_page_classification(
AsOmniboxEventPageClassification(log.current_page_classification)); AsOmniboxEventPageClassification(log.current_page_classification));
omnibox_event->set_input_type(AsOmniboxEventInputType(log.input_type)); omnibox_event->set_input_type(log.input_type);
// We consider a paste-and-search/paste-and-go action to have a closed popup // We consider a paste-and-search/paste-and-go action to have a closed popup
// (as explained in omnibox_event.proto) even if it was not, because such // (as explained in omnibox_event.proto) even if it was not, because such
// actions ignore the contents of the popup so it doesn't matter that it was // actions ignore the contents of the popup so it doesn't matter that it was
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
OmniboxLog::OmniboxLog( OmniboxLog::OmniboxLog(
const base::string16& text, const base::string16& text,
bool just_deleted_text, bool just_deleted_text,
AutocompleteInput::Type input_type, metrics::OmniboxInputType::Type input_type,
bool is_popup_open, bool is_popup_open,
size_t selected_index, size_t selected_index,
bool is_paste_and_go, bool is_paste_and_go,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/sessions/session_id.h" #include "chrome/browser/sessions/session_id.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
class AutocompleteResult; class AutocompleteResult;
...@@ -21,7 +22,7 @@ struct OmniboxLog { ...@@ -21,7 +22,7 @@ struct OmniboxLog {
OmniboxLog( OmniboxLog(
const base::string16& text, const base::string16& text,
bool just_deleted_text, bool just_deleted_text,
AutocompleteInput::Type input_type, metrics::OmniboxInputType::Type input_type,
bool is_popup_open, bool is_popup_open,
size_t selected_index, size_t selected_index,
bool is_paste_and_go, bool is_paste_and_go,
...@@ -41,7 +42,7 @@ struct OmniboxLog { ...@@ -41,7 +42,7 @@ struct OmniboxLog {
bool just_deleted_text; bool just_deleted_text;
// The detected type of the user's input. // The detected type of the user's input.
AutocompleteInput::Type input_type; metrics::OmniboxInputType::Type input_type;
// True if the popup is open. // True if the popup is open.
bool is_popup_open; bool is_popup_open;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "chrome/browser/autocomplete/search_provider.h" #include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h" #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
'metrics/proto/chrome_user_metrics_extension.proto', 'metrics/proto/chrome_user_metrics_extension.proto',
'metrics/proto/histogram_event.proto', 'metrics/proto/histogram_event.proto',
'metrics/proto/omnibox_event.proto', 'metrics/proto/omnibox_event.proto',
'metrics/proto/omnibox_input_type.proto',
'metrics/proto/perf_data.proto', 'metrics/proto/perf_data.proto',
'metrics/proto/profiler_event.proto', 'metrics/proto/profiler_event.proto',
'metrics/proto/sampled_profile.proto', 'metrics/proto/sampled_profile.proto',
......
...@@ -10,6 +10,8 @@ option optimize_for = LITE_RUNTIME; ...@@ -10,6 +10,8 @@ option optimize_for = LITE_RUNTIME;
package metrics; package metrics;
import "omnibox_input_type.proto";
// Next tag: 17 // Next tag: 17
message OmniboxEventProto { message OmniboxEventProto {
// The timestamp for the event, in seconds since the epoch. // The timestamp for the event, in seconds since the epoch.
...@@ -130,18 +132,7 @@ message OmniboxEventProto { ...@@ -130,18 +132,7 @@ message OmniboxEventProto {
} }
optional PageClassification current_page_classification = 10; optional PageClassification current_page_classification = 10;
// What kind of input the user provided. optional OmniboxInputType.Type input_type = 8;
enum InputType {
INVALID = 0; // Empty input (should not reach here)
UNKNOWN = 1; // Valid input whose type cannot be determined
REQUESTED_URL = 2; // DEPRECATED. Input autodetected as UNKNOWN, which the
// user wants to treat as an URL by specifying a
// desired_tld
URL = 3; // Input autodetected as a URL
QUERY = 4; // Input autodetected as a query
FORCED_QUERY = 5; // Input forced to be a query by an initial '?'
}
optional InputType input_type = 8;
// An enum used in multiple places below. // An enum used in multiple places below.
enum ProviderType { enum ProviderType {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Stores information about an omnibox interaction.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package metrics.OmniboxInputType;
// What kind of input the user provided.
// Note that the type below may be misleading. For example, "http:/" alone
// cannot be opened as a URL, so it is marked as a QUERY; yet the user
// probably intends to type more and have it eventually become a URL, so we
// need to make sure we still run it through inline autocomplete.
enum Type {
// Empty input (should not reach here)
INVALID = 0;
// Valid input whose type cannot be determined
UNKNOWN = 1;
// DEPRECATED. Input autodetected as UNKNOWN, which the user wants to treat
// as an URL by specifying a desired_tld.
DEPRECATED_REQUESTED_URL = 2;
// Input autodetected as a URL
URL = 3;
// Input autodetected as a query
QUERY = 4;
// Input forced to be a query by an initial '?'
FORCED_QUERY = 5;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment