| 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" | 12 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_result.h" | 15 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/omnibox/omnibox_log.h" | 17 #include "chrome/browser/omnibox/omnibox_log.h" |
| 18 #include "chrome/browser/ui/browser_otr_state.h" | 18 #include "chrome/browser/ui/browser_otr_state.h" |
| 19 #include "components/metrics/metrics_log_base.h" | 19 #include "components/metrics/metrics_log.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 | 21 |
| 22 using metrics::OmniboxEventProto; | 22 using metrics::OmniboxEventProto; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 OmniboxEventProto::InputType AsOmniboxEventInputType( | 26 OmniboxEventProto::InputType AsOmniboxEventInputType( |
| 27 AutocompleteInput::Type type) { | 27 AutocompleteInput::Type type) { |
| 28 switch (type) { | 28 switch (type) { |
| 29 case AutocompleteInput::INVALID: | 29 case AutocompleteInput::INVALID: |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!chrome::IsOffTheRecordSessionActive()) | 149 if (!chrome::IsOffTheRecordSessionActive()) |
| 150 RecordOmniboxOpenedURL(*content::Details<OmniboxLog>(details).ptr()); | 150 RecordOmniboxOpenedURL(*content::Details<OmniboxLog>(details).ptr()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) { | 153 void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) { |
| 154 std::vector<base::string16> terms; | 154 std::vector<base::string16> terms; |
| 155 const int num_terms = | 155 const int num_terms = |
| 156 static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms)); | 156 static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms)); |
| 157 | 157 |
| 158 OmniboxEventProto* omnibox_event = omnibox_events_cache.add_omnibox_event(); | 158 OmniboxEventProto* omnibox_event = omnibox_events_cache.add_omnibox_event(); |
| 159 omnibox_event->set_time(metrics::MetricsLogBase::GetCurrentTime()); | 159 omnibox_event->set_time(MetricsLog::GetCurrentTime()); |
| 160 if (log.tab_id != -1) { | 160 if (log.tab_id != -1) { |
| 161 // If we know what tab the autocomplete URL was opened in, log it. | 161 // If we know what tab the autocomplete URL was opened in, log it. |
| 162 omnibox_event->set_tab_id(log.tab_id); | 162 omnibox_event->set_tab_id(log.tab_id); |
| 163 } | 163 } |
| 164 omnibox_event->set_typed_length(log.text.length()); | 164 omnibox_event->set_typed_length(log.text.length()); |
| 165 omnibox_event->set_just_deleted_text(log.just_deleted_text); | 165 omnibox_event->set_just_deleted_text(log.just_deleted_text); |
| 166 omnibox_event->set_num_typed_terms(num_terms); | 166 omnibox_event->set_num_typed_terms(num_terms); |
| 167 omnibox_event->set_selected_index(log.selected_index); | 167 omnibox_event->set_selected_index(log.selected_index); |
| 168 if (log.completed_length != base::string16::npos) | 168 if (log.completed_length != base::string16::npos) |
| 169 omnibox_event->set_completed_length(log.completed_length); | 169 omnibox_event->set_completed_length(log.completed_length); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 suggestion->set_typed_count(i->typed_count); | 205 suggestion->set_typed_count(i->typed_count); |
| 206 suggestion->set_is_starred(i->starred); | 206 suggestion->set_is_starred(i->starred); |
| 207 } | 207 } |
| 208 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); | 208 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); |
| 209 i != log.providers_info.end(); ++i) { | 209 i != log.providers_info.end(); ++i) { |
| 210 OmniboxEventProto::ProviderInfo* provider_info = | 210 OmniboxEventProto::ProviderInfo* provider_info = |
| 211 omnibox_event->add_provider_info(); | 211 omnibox_event->add_provider_info(); |
| 212 provider_info->CopyFrom(*i); | 212 provider_info->CopyFrom(*i); |
| 213 } | 213 } |
| 214 } | 214 } |
| OLD | NEW |