summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-08 00:02:22 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-08 00:02:22 +0000
commit3dc75b1cccf30ccce1f13553353c21c21d6a3e34 (patch)
tree2ae602d45cb7006f3dffe30cc8c9d43038b0b5df
parent702484bde5a044d224230f08ea12aeeb7cd069d6 (diff)
downloadchromium_src-3dc75b1cccf30ccce1f13553353c21c21d6a3e34.zip
chromium_src-3dc75b1cccf30ccce1f13553353c21c21d6a3e34.tar.gz
chromium_src-3dc75b1cccf30ccce1f13553353c21c21d6a3e34.tar.bz2
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
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.cc98
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.h13
-rw-r--r--chrome/browser/autocomplete/autocomplete_input_unittest.cc227
-rw-r--r--chrome/browser/autocomplete/autocomplete_provider.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_result.cc8
-rw-r--r--chrome/browser/autocomplete/base_search_provider.cc8
-rw-r--r--chrome/browser/autocomplete/bookmark_provider.cc3
-rw-r--r--chrome/browser/autocomplete/builtin_provider.cc7
-rw-r--r--chrome/browser/autocomplete/extension_app_provider.cc18
-rw-r--r--chrome/browser/autocomplete/extension_app_provider.h3
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.cc7
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc21
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc16
-rw-r--r--chrome/browser/autocomplete/keyword_provider.cc12
-rw-r--r--chrome/browser/autocomplete/keyword_provider.h3
-rw-r--r--chrome/browser/autocomplete/search_provider.cc28
-rw-r--r--chrome/browser/autocomplete/search_provider.h1
-rw-r--r--chrome/browser/autocomplete/shortcuts_provider.cc5
-rw-r--r--chrome/browser/autocomplete/zero_suggest_provider.cc3
-rw-r--r--chrome/browser/metrics/omnibox_metrics_provider.cc22
-rw-r--r--chrome/browser/omnibox/omnibox_log.cc2
-rw-r--r--chrome/browser/omnibox/omnibox_log.h5
-rw-r--r--chrome/browser/ui/app_list/search/omnibox_provider.cc1
-rw-r--r--components/metrics.gypi1
-rw-r--r--components/metrics/proto/omnibox_event.proto15
-rw-r--r--components/metrics/proto/omnibox_input_type.proto37
26 files changed, 303 insertions, 263 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc
index 36652d4..2e18481 100644
--- a/chrome/browser/autocomplete/autocomplete_input.cc
+++ b/chrome/browser/autocomplete/autocomplete_input.cc
@@ -32,7 +32,7 @@ void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed,
AutocompleteInput::AutocompleteInput()
: cursor_position_(base::string16::npos),
current_page_classification_(AutocompleteInput::INVALID_SPEC),
- type_(INVALID),
+ type_(metrics::OmniboxInputType::INVALID),
prevent_inline_autocomplete_(false),
prefer_keyword_(false),
allow_exact_keyword_match_(true),
@@ -69,10 +69,11 @@ AutocompleteInput::AutocompleteInput(
GURL canonicalized_url;
type_ = Parse(text_, desired_tld, &parts_, &scheme_, &canonicalized_url);
- if (type_ == INVALID)
+ if (type_ == metrics::OmniboxInputType::INVALID)
return;
- if (((type_ == UNKNOWN) || (type_ == URL)) &&
+ if (((type_ == metrics::OmniboxInputType::UNKNOWN) ||
+ (type_ == metrics::OmniboxInputType::URL)) &&
canonicalized_url.is_valid() &&
(!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() ||
canonicalized_url.SchemeIsFileSystem() ||
@@ -98,9 +99,10 @@ AutocompleteInput::~AutocompleteInput() {
// static
size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary(
- Type type,
+ AutocompleteInput::Type type,
base::string16* text) {
- if (type != FORCED_QUERY || text->empty() || (*text)[0] != L'?')
+ if ((type != metrics::OmniboxInputType::FORCED_QUERY) || text->empty() ||
+ (*text)[0] != L'?')
return 0;
// Drop the leading '?'.
text->erase(0, 1);
@@ -108,18 +110,17 @@ size_t AutocompleteInput::RemoveForcedQueryStringIfNecessary(
}
// static
-std::string AutocompleteInput::TypeToString(Type type) {
+std::string AutocompleteInput::TypeToString(AutocompleteInput::Type type) {
switch (type) {
- case INVALID: return "invalid";
- case UNKNOWN: return "unknown";
- case URL: return "url";
- case QUERY: return "query";
- case FORCED_QUERY: return "forced-query";
-
- default:
- NOTREACHED();
- return std::string();
+ case metrics::OmniboxInputType::INVALID: return "invalid";
+ case metrics::OmniboxInputType::UNKNOWN: return "unknown";
+ case metrics::OmniboxInputType::DEPRECATED_REQUESTED_URL:
+ return "deprecated-requested-url";
+ case metrics::OmniboxInputType::URL: return "url";
+ case metrics::OmniboxInputType::QUERY: return "query";
+ case metrics::OmniboxInputType::FORCED_QUERY: return "forced-query";
}
+ return std::string();
}
// static
@@ -131,12 +132,12 @@ AutocompleteInput::Type AutocompleteInput::Parse(
GURL* canonicalized_url) {
size_t first_non_white = text.find_first_not_of(base::kWhitespaceUTF16, 0);
if (first_non_white == base::string16::npos)
- return INVALID; // All whitespace.
+ return metrics::OmniboxInputType::INVALID; // All whitespace.
if (text[first_non_white] == L'?') {
// If the first non-whitespace character is a '?', we magically treat this
// as a query.
- return FORCED_QUERY;
+ return metrics::OmniboxInputType::FORCED_QUERY;
}
// Ask our parsing back-end to help us understand what the user typed. We
@@ -159,13 +160,13 @@ AutocompleteInput::Type AutocompleteInput::Parse(
*canonicalized_url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text),
base::UTF16ToUTF8(desired_tld));
if (!canonicalized_url->is_valid())
- return QUERY;
+ return metrics::OmniboxInputType::QUERY;
if (LowerCaseEqualsASCII(parsed_scheme, url::kFileScheme)) {
// A user might or might not type a scheme when entering a file URL. In
// either case, |parsed_scheme| will tell us that this is a file URL, but
// |parts->scheme| might be empty, e.g. if the user typed "C:\foo".
- return URL;
+ return metrics::OmniboxInputType::URL;
}
// If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it
@@ -186,7 +187,7 @@ AutocompleteInput::Type AutocompleteInput::Parse(
LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) ||
LowerCaseEqualsASCII(parsed_scheme, url::kJavaScriptScheme) ||
LowerCaseEqualsASCII(parsed_scheme, url::kDataScheme))
- return URL;
+ return metrics::OmniboxInputType::URL;
// Not an internal protocol. Check and see if the user has explicitly
// opened this scheme as a URL before, or if the "scheme" is actually a
@@ -202,12 +203,12 @@ AutocompleteInput::Type AutocompleteInput::Parse(
base::UTF16ToUTF8(parsed_scheme), true);
switch (block_state) {
case ExternalProtocolHandler::DONT_BLOCK:
- return URL;
+ return metrics::OmniboxInputType::URL;
case ExternalProtocolHandler::BLOCK:
// If we don't want the user to open the URL, don't let it be navigated
// to at all.
- return QUERY;
+ return metrics::OmniboxInputType::QUERY;
default: {
// We don't know about this scheme. It might be that the user typed a
@@ -218,13 +219,14 @@ AutocompleteInput::Type AutocompleteInput::Parse(
url::Parsed http_parts;
base::string16 http_scheme;
GURL http_canonicalized_url;
- Type http_type = Parse(http_scheme_prefix + text, desired_tld,
- &http_parts, &http_scheme,
- &http_canonicalized_url);
+ AutocompleteInput::Type http_type =
+ Parse(http_scheme_prefix + text, desired_tld, &http_parts,
+ &http_scheme, &http_canonicalized_url);
DCHECK_EQ(std::string(url::kHttpScheme),
base::UTF16ToUTF8(http_scheme));
- if ((http_type == URL) && http_parts.username.is_nonempty() &&
+ if ((http_type == metrics::OmniboxInputType::URL) &&
+ http_parts.username.is_nonempty() &&
http_parts.password.is_nonempty()) {
// Manually re-jigger the parsed parts to match |text| (without the
// http scheme added).
@@ -248,7 +250,7 @@ AutocompleteInput::Type AutocompleteInput::Parse(
scheme->clear();
*canonicalized_url = http_canonicalized_url;
- return URL;
+ return metrics::OmniboxInputType::URL;
}
// We don't know about this scheme and it doesn't look like the user
@@ -257,7 +259,7 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// the option of treating it as a URL if we're wrong.
// Note that SegmentURL() is smart so we aren't tricked by "c:\foo" or
// "www.example.com:81" in this case.
- return UNKNOWN;
+ return metrics::OmniboxInputType::UNKNOWN;
}
}
}
@@ -271,7 +273,7 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// valid, non-standard URL; for standard URLs, an empty host would have
// resulted in an invalid |canonicalized_url| above.)
if (!parts->host.is_nonempty())
- return QUERY;
+ return metrics::OmniboxInputType::QUERY;
// Sanity-check: GURL should have failed to canonicalize this URL if it had an
// invalid port.
@@ -297,11 +299,14 @@ AutocompleteInput::Type AutocompleteInput::Parse(
base::UTF16ToUTF8(host_with_tld),
net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
- if (tld_length != std::string::npos)
- return URL; // Something like "99999999999" that looks like a bad IP
- // address, but becomes valid on attaching a TLD.
+ if (tld_length != std::string::npos) {
+ // Something like "99999999999" that looks like a bad IP
+ // address, but becomes valid on attaching a TLD.
+ return metrics::OmniboxInputType::URL;
+ }
}
- return QUERY; // Could be a broken IP address, etc.
+ // Could be a broken IP address, etc.
+ return metrics::OmniboxInputType::QUERY;
}
@@ -335,18 +340,19 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// These are rare, though probably possible in intranets.
return (parts->scheme.is_nonempty() ||
((registry_length != 0) &&
- (host.find(' ') == base::string16::npos))) ? UNKNOWN : QUERY;
+ (host.find(' ') == base::string16::npos))) ?
+ metrics::OmniboxInputType::UNKNOWN : metrics::OmniboxInputType::QUERY;
}
// Now that we've ruled out all schemes other than http or https and done a
// little more sanity checking, the presence of a scheme means this is likely
// a URL.
if (parts->scheme.is_nonempty())
- return URL;
+ return metrics::OmniboxInputType::URL;
// See if the host is an IP address.
if (host_info.family == url::CanonHostInfo::IPV6)
- return URL;
+ return metrics::OmniboxInputType::URL;
// If the user originally typed a host that looks like an IP address (a
// dotted quad), they probably want to open it. If the original input was
// something else (like a single number), they probably wanted to search for
@@ -359,27 +365,27 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// below.
if ((host_info.family == url::CanonHostInfo::IPV4) &&
(host_info.num_ipv4_components == 4))
- return URL;
+ return metrics::OmniboxInputType::URL;
// Presence of a password means this is likely a URL. Note that unless the
// user has typed an explicit "http://" or similar, we'll probably think that
// the username is some unknown scheme, and bail out in the scheme-handling
// code above.
if (parts->password.is_nonempty())
- return URL;
+ return metrics::OmniboxInputType::URL;
// Trailing slashes force the input to be treated as a URL.
if (parts->path.is_nonempty()) {
char c = text[parts->path.end() - 1];
if ((c == '\\') || (c == '/'))
- return URL;
+ return metrics::OmniboxInputType::URL;
}
// If there is more than one recognized non-host component, this is likely to
// be a URL, even if the TLD is unknown (in which case this is likely an
// intranet URL).
if (NumNonHostComponents(*parts) > 1)
- return URL;
+ return metrics::OmniboxInputType::URL;
// If the host has a known TLD or a port, it's probably a URL, with the
// following exceptions:
@@ -392,14 +398,16 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// Note that we special-case "localhost" as a known hostname.
if ((host_info.family != url::CanonHostInfo::IPV4) &&
((registry_length != 0) || (host == base::ASCIIToUTF16("localhost") ||
- parts->port.is_nonempty())))
- return parts->username.is_nonempty() ? UNKNOWN : URL;
+ parts->port.is_nonempty()))) {
+ return parts->username.is_nonempty() ? metrics::OmniboxInputType::UNKNOWN :
+ metrics::OmniboxInputType::URL;
+ }
// If we reach this point, we know there's no known TLD on the input, so if
// the user wishes to add a desired_tld, the fixup code will oblige; thus this
// is a URL.
if (!desired_tld.empty())
- return URL;
+ return metrics::OmniboxInputType::URL;
// No scheme, password, port, path, and no known TLD on the host.
// This could be:
@@ -418,7 +426,7 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// QUERY. Since this is indistinguishable from the case above, and this
// case is much more likely, claim these are UNKNOWN, which should default
// to the right thing and let users correct us on a case-by-case basis.
- return UNKNOWN;
+ return metrics::OmniboxInputType::UNKNOWN;
}
// static
@@ -523,7 +531,7 @@ void AutocompleteInput::Clear() {
cursor_position_ = base::string16::npos;
current_url_ = GURL();
current_page_classification_ = AutocompleteInput::INVALID_SPEC;
- type_ = INVALID;
+ type_ = metrics::OmniboxInputType::INVALID;
parts_ = url::Parsed();
scheme_.clear();
canonicalized_url_ = GURL();
diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h
index b923e7b..46dbdd4 100644
--- a/chrome/browser/autocomplete/autocomplete_input.h
+++ b/chrome/browser/autocomplete/autocomplete_input.h
@@ -10,23 +10,14 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/strings/string16.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "url/gurl.h"
#include "url/url_parse.h"
// The user input for an autocomplete query. Allows copying.
class AutocompleteInput {
public:
- // 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 {
- 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 '?'
- };
+ typedef metrics::OmniboxInputType::Type Type;
// The type of page currently displayed.
// Note: when adding an element to this enum, please add it at the end
diff --git a/chrome/browser/autocomplete/autocomplete_input_unittest.cc b/chrome/browser/autocomplete/autocomplete_input_unittest.cc
index bf5bee7..b131e6b 100644
--- a/chrome/browser/autocomplete/autocomplete_input_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_input_unittest.cc
@@ -18,113 +18,121 @@ TEST(AutocompleteInputTest, InputType) {
const base::string16 input;
const AutocompleteInput::Type type;
} input_cases[] = {
- { base::string16(), AutocompleteInput::INVALID },
- { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY },
- { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY },
- { ASCIIToUTF16("?foo bar"), AutocompleteInput::FORCED_QUERY },
- { ASCIIToUTF16("?http://foo.com/bar"), AutocompleteInput::FORCED_QUERY },
- { ASCIIToUTF16("foo"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("localhost"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo.c"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("-foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo-.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo_.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo.-com"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo/"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo/bar"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo/bar%00"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo/bar/"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo/bar baz\\"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo.com/bar"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo;bar"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo/bar baz"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo bar.com"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo bar"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo+bar"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo+bar.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("\"foo:bar\""), AutocompleteInput::QUERY },
- { ASCIIToUTF16("link:foo.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("foo:81"), AutocompleteInput::URL },
- { ASCIIToUTF16("localhost:8080"), AutocompleteInput::URL },
- { ASCIIToUTF16("www.foo.com:81"), AutocompleteInput::URL },
- { ASCIIToUTF16("foo.com:123456"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("foo.com:abc"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("1.2.3.4:abc"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("user@foo.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("user@foo/z"), AutocompleteInput::URL },
- { ASCIIToUTF16("user@foo/z z"), AutocompleteInput::URL },
- { ASCIIToUTF16("user@foo.com/z"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("user:pass@!foo.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("user:pass@foo"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@foo.c"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@foo.com:81"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@foo:81"), AutocompleteInput::URL },
- { ASCIIToUTF16("1.2"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("1.2/45"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("1.2:45"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("user@1.2:45"), AutocompleteInput::URL },
- { ASCIIToUTF16("user@foo:45"), AutocompleteInput::URL },
- { ASCIIToUTF16("user:pass@1.2:45"), AutocompleteInput::URL },
- { ASCIIToUTF16("host?query"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("host#ref"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("host/path?query"), AutocompleteInput::URL },
- { ASCIIToUTF16("host/path#ref"), AutocompleteInput::URL },
- { ASCIIToUTF16("en.wikipedia.org/wiki/Jim Beam"), AutocompleteInput::URL },
+ { base::string16(), metrics::OmniboxInputType::INVALID },
+ { ASCIIToUTF16("?"), metrics::OmniboxInputType::FORCED_QUERY },
+ { ASCIIToUTF16("?foo"), metrics::OmniboxInputType::FORCED_QUERY },
+ { ASCIIToUTF16("?foo bar"), metrics::OmniboxInputType::FORCED_QUERY },
+ { ASCIIToUTF16("?http://foo.com/bar"), metrics::OmniboxInputType::FORCED_QUERY },
+ { ASCIIToUTF16("foo"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("localhost"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo.c"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("-foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo-.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo_.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo.-com"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo/"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo/bar"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo/bar%00"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo/bar/"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo/bar baz\\"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo.com/bar"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo;bar"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo/bar baz"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo bar.com"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo bar"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo+bar"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo+bar.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("\"foo:bar\""), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("link:foo.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("foo:81"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("localhost:8080"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("www.foo.com:81"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("foo.com:123456"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("foo.com:abc"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("1.2.3.4:abc"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("user@foo.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("user@foo/z"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user@foo/z z"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user@foo.com/z"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("user:pass@!foo.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("user:pass@foo"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@foo.c"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@foo.com:81"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@foo:81"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("1.2"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("1.2/45"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("1.2:45"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("user@1.2:45"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user@foo:45"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("user:pass@1.2:45"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("host?query"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("host#ref"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("host/path?query"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("host/path#ref"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("en.wikipedia.org/wiki/Jim Beam"),
+ metrics::OmniboxInputType::URL },
// In Chrome itself, mailto: will get handled by ShellExecute, but in
// unittest mode, we don't have the data loaded in the external protocol
// handler to know this.
- // { ASCIIToUTF16("mailto:abuse@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("view-source:http://www.foo.com/"), AutocompleteInput::URL },
- { ASCIIToUTF16("javascript:alert(\"Hi there\");"), AutocompleteInput::URL },
+ // { ASCIIToUTF16("mailto:abuse@foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("view-source:http://www.foo.com/"),
+ metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("javascript:alert(\"Hi there\");"),
+ metrics::OmniboxInputType::URL },
#if defined(OS_WIN)
- { ASCIIToUTF16("C:\\Program Files"), AutocompleteInput::URL },
- { ASCIIToUTF16("\\\\Server\\Folder\\File"), AutocompleteInput::URL },
+ { ASCIIToUTF16("C:\\Program Files"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("\\\\Server\\Folder\\File"),
+ metrics::OmniboxInputType::URL },
#endif // defined(OS_WIN)
- { ASCIIToUTF16("http:foo"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo.c"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo_bar.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo/bar%00"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("http://foo/bar baz"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://-foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo-.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://foo_.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("http://foo.-com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("http://_foo_.com"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("http://foo.com:abc"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("http://foo.com:123456"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("http://1.2.3.4:abc"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("http:user@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://user@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http:user:pass@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://user:pass@foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://1.2"), AutocompleteInput::URL },
- { ASCIIToUTF16("http://1.2/45"), AutocompleteInput::URL },
- { ASCIIToUTF16("http:ps/2 games"), AutocompleteInput::URL },
- { ASCIIToUTF16("https://foo.com"), AutocompleteInput::URL },
- { ASCIIToUTF16("127.0.0.1"), AutocompleteInput::URL },
- { ASCIIToUTF16("127.0.1"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("127.0.1/"), AutocompleteInput::URL },
- { ASCIIToUTF16("browser.tabs.closeButtons"), AutocompleteInput::UNKNOWN },
- { base::WideToUTF16(L"\u6d4b\u8bd5"), AutocompleteInput::UNKNOWN },
- { ASCIIToUTF16("[2001:]"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("[2001:dB8::1]"), AutocompleteInput::URL },
- { ASCIIToUTF16("192.168.0.256"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("[foo.com]"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("filesystem:http://a.com/t/bar"), AutocompleteInput::URL },
- { ASCIIToUTF16("filesystem:http://a.com/"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("filesystem:file://"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("filesystem:http"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("filesystem:"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("chrome-search://"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("chrome-devtools:"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("about://f;"), AutocompleteInput::QUERY },
- { ASCIIToUTF16("://w"), AutocompleteInput::QUERY },
- { ASCIIToUTF16(":w"), AutocompleteInput::QUERY },
+ { ASCIIToUTF16("http:foo"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo.c"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo_bar.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo/bar%00"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("http://foo/bar baz"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://-foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo-.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://foo_.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("http://foo.-com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("http://_foo_.com"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("http://foo.com:abc"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("http://foo.com:123456"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("http://1.2.3.4:abc"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("http:user@foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://user@foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http:user:pass@foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://user:pass@foo.com"),
+ metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://1.2"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http://1.2/45"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("http:ps/2 games"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("https://foo.com"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("127.0.0.1"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("127.0.1"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("127.0.1/"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("browser.tabs.closeButtons"),
+ metrics::OmniboxInputType::UNKNOWN },
+ { base::WideToUTF16(L"\u6d4b\u8bd5"), metrics::OmniboxInputType::UNKNOWN },
+ { ASCIIToUTF16("[2001:]"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("[2001:dB8::1]"), metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("192.168.0.256"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("[foo.com]"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("filesystem:http://a.com/t/bar"),
+ metrics::OmniboxInputType::URL },
+ { ASCIIToUTF16("filesystem:http://a.com/"),
+ metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("filesystem:file://"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("filesystem:http"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("filesystem:"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("chrome-search://"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("chrome-devtools:"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("about://f;"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16("://w"), metrics::OmniboxInputType::QUERY },
+ { ASCIIToUTF16(":w"), metrics::OmniboxInputType::QUERY },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) {
@@ -143,17 +151,18 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) {
const AutocompleteInput::Type type;
const std::string spec; // Unused if not a URL.
} input_cases[] = {
- { ASCIIToUTF16("401k"), AutocompleteInput::URL,
+ { ASCIIToUTF16("401k"), metrics::OmniboxInputType::URL,
std::string("http://www.401k.com/") },
- { ASCIIToUTF16("999999999999999"), AutocompleteInput::URL,
+ { ASCIIToUTF16("999999999999999"), metrics::OmniboxInputType::URL,
std::string("http://www.999999999999999.com/") },
- { ASCIIToUTF16("x@y"), AutocompleteInput::URL,
+ { ASCIIToUTF16("x@y"), metrics::OmniboxInputType::URL,
std::string("http://x@www.y.com/") },
- { ASCIIToUTF16("y/z z"), AutocompleteInput::URL,
+ { ASCIIToUTF16("y/z z"), metrics::OmniboxInputType::URL,
std::string("http://www.y.com/z%20z") },
- { ASCIIToUTF16("abc.com"), AutocompleteInput::URL,
+ { ASCIIToUTF16("abc.com"), metrics::OmniboxInputType::URL,
std::string("http://abc.com/") },
- { ASCIIToUTF16("foo bar"), AutocompleteInput::QUERY, std::string() },
+ { ASCIIToUTF16("foo bar"), metrics::OmniboxInputType::QUERY,
+ std::string() },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) {
@@ -163,7 +172,7 @@ TEST(AutocompleteInputTest, InputTypeWithDesiredTLD) {
AutocompleteInput::INVALID_SPEC, true, false, true,
true);
EXPECT_EQ(input_cases[i].type, input.type());
- if (input_cases[i].type == AutocompleteInput::URL)
+ if (input_cases[i].type == metrics::OmniboxInputType::URL)
EXPECT_EQ(input_cases[i].spec, input.canonicalized_url().spec());
}
}
diff --git a/chrome/browser/autocomplete/autocomplete_provider.cc b/chrome/browser/autocomplete/autocomplete_provider.cc
index 72c99e8..4368834 100644
--- a/chrome/browser/autocomplete/autocomplete_provider.cc
+++ b/chrome/browser/autocomplete/autocomplete_provider.cc
@@ -154,7 +154,7 @@ AutocompleteProvider::FixupReturn AutocompleteProvider::FixupUserInput(
// 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
// "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()) {
std::string original_hostname =
base::UTF16ToUTF8(input_text.substr(input.parts().host.begin,
diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc
index a65ca2b..67da012 100644
--- a/chrome/browser/autocomplete/autocomplete_result.cc
+++ b/chrome/browser/autocomplete/autocomplete_result.cc
@@ -16,6 +16,7 @@
#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_input_type.pb.h"
namespace {
@@ -254,9 +255,10 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input,
// We shouldn't get query matches for URL inputs, or non-query matches
// for query inputs.
if (AutocompleteMatch::IsSearchType(default_match_->type)) {
- DCHECK_NE(AutocompleteInput::URL, input.type()) << debug_info;
+ DCHECK_NE(metrics::OmniboxInputType::URL, input.type()) << debug_info;
} 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 {
GURL AutocompleteResult::ComputeAlternateNavUrl(
const AutocompleteInput& input,
const AutocompleteMatch& match) {
- return ((input.type() == AutocompleteInput::UNKNOWN) &&
+ return ((input.type() == metrics::OmniboxInputType::UNKNOWN) &&
(AutocompleteMatch::IsSearchType(match.type)) &&
(match.transition != content::PAGE_TRANSITION_KEYWORD) &&
(input.canonicalized_url() != match.destination_url)) ?
diff --git a/chrome/browser/autocomplete/base_search_provider.cc b/chrome/browser/autocomplete/base_search_provider.cc
index 3d47eda..3de7d41 100644
--- a/chrome/browser/autocomplete/base_search_provider.cc
+++ b/chrome/browser/autocomplete/base_search_provider.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/common/url_constants.h"
#include "net/base/escape.h"
@@ -337,7 +338,7 @@ int BaseSearchProvider::SuggestResult::CalculateRelevance(
bool keyword_provider_requested) const {
if (!from_keyword_provider_ && keyword_provider_requested)
return 100;
- return ((input.type() == AutocompleteInput::URL) ? 300 : 600);
+ return ((input.type() == metrics::OmniboxInputType::URL) ? 300 : 600);
}
// BaseSearchProvider::NavigationResult ----------------------------------------
@@ -518,7 +519,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
// 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
// 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("?"));
if (suggestion.from_keyword_provider())
match.fill_into_edit.append(match.keyword + base::char16(' '));
@@ -853,7 +854,8 @@ bool BaseSearchProvider::ParseSuggestResults(const base::Value& root_val,
std::string type;
int relevance = GetDefaultResultRelevance();
// 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(
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
const base::string16& trimmed_input =
diff --git a/chrome/browser/autocomplete/bookmark_provider.cc b/chrome/browser/autocomplete/bookmark_provider.cc
index 2b18d29..c099218 100644
--- a/chrome/browser/autocomplete/bookmark_provider.cc
+++ b/chrome/browser/autocomplete/bookmark_provider.cc
@@ -19,6 +19,7 @@
#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_match.h"
#include "components/bookmarks/browser/bookmark_model.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "net/base/net_util.h"
typedef std::vector<BookmarkMatch> BookmarkMatches;
@@ -45,7 +46,7 @@ void BookmarkProvider::Start(const AutocompleteInput& input,
matches_.clear();
if (input.text().empty() ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return;
DoAutocomplete(input);
diff --git a/chrome/browser/autocomplete/builtin_provider.cc b/chrome/browser/autocomplete/builtin_provider.cc
index 615211b..e9e08cf 100644
--- a/chrome/browser/autocomplete/builtin_provider.cc
+++ b/chrome/browser/autocomplete/builtin_provider.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/history_provider.h"
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/url_constants.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
namespace {
@@ -64,9 +65,9 @@ BuiltinProvider::BuiltinProvider(AutocompleteProviderListener* listener,
void BuiltinProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY) ||
- (input.type() == AutocompleteInput::QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY) ||
+ (input.type() == metrics::OmniboxInputType::QUERY))
return;
const size_t kAboutSchemeLength = strlen(content::kAboutScheme);
diff --git a/chrome/browser/autocomplete/extension_app_provider.cc b/chrome/browser/autocomplete/extension_app_provider.cc
index 8eea0af..479c15a 100644
--- a/chrome/browser/autocomplete/extension_app_provider.cc
+++ b/chrome/browser/autocomplete/extension_app_provider.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.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 "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
@@ -106,8 +107,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return;
if (input.text().empty())
@@ -133,8 +134,8 @@ void ExtensionAppProvider::Start(const AutocompleteInput& input,
std::search(url.begin(), url.end(),
input.text().begin(), input.text().end(),
base::CaseInsensitiveCompare<base::char16>());
- matches_url = url_iter != url.end() &&
- input.type() != AutocompleteInput::FORCED_QUERY;
+ matches_url = (url_iter != url.end()) &&
+ (input.type() != metrics::OmniboxInputType::FORCED_QUERY);
url_match_index = matches_url ?
static_cast<size_t>(url_iter - url.begin()) : base::string16::npos;
}
@@ -191,10 +192,11 @@ void ExtensionAppProvider::Observe(int type,
RefreshAppList();
}
-int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type,
- int input_length,
- int target_length,
- const GURL& url) {
+int ExtensionAppProvider::CalculateRelevance(
+ metrics::OmniboxInputType::Type type,
+ int input_length,
+ int target_length,
+ const GURL& url) {
// If you update the algorithm here, please remember to update the tables in
// autocomplete.h also.
const int kMaxRelevance = 1425;
diff --git a/chrome/browser/autocomplete/extension_app_provider.h b/chrome/browser/autocomplete/extension_app_provider.h
index 5dbcc26..b14f532 100644
--- a/chrome/browser/autocomplete/extension_app_provider.h
+++ b/chrome/browser/autocomplete/extension_app_provider.h
@@ -13,6 +13,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_input_type.pb.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/window_open_disposition.h"
@@ -71,7 +72,7 @@ class ExtensionAppProvider : public AutocompleteProvider,
void RefreshAppList();
// Calculate the relevance of the match.
- int CalculateRelevance(AutocompleteInput::Type type,
+ int CalculateRelevance(metrics::OmniboxInputType::Type type,
int input_length,
int target_length,
const GURL& url);
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc
index 2af03ac..1391ca4 100644
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ b/chrome/browser/autocomplete/history_quick_provider.cc
@@ -36,6 +36,7 @@
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.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_types.h"
#include "net/base/escape.h"
@@ -65,8 +66,8 @@ void HistoryQuickProvider::Start(const AutocompleteInput& input,
return;
// Don't bother with INVALID and FORCED_QUERY.
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return;
autocomplete_input_ = input;
@@ -121,7 +122,7 @@ void HistoryQuickProvider::DoAutocomplete() {
// provider won't promote the URL-what-you-typed match to first
// for these inputs.
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().password.is_nonempty() ||
autocomplete_input_.parts().path.is_nonempty());
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 1ca36b8..2872f6a 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -34,6 +34,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.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/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
@@ -336,7 +337,7 @@ HistoryURLProvider::VisitClassifier::VisitClassifier(
// and because the history backend strips auth creds, we'll get a bogus exact
// match below if the user has visited "site".
if (!url.is_valid() ||
- ((input.type() == AutocompleteInput::UNKNOWN) &&
+ ((input.type() == metrics::OmniboxInputType::UNKNOWN) &&
input.parts().username.is_nonempty() &&
!input.parts().password.is_nonempty() &&
!input.parts().path.is_nonempty()))
@@ -410,8 +411,8 @@ void HistoryURLProvider::Start(const AutocompleteInput& input,
matches_.clear();
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return;
// 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,
const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text());
// 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.
- if (input.type() != AutocompleteInput::QUERY) {
+ if (input.type() != metrics::OmniboxInputType::QUERY) {
AutocompleteMatch what_you_typed(SuggestExactInput(
input.text(), input.canonicalized_url(), trim_http));
what_you_typed.relevance = CalculateRelevance(WHAT_YOU_TYPED, 0);
@@ -596,8 +597,8 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
// 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.
bool have_what_you_typed_match =
- (params->input.type() != AutocompleteInput::QUERY) &&
- ((params->input.type() != AutocompleteInput::UNKNOWN) ||
+ (params->input.type() != metrics::OmniboxInputType::QUERY) &&
+ ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) ||
(classifier.type() == VisitClassifier::UNVISITED_INTRANET) ||
!params->trim_http ||
(AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0));
@@ -827,9 +828,9 @@ bool HistoryURLProvider::FixupExactSuggestion(
// between the input "c" and the input "c#", both of which will have empty
// reference fragments.)
if ((type == UNVISITED_INTRANET) &&
- (input.type() != AutocompleteInput::URL) && url.username().empty() &&
- url.password().empty() && url.port().empty() && (url.path() == "/") &&
- url.query().empty() &&
+ (input.type() != metrics::OmniboxInputType::URL) &&
+ url.username().empty() && url.password().empty() && url.port().empty() &&
+ (url.path() == "/") && url.query().empty() &&
(parsed.CountCharactersBefore(url::Parsed::REF, true) !=
parsed.CountCharactersBefore(url::Parsed::REF, false))) {
return false;
@@ -858,7 +859,7 @@ bool HistoryURLProvider::CanFindIntranetURL(
// third condition, but because FixupUserInput() can run and modify the
// input's text and parts between Parse() and here, it seems better to be
// paranoid and check.
- if ((input.type() != AutocompleteInput::UNKNOWN) ||
+ if ((input.type() != metrics::OmniboxInputType::UNKNOWN) ||
!LowerCaseEqualsASCII(input.scheme(), url::kHttpScheme) ||
!input.parts().host.is_nonempty())
return false;
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index 45caf46..15cfe54 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -670,14 +670,14 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithRefs) {
int relevance;
AutocompleteInput::Type type;
} test_cases[] = {
- { "gooey", 1410, AutocompleteInput::UNKNOWN },
- { "gooey/", 1410, AutocompleteInput::URL },
- { "gooey#", 1200, AutocompleteInput::UNKNOWN },
- { "gooey/#", 1200, AutocompleteInput::URL },
- { "gooey#foo", 1200, AutocompleteInput::UNKNOWN },
- { "gooey/#foo", 1200, AutocompleteInput::URL },
- { "gooey# foo", 1200, AutocompleteInput::UNKNOWN },
- { "gooey/# foo", 1200, AutocompleteInput::URL },
+ { "gooey", 1410, metrics::OmniboxInputType::UNKNOWN },
+ { "gooey/", 1410, metrics::OmniboxInputType::URL },
+ { "gooey#", 1200, metrics::OmniboxInputType::UNKNOWN },
+ { "gooey/#", 1200, metrics::OmniboxInputType::URL },
+ { "gooey#foo", 1200, metrics::OmniboxInputType::UNKNOWN },
+ { "gooey/#foo", 1200, metrics::OmniboxInputType::URL },
+ { "gooey# foo", 1200, metrics::OmniboxInputType::UNKNOWN },
+ { "gooey/# foo", 1200, metrics::OmniboxInputType::URL },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
SCOPED_TRACE(test_cases[i].input);
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index 5740e90..44e9354 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -18,6 +18,7 @@
#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_factory.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/extension_system.h"
@@ -340,8 +341,8 @@ KeywordProvider::~KeywordProvider() {}
bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
base::string16* keyword,
base::string16* remaining_input) {
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return false;
*keyword = TemplateURLService::CleanUserInputKeyword(
@@ -350,7 +351,7 @@ bool KeywordProvider::ExtractKeywordFromInput(const AutocompleteInput& input,
}
// static
-int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type,
+int KeywordProvider::CalculateRelevance(metrics::OmniboxInputType::Type type,
bool complete,
bool supports_replacement,
bool prefer_keyword,
@@ -365,10 +366,11 @@ int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type,
// make such a change, however, you should update this comment to
// describe it, so it's clear why the functions diverge.
if (!complete)
- return (type == AutocompleteInput::URL) ? 700 : 450;
+ return (type == metrics::OmniboxInputType::URL) ? 700 : 450;
if (!supports_replacement || (allow_exact_keyword_match && prefer_keyword))
return 1500;
- return (allow_exact_keyword_match && (type == AutocompleteInput::QUERY)) ?
+ return (allow_exact_keyword_match &&
+ (type == metrics::OmniboxInputType::QUERY)) ?
1450 : 1100;
}
diff --git a/chrome/browser/autocomplete/keyword_provider.h b/chrome/browser/autocomplete/keyword_provider.h
index d2a22d4..1857534 100644
--- a/chrome/browser/autocomplete/keyword_provider.h
+++ b/chrome/browser/autocomplete/keyword_provider.h
@@ -18,6 +18,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
class KeywordExtensionsDelegate;
class Profile;
@@ -114,7 +115,7 @@ class KeywordProvider : public AutocompleteProvider {
// matches" mode, and whether the keyword supports replacement.
// If |allow_exact_keyword_match| is false, the relevance for complete
// keywords that support replacements is degraded.
- static int CalculateRelevance(AutocompleteInput::Type type,
+ static int CalculateRelevance(metrics::OmniboxInputType::Type type,
bool complete,
bool support_replacement,
bool prefer_keyword,
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 22b8bb3..f0106f8 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -39,6 +39,7 @@
#include "chrome/browser/ui/search/instant_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "content/public/browser/user_metrics.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
@@ -176,7 +177,7 @@ int SearchProvider::CalculateRelevanceForKeywordVerbatim(
// describe it, so it's clear why the functions diverge.
if (prefer_keyword)
return 1500;
- return (type == AutocompleteInput::QUERY) ? 1450 : 1100;
+ return (type == metrics::OmniboxInputType::QUERY) ? 1450 : 1100;
}
void SearchProvider::Start(const AutocompleteInput& input,
@@ -191,7 +192,7 @@ void SearchProvider::Start(const AutocompleteInput& input,
field_trial_triggered_ = false;
// 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);
return;
}
@@ -549,7 +550,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
// 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.
- if (input_.type() == AutocompleteInput::FORCED_QUERY)
+ if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY)
return true;
// Next we check the scheme. If this is UNKNOWN/URL with a scheme that isn't
@@ -565,7 +566,7 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
if (!LowerCaseEqualsASCII(input_.scheme(), url::kHttpScheme) &&
!LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
!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
// private, and the Suggest server is unlikely to have any useful results
@@ -579,7 +580,8 @@ bool SearchProvider::IsQuerySuitableForSuggest() const {
const url::Parsed& parts = input_.parts();
if (parts.username.is_nonempty() || parts.port.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;
// Don't send anything for https except the hostname. Hostnames are OK
@@ -812,7 +814,7 @@ bool SearchProvider::HasKeywordDefaultMatchInKeywordMode() const {
bool SearchProvider::IsTopMatchSearchWithURLInput() const {
ACMatches::const_iterator first_match = FindTopMatch();
- return (input_.type() == AutocompleteInput::URL) &&
+ return (input_.type() == metrics::OmniboxInputType::URL) &&
(first_match != matches_.end()) &&
(first_match->relevance > CalculateRelevanceForVerbatim()) &&
(first_match->type != AutocompleteMatchType::NAVSUGGEST) &&
@@ -841,7 +843,7 @@ void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results,
base::TimeTicks start_time(base::TimeTicks::Now());
bool prevent_inline_autocomplete = input_.prevent_inline_autocomplete() ||
- (input_.type() == AutocompleteInput::URL);
+ (input_.type() == metrics::OmniboxInputType::URL);
const base::string16& input_text =
is_keyword ? keyword_input_.text() : input_.text();
bool input_multiple_words = HasMultipleWords(input_text);
@@ -987,12 +989,12 @@ int SearchProvider::CalculateRelevanceForVerbatim() const {
int SearchProvider::
CalculateRelevanceForVerbatimIgnoringKeywordModeState() const {
switch (input_.type()) {
- case AutocompleteInput::UNKNOWN:
- case AutocompleteInput::QUERY:
- case AutocompleteInput::FORCED_QUERY:
+ case metrics::OmniboxInputType::UNKNOWN:
+ case metrics::OmniboxInputType::QUERY:
+ case metrics::OmniboxInputType::FORCED_QUERY:
return kNonURLVerbatimRelevance;
- case AutocompleteInput::URL:
+ case metrics::OmniboxInputType::URL:
return 850;
default:
@@ -1059,7 +1061,7 @@ int SearchProvider::CalculateRelevanceForHistory(
// a different way.
int base_score;
if (is_primary_provider)
- base_score = (input_.type() == AutocompleteInput::URL) ? 750 : 1050;
+ base_score = (input_.type() == metrics::OmniboxInputType::URL) ? 750 : 1050;
else
base_score = 200;
return std::max(0, base_score - score_discount);
@@ -1099,7 +1101,7 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
&inline_autocomplete_offset));
// Preserve the forced query '?' prefix in |match.fill_into_edit|.
// 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("?"));
if (inline_autocomplete_offset != base::string16::npos)
++inline_autocomplete_offset;
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index e2be361..0c1188c 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -19,6 +19,7 @@
#include "chrome/browser/autocomplete/base_search_provider.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/search_engines/template_url.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
class Profile;
class SearchProviderTest;
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc
index b82cac9..a8868b5d 100644
--- a/chrome/browser/autocomplete/shortcuts_provider.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc
@@ -33,6 +33,7 @@
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "url/url_parse.h"
namespace {
@@ -70,8 +71,8 @@ void ShortcutsProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- if ((input.type() == AutocompleteInput::INVALID) ||
- (input.type() == AutocompleteInput::FORCED_QUERY))
+ if ((input.type() == metrics::OmniboxInputType::INVALID) ||
+ (input.type() == metrics::OmniboxInputType::FORCED_QUERY))
return;
if (input.text().empty())
diff --git a/chrome/browser/autocomplete/zero_suggest_provider.cc b/chrome/browser/autocomplete/zero_suggest_provider.cc
index 723622b..ad3bef6 100644
--- a/chrome/browser/autocomplete/zero_suggest_provider.cc
+++ b/chrome/browser/autocomplete/zero_suggest_provider.cc
@@ -32,6 +32,7 @@
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.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 "content/public/browser/user_metrics.h"
#include "net/base/escape.h"
@@ -93,7 +94,7 @@ void ZeroSuggestProvider::RegisterProfilePrefs(
void ZeroSuggestProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- if (input.type() == AutocompleteInput::INVALID)
+ if (input.type() == metrics::OmniboxInputType::INVALID)
return;
Stop(true);
diff --git a/chrome/browser/metrics/omnibox_metrics_provider.cc b/chrome/browser/metrics/omnibox_metrics_provider.cc
index 430cfa1..94847f9 100644
--- a/chrome/browser/metrics/omnibox_metrics_provider.cc
+++ b/chrome/browser/metrics/omnibox_metrics_provider.cc
@@ -17,30 +17,14 @@
#include "chrome/browser/omnibox/omnibox_log.h"
#include "chrome/browser/ui/browser_otr_state.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"
using metrics::OmniboxEventProto;
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(
AutocompleteMatch::Type type) {
switch (type) {
@@ -182,7 +166,7 @@ void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) {
}
omnibox_event->set_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
// (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
diff --git a/chrome/browser/omnibox/omnibox_log.cc b/chrome/browser/omnibox/omnibox_log.cc
index 48f6241..ef0a08d 100644
--- a/chrome/browser/omnibox/omnibox_log.cc
+++ b/chrome/browser/omnibox/omnibox_log.cc
@@ -7,7 +7,7 @@
OmniboxLog::OmniboxLog(
const base::string16& text,
bool just_deleted_text,
- AutocompleteInput::Type input_type,
+ metrics::OmniboxInputType::Type input_type,
bool is_popup_open,
size_t selected_index,
bool is_paste_and_go,
diff --git a/chrome/browser/omnibox/omnibox_log.h b/chrome/browser/omnibox/omnibox_log.h
index f66883c..3c641ce 100644
--- a/chrome/browser/omnibox/omnibox_log.h
+++ b/chrome/browser/omnibox/omnibox_log.h
@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/sessions/session_id.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
class AutocompleteResult;
@@ -21,7 +22,7 @@ struct OmniboxLog {
OmniboxLog(
const base::string16& text,
bool just_deleted_text,
- AutocompleteInput::Type input_type,
+ metrics::OmniboxInputType::Type input_type,
bool is_popup_open,
size_t selected_index,
bool is_paste_and_go,
@@ -41,7 +42,7 @@ struct OmniboxLog {
bool just_deleted_text;
// The detected type of the user's input.
- AutocompleteInput::Type input_type;
+ metrics::OmniboxInputType::Type input_type;
// True if the popup is open.
bool is_popup_open;
diff --git a/chrome/browser/ui/app_list/search/omnibox_provider.cc b/chrome/browser/ui/app_list/search/omnibox_provider.cc
index de71f00..33aa87e 100644
--- a/chrome/browser/ui/app_list/search/omnibox_provider.cc
+++ b/chrome/browser/ui/app_list/search/omnibox_provider.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h"
#include "chrome/browser/ui/browser_navigator.h"
-#include "components/metrics/proto/omnibox_event.pb.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
diff --git a/components/metrics.gypi b/components/metrics.gypi
index b9d4420..0a48dac 100644
--- a/components/metrics.gypi
+++ b/components/metrics.gypi
@@ -83,6 +83,7 @@
'metrics/proto/chrome_user_metrics_extension.proto',
'metrics/proto/histogram_event.proto',
'metrics/proto/omnibox_event.proto',
+ 'metrics/proto/omnibox_input_type.proto',
'metrics/proto/perf_data.proto',
'metrics/proto/profiler_event.proto',
'metrics/proto/sampled_profile.proto',
diff --git a/components/metrics/proto/omnibox_event.proto b/components/metrics/proto/omnibox_event.proto
index 3307954..afef1a0 100644
--- a/components/metrics/proto/omnibox_event.proto
+++ b/components/metrics/proto/omnibox_event.proto
@@ -10,6 +10,8 @@ option optimize_for = LITE_RUNTIME;
package metrics;
+import "omnibox_input_type.proto";
+
// Next tag: 17
message OmniboxEventProto {
// The timestamp for the event, in seconds since the epoch.
@@ -130,18 +132,7 @@ message OmniboxEventProto {
}
optional PageClassification current_page_classification = 10;
- // What kind of input the user provided.
- 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;
+ optional OmniboxInputType.Type input_type = 8;
// An enum used in multiple places below.
enum ProviderType {
diff --git a/components/metrics/proto/omnibox_input_type.proto b/components/metrics/proto/omnibox_input_type.proto
new file mode 100644
index 0000000..6a9b08e
--- /dev/null
+++ b/components/metrics/proto/omnibox_input_type.proto
@@ -0,0 +1,37 @@
+// 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;
+}