OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/security_interstitials/core/metrics_helper.h" | 5 #include "components/security_interstitials/core/metrics_helper.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
10 #include "base/metrics/user_metrics.h" | 11 #include "base/metrics/user_metrics.h" |
11 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
12 #include "components/history/core/browser/history_service.h" | 13 #include "components/history/core/browser/history_service.h" |
13 #include "components/rappor/rappor_service.h" | 14 #include "components/rappor/rappor_service.h" |
14 #include "components/rappor/rappor_utils.h" | 15 #include "components/rappor/rappor_utils.h" |
15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 16 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
16 | 17 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (!settings_.extra_suffix.empty()) { | 160 if (!settings_.extra_suffix.empty()) { |
160 RecordSingleDecisionToMetrics( | 161 RecordSingleDecisionToMetrics( |
161 decision, histogram_name + "." + settings_.extra_suffix); | 162 decision, histogram_name + "." + settings_.extra_suffix); |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
165 void MetricsHelper::RecordUserDecisionToRappor(Decision decision) { | 166 void MetricsHelper::RecordUserDecisionToRappor(Decision decision) { |
166 if (!rappor_service_ || (decision != PROCEED && decision != DONT_PROCEED)) | 167 if (!rappor_service_ || (decision != PROCEED && decision != DONT_PROCEED)) |
167 return; | 168 return; |
168 | 169 |
169 scoped_ptr<rappor::Sample> sample = | 170 std::unique_ptr<rappor::Sample> sample = |
170 rappor_service_->CreateSample(settings_.rappor_report_type); | 171 rappor_service_->CreateSample(settings_.rappor_report_type); |
171 | 172 |
172 // This will populate, for example, "intersitial.malware.domain" or | 173 // This will populate, for example, "intersitial.malware.domain" or |
173 // "interstitial.ssl2.domain". |domain| will be empty for hosts w/o TLDs. | 174 // "interstitial.ssl2.domain". |domain| will be empty for hosts w/o TLDs. |
174 const std::string domain = | 175 const std::string domain = |
175 rappor::GetDomainAndRegistrySampleFromGURL(request_url_); | 176 rappor::GetDomainAndRegistrySampleFromGURL(request_url_); |
176 sample->SetStringField("domain", domain); | 177 sample->SetStringField("domain", domain); |
177 | 178 |
178 // Only report history and decision if we have history data. | 179 // Only report history and decision if we have history data. |
179 if (num_visits_ >= 0) { | 180 if (num_visits_ >= 0) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 213 } |
213 | 214 |
214 void MetricsHelper::OnGotHistoryCount(bool success, | 215 void MetricsHelper::OnGotHistoryCount(bool success, |
215 int num_visits, | 216 int num_visits, |
216 base::Time /*first_visit*/) { | 217 base::Time /*first_visit*/) { |
217 if (success) | 218 if (success) |
218 num_visits_ = num_visits; | 219 num_visits_ = num_visits; |
219 } | 220 } |
220 | 221 |
221 } // namespace security_interstitials | 222 } // namespace security_interstitials |
OLD | NEW |