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" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (!chrome::IsOffTheRecordSessionActive()) | 106 if (!chrome::IsOffTheRecordSessionActive()) |
107 RecordOmniboxOpenedURL(*content::Details<OmniboxLog>(details).ptr()); | 107 RecordOmniboxOpenedURL(*content::Details<OmniboxLog>(details).ptr()); |
108 } | 108 } |
109 | 109 |
110 void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) { | 110 void OmniboxMetricsProvider::RecordOmniboxOpenedURL(const OmniboxLog& log) { |
111 std::vector<base::string16> terms; | 111 std::vector<base::string16> terms; |
112 const int num_terms = | 112 const int num_terms = |
113 static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms)); | 113 static_cast<int>(Tokenize(log.text, base::kWhitespaceUTF16, &terms)); |
114 | 114 |
115 OmniboxEventProto* omnibox_event = omnibox_events_cache.add_omnibox_event(); | 115 OmniboxEventProto* omnibox_event = omnibox_events_cache.add_omnibox_event(); |
116 omnibox_event->set_time(MetricsLog::GetCurrentTime()); | 116 omnibox_event->set_time(metrics::MetricsLog::GetCurrentTime()); |
117 if (log.tab_id != -1) { | 117 if (log.tab_id != -1) { |
118 // If we know what tab the autocomplete URL was opened in, log it. | 118 // If we know what tab the autocomplete URL was opened in, log it. |
119 omnibox_event->set_tab_id(log.tab_id); | 119 omnibox_event->set_tab_id(log.tab_id); |
120 } | 120 } |
121 omnibox_event->set_typed_length(log.text.length()); | 121 omnibox_event->set_typed_length(log.text.length()); |
122 omnibox_event->set_just_deleted_text(log.just_deleted_text); | 122 omnibox_event->set_just_deleted_text(log.just_deleted_text); |
123 omnibox_event->set_num_typed_terms(num_terms); | 123 omnibox_event->set_num_typed_terms(num_terms); |
124 omnibox_event->set_selected_index(log.selected_index); | 124 omnibox_event->set_selected_index(log.selected_index); |
125 if (log.completed_length != base::string16::npos) | 125 if (log.completed_length != base::string16::npos) |
126 omnibox_event->set_completed_length(log.completed_length); | 126 omnibox_event->set_completed_length(log.completed_length); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (i->typed_count != -1) | 161 if (i->typed_count != -1) |
162 suggestion->set_typed_count(i->typed_count); | 162 suggestion->set_typed_count(i->typed_count); |
163 } | 163 } |
164 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); | 164 for (ProvidersInfo::const_iterator i(log.providers_info.begin()); |
165 i != log.providers_info.end(); ++i) { | 165 i != log.providers_info.end(); ++i) { |
166 OmniboxEventProto::ProviderInfo* provider_info = | 166 OmniboxEventProto::ProviderInfo* provider_info = |
167 omnibox_event->add_provider_info(); | 167 omnibox_event->add_provider_info(); |
168 provider_info->CopyFrom(*i); | 168 provider_info->CopyFrom(*i); |
169 } | 169 } |
170 } | 170 } |
OLD | NEW |