diff options
3 files changed, 29 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 8309378..d89c5a1 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -28,6 +28,7 @@ #include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url.h" +#include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/browser_list.h" @@ -530,12 +531,30 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match, if (template_url) { UserMetrics::RecordAction(UserMetricsAction("AcceptedKeyword")); template_url_service->IncrementUsageCount(template_url); + + if (match.transition == PageTransition::KEYWORD || + match.transition == PageTransition::KEYWORD_GENERATED) { + // NOTE: Non-prepopulated engines will all have ID 0, which is fine as + // the prepopulate IDs start at 1. Distribution-specific engines will + // all have IDs above the maximum, and will be automatically lumped + // together in an "overflow" bucket in the histogram. + UMA_HISTOGRAM_ENUMERATION( + "Omnibox.SearchEngine", template_url->prepopulate_id(), + TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); + } } // NOTE: We purposefully don't increment the usage count of the default // search engine, if applicable; see comments in template_url.h. } + if (match.transition == PageTransition::GENERATED && match.template_url) { + // See comment above. + UMA_HISTOGRAM_ENUMERATION( + "Omnibox.SearchEngine", match.template_url->prepopulate_id(), + TemplateURLPrepopulateData::kMaxPrepopulatedEngineID); + } + if (disposition != NEW_BACKGROUND_TAB) { in_revert_ = true; view_->RevertAll(); // Revert the box to its unedited state diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc index 56cb77a..66ec20b 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data.cc +++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc @@ -78,7 +78,10 @@ struct PrepopulatedEngine { // // IDs > 1000 are reserved for distribution custom engines. // - // NOTE: CHANGE THE ABOVE NUMBERS IF YOU ADD A NEW ENGINE; ID conflicts = bad! + // NOTES: + // CHANGE THE ABOVE NUMBERS IF YOU ADD A NEW ENGINE; ID conflicts = bad! + // CHANGE kMaxPrepopulatedEngineID below if you add new engine outside + // of the current range or it will not be counted in stats. const int id; }; @@ -3344,6 +3347,10 @@ void GetPrepopulationSetFromCountryID(PrefService* prefs, namespace TemplateURLPrepopulateData { +// The following id is for UMA stats only. Please update +// kMaxPrepopulatedEngineID if it changes upwards. +const int kMaxPrepopulatedEngineID = 101; + void RegisterUserPrefs(PrefService* prefs) { prefs->RegisterIntegerPref(prefs::kCountryIDAtInstall, kCountryIDUnknown, diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.h b/chrome/browser/search_engines/template_url_prepopulate_data.h index 5591fc9..1898fde 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data.h +++ b/chrome/browser/search_engines/template_url_prepopulate_data.h @@ -15,6 +15,8 @@ class TemplateURL; namespace TemplateURLPrepopulateData { +extern const int kMaxPrepopulatedEngineID; + void RegisterUserPrefs(PrefService* prefs); // Returns the current version of the prepopulate data, so callers can know when |