| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 5 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_input.h" | |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 13 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_result.h" | 14 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/omnibox/omnibox_log.h" | 16 #include "chrome/browser/omnibox/omnibox_log.h" |
| 18 #include "chrome/browser/ui/browser_otr_state.h" | 17 #include "chrome/browser/ui/browser_otr_state.h" |
| 19 #include "components/metrics/metrics_log.h" | 18 #include "components/metrics/metrics_log.h" |
| 20 #include "components/metrics/proto/omnibox_event.pb.h" | 19 #include "components/metrics/proto/omnibox_event.pb.h" |
| 21 #include "components/metrics/proto/omnibox_input_type.pb.h" | 20 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 22 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 case AutocompleteMatchType::NAVSUGGEST_PERSONALIZED: | 64 case AutocompleteMatchType::NAVSUGGEST_PERSONALIZED: |
| 66 return OmniboxEventProto::Suggestion::NAVSUGGEST_PERSONALIZED; | 65 return OmniboxEventProto::Suggestion::NAVSUGGEST_PERSONALIZED; |
| 67 case AutocompleteMatchType::CONTACT_DEPRECATED: | 66 case AutocompleteMatchType::CONTACT_DEPRECATED: |
| 68 case AutocompleteMatchType::NUM_TYPES: | 67 case AutocompleteMatchType::NUM_TYPES: |
| 69 break; | 68 break; |
| 70 } | 69 } |
| 71 NOTREACHED(); | 70 NOTREACHED(); |
| 72 return OmniboxEventProto::Suggestion::UNKNOWN_RESULT_TYPE; | 71 return OmniboxEventProto::Suggestion::UNKNOWN_RESULT_TYPE; |
| 73 } | 72 } |
| 74 | 73 |
| 75 OmniboxEventProto::PageClassification AsOmniboxEventPageClassification( | |
| 76 AutocompleteInput::PageClassification page_classification) { | |
| 77 switch (page_classification) { | |
| 78 case AutocompleteInput::INVALID_SPEC: | |
| 79 return OmniboxEventProto::INVALID_SPEC; | |
| 80 case AutocompleteInput::NTP: | |
| 81 return OmniboxEventProto::NTP; | |
| 82 case AutocompleteInput::BLANK: | |
| 83 return OmniboxEventProto::BLANK; | |
| 84 case AutocompleteInput::HOME_PAGE: | |
| 85 return OmniboxEventProto::HOME_PAGE; | |
| 86 case AutocompleteInput::OTHER: | |
| 87 return OmniboxEventProto::OTHER; | |
| 88 case AutocompleteInput::SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT: | |
| 89 return OmniboxEventProto:: | |
| 90 SEARCH_RESULT_PAGE_DOING_SEARCH_TERM_REPLACEMENT; | |
| 91 case AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS: | |
| 92 return OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS; | |
| 93 case AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS: | |
| 94 return OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS; | |
| 95 case AutocompleteInput::SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT: | |
| 96 return OmniboxEventProto:: | |
| 97 SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT; | |
| 98 } | |
| 99 NOTREACHED(); | |
| 100 return OmniboxEventProto::INVALID_SPEC; | |
| 101 } | |
| 102 | |
| 103 } // namespace | 74 } // namespace |
| 104 | 75 |
| 105 OmniboxMetricsProvider::OmniboxMetricsProvider() { | 76 OmniboxMetricsProvider::OmniboxMetricsProvider() { |
| 106 } | 77 } |
| 107 | 78 |
| 108 OmniboxMetricsProvider::~OmniboxMetricsProvider() { | 79 OmniboxMetricsProvider::~OmniboxMetricsProvider() { |
| 109 } | 80 } |
| 110 | 81 |
| 111 void OmniboxMetricsProvider::OnRecordingEnabled() { | 82 void OmniboxMetricsProvider::OnRecordingEnabled() { |
| 112 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 83 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Only upload the typing duration if it is set/valid. | 131 // Only upload the typing duration if it is set/valid. |
| 161 omnibox_event->set_typing_duration_ms( | 132 omnibox_event->set_typing_duration_ms( |
| 162 log.elapsed_time_since_user_first_modified_omnibox.InMilliseconds()); | 133 log.elapsed_time_since_user_first_modified_omnibox.InMilliseconds()); |
| 163 } | 134 } |
| 164 if (log.elapsed_time_since_last_change_to_default_match != | 135 if (log.elapsed_time_since_last_change_to_default_match != |
| 165 default_time_delta) { | 136 default_time_delta) { |
| 166 omnibox_event->set_duration_since_last_default_match_update_ms( | 137 omnibox_event->set_duration_since_last_default_match_update_ms( |
| 167 log.elapsed_time_since_last_change_to_default_match.InMilliseconds()); | 138 log.elapsed_time_since_last_change_to_default_match.InMilliseconds()); |
| 168 } | 139 } |
| 169 omnibox_event->set_current_page_classification( | 140 omnibox_event->set_current_page_classification( |
| 170 AsOmniboxEventPageClassification(log.current_page_classification)); | 141 log.current_page_classification); |
| 171 omnibox_event->set_input_type(log.input_type); | 142 omnibox_event->set_input_type(log.input_type); |
| 172 // We consider a paste-and-search/paste-and-go action to have a closed popup | 143 // We consider a paste-and-search/paste-and-go action to have a closed popup |
| 173 // (as explained in omnibox_event.proto) even if it was not, because such | 144 // (as explained in omnibox_event.proto) even if it was not, because such |
| 174 // actions ignore the contents of the popup so it doesn't matter that it was | 145 // actions ignore the contents of the popup so it doesn't matter that it was |
| 175 // open. | 146 // open. |
| 176 const bool consider_popup_open = log.is_popup_open && !log.is_paste_and_go; | 147 const bool consider_popup_open = log.is_popup_open && !log.is_paste_and_go; |
| 177 omnibox_event->set_is_popup_open(consider_popup_open); | 148 omnibox_event->set_is_popup_open(consider_popup_open); |
| 178 omnibox_event->set_is_paste_and_go(log.is_paste_and_go); | 149 omnibox_event->set_is_paste_and_go(log.is_paste_and_go); |
| 179 if (consider_popup_open) { | 150 if (consider_popup_open) { |
| 180 omnibox_event->set_is_top_result_hidden_in_dropdown( | 151 omnibox_event->set_is_top_result_hidden_in_dropdown( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 191 suggestion->set_typed_count(i->typed_count); | 162 suggestion->set_typed_count(i->typed_count); |
| 192 suggestion->set_is_starred(i->starred); | 163 suggestion->set_is_starred(i->starred); |
| 193 } | 164 } |
| 194 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); | 165 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); |
| 195 i != log.providers_info.end(); ++i) { | 166 i != log.providers_info.end(); ++i) { |
| 196 OmniboxEventProto::ProviderInfo* provider_info = | 167 OmniboxEventProto::ProviderInfo* provider_info = |
| 197 omnibox_event->add_provider_info(); | 168 omnibox_event->add_provider_info(); |
| 198 provider_info->CopyFrom(*i); | 169 provider_info->CopyFrom(*i); |
| 199 } | 170 } |
| 200 } | 171 } |
| OLD | NEW |