Commit ee902534 authored by mpearson@chromium.org's avatar mpearson@chromium.org

Omnibox: Add logging of what type of page was displayed when it's used

For UMA opted-in users, this adds a new field to the omnibox event record that's uploaded when the user uses the omnibox.  In particular, it records a simple enum of what type of page the user was looking at, such as a generic web page or the new tab page.

This change only adds the field to the protocol buffer upload format, not the XML format.  If I decide later I want to add it to the XML format, I'll do it in another changelist.

BUG=
TEST=using VLOG(1) of what would be uploaded


Review URL: http://codereview.chromium.org/10273019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134824 0039d316-1c4b-4281-b951-d872f2087c98
parent 796f1cf6
......@@ -1133,6 +1133,7 @@ AutocompleteLog::AutocompleteLog(
AutocompleteInput::Type input_type,
size_t selected_index,
SessionID::id_type tab_id,
metrics::OmniboxEventProto::PageClassification current_page_classification,
base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
size_t inline_autocompleted_length,
const AutocompleteResult& result)
......@@ -1140,6 +1141,7 @@ AutocompleteLog::AutocompleteLog(
input_type(input_type),
selected_index(selected_index),
tab_id(tab_id),
current_page_classification(current_page_classification),
elapsed_time_since_user_first_modified_omnibox(
elapsed_time_since_user_first_modified_omnibox),
inline_autocompleted_length(inline_autocompleted_length),
......
......@@ -17,6 +17,7 @@
#include "base/time.h"
#include "base/timer.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/common/metrics/proto/omnibox_event.pb.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_parse.h"
......@@ -776,6 +777,8 @@ struct AutocompleteLog {
AutocompleteInput::Type input_type,
size_t selected_index,
SessionID::id_type tab_id,
metrics::OmniboxEventProto::PageClassification
current_page_classification,
base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
size_t inline_autocompleted_length,
const AutocompleteResult& result);
......@@ -788,6 +791,9 @@ struct AutocompleteLog {
// ID of the tab the selected autocomplete suggestion was opened in.
// Set to -1 if we haven't yet determined the destination tab.
SessionID::id_type tab_id;
// The type of page (e.g., new tab page, regular web page) that the
// user was viewing before going somewhere with the omnibox.
metrics::OmniboxEventProto::PageClassification current_page_classification;
// The amount of time since the user first began modifying the text
// in the omnibox. If at some point after modifying the text, the
// user reverts the modifications (thus seeing the current web
......
......@@ -27,6 +27,7 @@
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prerender/prerender_field_trial.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
......@@ -41,6 +42,8 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/metrics/proto/omnibox_event.pb.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
......@@ -518,6 +521,8 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match,
autocomplete_controller_->input().type(),
popup_->selected_line(),
-1, // don't yet know tab ID; set later if appropriate
ClassifyPage(controller_->GetTabContentsWrapper()->
web_contents()->GetURL()),
base::TimeTicks::Now() - time_user_first_modified_omnibox_,
0, // inline autocomplete length; possibly set later
result());
......@@ -1138,3 +1143,17 @@ bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
return false;
}
}
metrics::OmniboxEventProto::PageClassification
AutocompleteEditModel::ClassifyPage(const GURL& gurl) const {
if (!gurl.is_valid())
return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC;
const std::string& url = gurl.spec();
if (url == chrome::kChromeUINewTabURL)
return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE;
if (url == chrome::kAboutBlankURL)
return metrics::OmniboxEventProto_PageClassification_BLANK;
if (url == profile()->GetPrefs()->GetString(prefs::kHomePage))
return metrics::OmniboxEventProto_PageClassification_HOMEPAGE;
return metrics::OmniboxEventProto_PageClassification_OTHER;
}
......@@ -12,6 +12,7 @@
#include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/common/instant_types.h"
#include "chrome/common/metrics/proto/omnibox_event.pb.h"
#include "content/public/common/page_transition_types.h"
#include "googleurl/src/gurl.h"
#include "ui/gfx/native_widget_types.h"
......@@ -444,6 +445,13 @@ class AutocompleteEditModel : public AutocompleteControllerDelegate {
// keyword.
static bool IsSpaceCharForAcceptingKeyword(wchar_t c);
// Classify the current page being viewed as, for example, the new tab
// page or a normal web page. Used for logging omnibox events for
// UMA opted-in users. Examines the user's profile to determine if the
// current page is the user's home page.
metrics::OmniboxEventProto::PageClassification ClassifyPage(
const GURL& gurl) const;
scoped_ptr<AutocompleteController> autocomplete_controller_;
OmniboxView* view_;
......
......@@ -938,6 +938,8 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
omnibox_event->set_typing_duration_ms(
log.elapsed_time_since_user_first_modified_omnibox.InMilliseconds());
}
omnibox_event->set_current_page_classification(
log.current_page_classification);
omnibox_event->set_input_type(AsOmniboxEventInputType(log.input_type));
for (AutocompleteResult::const_iterator i(log.result.begin());
i != log.result.end(); ++i) {
......
......@@ -10,7 +10,7 @@ option optimize_for = LITE_RUNTIME;
package metrics;
// Next tag: 10
// Next tag: 11
message OmniboxEventProto {
// The timestamp for the event, in seconds since the epoch.
optional int64 time = 1;
......@@ -43,6 +43,20 @@ message OmniboxEventProto {
// from the time of the second series of modification.
optional int64 typing_duration_ms = 7;
// The type of page currently displayed when the user used the omnibox.
enum PageClassification {
INVALID_SPEC = 0; // invalid URI; shouldn't happen
NEW_TAB_PAGE = 1; // chrome://newtab/
// Note that chrome://newtab/ doesn't have to be the built-in
// version; it could be replaced by an extension.
BLANK = 2; // about:blank
HOMEPAGE = 3; // user switched settings to "open this page" mode.
// Note that if the homepage is set to the new tab page or about blank,
// then we'll classify the web page into those categories, not HOMEPAGE.
OTHER = 4; // everything else
}
optional PageClassification current_page_classification = 10;
// What kind of input the user provided.
enum InputType {
INVALID = 0; // Empty input (should not reach here)
......
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