diff options
author | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-28 18:35:52 +0000 |
---|---|---|
committer | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-28 18:35:52 +0000 |
commit | 3c919d6ac5b262904d6598fc2418d7c0358aad57 (patch) | |
tree | 507280c32758d0d0a442c7ed2e30d3eaa37dc3c5 | |
parent | f7efe5e16454fffac843b8008799e0927db511c4 (diff) | |
download | chromium_src-3c919d6ac5b262904d6598fc2418d7c0358aad57.zip chromium_src-3c919d6ac5b262904d6598fc2418d7c0358aad57.tar.gz chromium_src-3c919d6ac5b262904d6598fc2418d7c0358aad57.tar.bz2 |
Make a copy of PageClassification enum outside the metrics code
This will reduce in the future the number of metrics protocol buffers
that we need to #include in various omnibox code files. It also
introduces better boundaries between disparate sections of the codebase.
NOTRY=true
BUG=
Review URL: https://chromiumcodereview.appspot.com/20747002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214132 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_input.h | 21 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 24 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_log.cc | 2 | ||||
-rw-r--r-- | chrome/browser/omnibox/omnibox_log.h | 6 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_edit_model.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_edit_model.h | 3 |
6 files changed, 57 insertions, 19 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h index d70a3af..9f97884 100644 --- a/chrome/browser/autocomplete/autocomplete_input.h +++ b/chrome/browser/autocomplete/autocomplete_input.h @@ -44,6 +44,27 @@ class AutocompleteInput { ALL_MATCHES, }; + // The type of page currently displayed. + // Note: when adding an element to this enum, please add it at the end + // and update omnibox_event.proto::PageClassification and + // omnibox_edit_model.cc::ClassifyPage() too. + 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 not included somewhere else on this list + INSTANT_NEW_TAB_PAGE = 5, // new tab page rendered by Instant + // The user is on a search result page that's doing search term + // replacement, meaning the search terms should've appeared in the omnibox + // before the user started editing it, not the URL of the page. + SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT = 6 + }; + AutocompleteInput(); // |text| and |cursor_position| represent the input query and location of // the cursor with the query respectively. |cursor_position| may be set to diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index af2613f..db64070 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -141,6 +141,28 @@ OmniboxEventProto::Suggestion::ResultType AsOmniboxEventResultType( } } +OmniboxEventProto::PageClassification AsOmniboxEventPageClassification( + AutocompleteInput::PageClassification page_classification) { + switch (page_classification) { + case AutocompleteInput::INVALID_SPEC: + return OmniboxEventProto::INVALID_SPEC; + case AutocompleteInput::NEW_TAB_PAGE: + return OmniboxEventProto::NEW_TAB_PAGE; + case AutocompleteInput::BLANK: + return OmniboxEventProto::BLANK; + case AutocompleteInput::HOMEPAGE: + return OmniboxEventProto::HOMEPAGE; + case AutocompleteInput::OTHER: + return OmniboxEventProto::OTHER; + case AutocompleteInput::INSTANT_NEW_TAB_PAGE: + return OmniboxEventProto::INSTANT_NEW_TAB_PAGE; + case AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT: + return OmniboxEventProto:: + SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; + } + return OmniboxEventProto::INVALID_SPEC; +} + ProfilerEventProto::TrackedObject::ProcessType AsProtobufProcessType( int process_type) { switch (process_type) { @@ -829,7 +851,7 @@ void MetricsLog::RecordOmniboxOpenedURL(const OmniboxLog& log) { omnibox_event->set_duration_since_last_default_match_update_ms( log.elapsed_time_since_last_change_to_default_match.InMilliseconds()); omnibox_event->set_current_page_classification( - log.current_page_classification); + AsOmniboxEventPageClassification(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) { diff --git a/chrome/browser/omnibox/omnibox_log.cc b/chrome/browser/omnibox/omnibox_log.cc index 9a80882..8da61d9 100644 --- a/chrome/browser/omnibox/omnibox_log.cc +++ b/chrome/browser/omnibox/omnibox_log.cc @@ -10,7 +10,7 @@ OmniboxLog::OmniboxLog( AutocompleteInput::Type input_type, size_t selected_index, SessionID::id_type tab_id, - metrics::OmniboxEventProto::PageClassification current_page_classification, + AutocompleteInput::PageClassification current_page_classification, base::TimeDelta elapsed_time_since_user_first_modified_omnibox, size_t completed_length, base::TimeDelta elapsed_time_since_last_change_to_default_match, diff --git a/chrome/browser/omnibox/omnibox_log.h b/chrome/browser/omnibox/omnibox_log.h index a31c9c7..2b3d5aa 100644 --- a/chrome/browser/omnibox/omnibox_log.h +++ b/chrome/browser/omnibox/omnibox_log.h @@ -12,7 +12,6 @@ #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/autocomplete/autocomplete_provider.h" #include "chrome/browser/sessions/session_id.h" -#include "chrome/common/metrics/proto/omnibox_event.pb.h" class AutocompleteResult; @@ -25,8 +24,7 @@ struct OmniboxLog { AutocompleteInput::Type input_type, size_t selected_index, SessionID::id_type tab_id, - metrics::OmniboxEventProto::PageClassification - current_page_classification, + AutocompleteInput::PageClassification current_page_classification, base::TimeDelta elapsed_time_since_user_first_modified_omnibox, size_t completed_length, base::TimeDelta elapsed_time_since_last_change_to_default_match, @@ -52,7 +50,7 @@ struct OmniboxLog { // 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; + AutocompleteInput::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 diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 4d8f585..42f1051 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -1254,27 +1254,25 @@ bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { } } -metrics::OmniboxEventProto::PageClassification - OmniboxEditModel::ClassifyPage() const { +AutocompleteInput::PageClassification OmniboxEditModel::ClassifyPage() const { if (!delegate_->CurrentPageExists()) - return metrics::OmniboxEventProto::OTHER; + return AutocompleteInput::OTHER; if (delegate_->IsInstantNTP()) - return metrics::OmniboxEventProto::INSTANT_NEW_TAB_PAGE; + return AutocompleteInput::INSTANT_NEW_TAB_PAGE; const GURL& gurl = delegate_->GetURL(); if (!gurl.is_valid()) - return metrics::OmniboxEventProto::INVALID_SPEC; + return AutocompleteInput::INVALID_SPEC; const std::string& url = gurl.spec(); if (url == chrome::kChromeUINewTabURL) - return metrics::OmniboxEventProto::NEW_TAB_PAGE; + return AutocompleteInput::NEW_TAB_PAGE; if (url == content::kAboutBlankURL) - return metrics::OmniboxEventProto::BLANK; + return AutocompleteInput::BLANK; if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) - return metrics::OmniboxEventProto::HOMEPAGE; + return AutocompleteInput::HOMEPAGE; if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms(true)) { - return metrics:: - OmniboxEventProto::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; + return AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; } - return metrics::OmniboxEventProto::OTHER; + return AutocompleteInput::OTHER; } void OmniboxEditModel::ClassifyStringForPasteAndGo( diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.h b/chrome/browser/ui/omnibox/omnibox_edit_model.h index 4087b4d..d349892 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.h +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.h @@ -13,7 +13,6 @@ #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/ui/omnibox/omnibox_controller.h" -#include "chrome/common/metrics/proto/omnibox_event.pb.h" #include "chrome/common/omnibox_focus_state.h" #include "content/public/common/page_transition_types.h" #include "ui/base/window_open_disposition.h" @@ -387,7 +386,7 @@ class OmniboxEditModel { // 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; + AutocompleteInput::PageClassification ClassifyPage() const; // Sets |match| and |alternate_nav_url| based on classifying |text|. // |alternate_nav_url| may be NULL. |