Commit 685403bc authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Add Omnibox.SearchEngineType metric to Android omnibox searches

Bug: 953893
Change-Id: Ic30e369768a6c154209ef7fdd9b881374b3f8f30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572534
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652611}
parent 778f6f32
......@@ -265,6 +265,9 @@ void AutocompleteControllerAndroid::OnSuggestionSelected(
ClipboardRecentContent::GetInstance()->GetClipboardContentAge());
}
AutocompleteMatch::LogSearchEngineUsed(
match, TemplateURLServiceFactory::GetForProfile(profile_));
OmniboxLog log(
// For zero suggest, record an empty input string instead of the
// current URL.
......
......@@ -9,6 +9,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
......@@ -25,6 +26,7 @@
#include "components/omnibox/browser/suggestion_answer.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "ui/gfx/vector_icon_types.h"
......@@ -627,6 +629,23 @@ url_formatter::FormatUrlTypes AutocompleteMatch::GetFormatTypes(
return format_types;
}
// static
void AutocompleteMatch::LogSearchEngineUsed(
const AutocompleteMatch& match,
TemplateURLService* template_url_service) {
DCHECK(template_url_service);
TemplateURL* template_url = match.GetTemplateURL(template_url_service, false);
if (template_url) {
SearchEngineType search_engine_type =
match.destination_url.is_valid()
? TemplateURLPrepopulateData::GetEngineType(match.destination_url)
: SEARCH_ENGINE_OTHER;
UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngineType", search_engine_type,
SEARCH_ENGINE_MAX);
}
}
void AutocompleteMatch::ComputeStrippedDestinationURL(
const AutocompleteInput& input,
TemplateURLService* template_url_service) {
......
......@@ -273,6 +273,11 @@ struct AutocompleteMatch {
static url_formatter::FormatUrlTypes GetFormatTypes(bool preserve_scheme,
bool preserve_subdomain);
// Logs the search engine used to navigate to a search page or auto complete
// suggestion. For direct URL navigations, nothing is logged.
static void LogSearchEngineUsed(const AutocompleteMatch& match,
TemplateURLService* template_url_service);
// Computes the stripped destination URL (via GURLToStrippedGURL()) and
// stores the result in |stripped_destination_url|. |input| is used for the
// same purpose as in GURLToStrippedGURL().
......
......@@ -803,11 +803,7 @@ void OmniboxEditModel::OpenMatch(AutocompleteMatch match,
// in template_url.h.
}
SearchEngineType search_engine_type = match.destination_url.is_valid() ?
TemplateURLPrepopulateData::GetEngineType(match.destination_url) :
SEARCH_ENGINE_OTHER;
UMA_HISTOGRAM_ENUMERATION("Omnibox.SearchEngineType", search_engine_type,
SEARCH_ENGINE_MAX);
AutocompleteMatch::LogSearchEngineUsed(match, service);
} else {
// |match| is a URL navigation, not a search.
// For logging the below histogram, only record uses that depend on the
......
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