| 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 <utility> |
| 8 |
| 7 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| 9 #include "base/metrics/user_metrics_action.h" | 11 #include "base/metrics/user_metrics_action.h" |
| 10 #include "components/history/core/browser/history_service.h" | 12 #include "components/history/core/browser/history_service.h" |
| 11 #include "components/rappor/rappor_service.h" | 13 #include "components/rappor/rappor_service.h" |
| 12 #include "components/rappor/rappor_utils.h" | 14 #include "components/rappor/rappor_utils.h" |
| 13 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 15 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 14 | 16 |
| 15 using base::RecordAction; | 17 using base::RecordAction; |
| 16 using base::UserMetricsAction; | 18 using base::UserMetricsAction; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 int flags = 0; | 174 int flags = 0; |
| 173 if (decision == PROCEED) | 175 if (decision == PROCEED) |
| 174 flags |= 1 << InterstitialFlagBits::DID_PROCEED; | 176 flags |= 1 << InterstitialFlagBits::DID_PROCEED; |
| 175 if (num_visits_ > 0) | 177 if (num_visits_ > 0) |
| 176 flags |= 1 << InterstitialFlagBits::IS_REPEAT_VISIT; | 178 flags |= 1 << InterstitialFlagBits::IS_REPEAT_VISIT; |
| 177 // e.g. "interstitial.malware.flags" | 179 // e.g. "interstitial.malware.flags" |
| 178 sample->SetFlagsField("flags", flags, | 180 sample->SetFlagsField("flags", flags, |
| 179 InterstitialFlagBits::HIGHEST_USED_BIT + 1); | 181 InterstitialFlagBits::HIGHEST_USED_BIT + 1); |
| 180 } | 182 } |
| 181 rappor_service_->RecordSampleObj("interstitial." + settings_.rappor_prefix, | 183 rappor_service_->RecordSampleObj("interstitial." + settings_.rappor_prefix, |
| 182 sample.Pass()); | 184 std::move(sample)); |
| 183 } | 185 } |
| 184 | 186 |
| 185 void MetricsHelper::RecordUserInteraction(Interaction interaction) { | 187 void MetricsHelper::RecordUserInteraction(Interaction interaction) { |
| 186 const std::string histogram_name( | 188 const std::string histogram_name( |
| 187 "interstitial." + settings_.metric_prefix + ".interaction"); | 189 "interstitial." + settings_.metric_prefix + ".interaction"); |
| 188 RecordSingleInteractionToMetrics(interaction, histogram_name); | 190 RecordSingleInteractionToMetrics(interaction, histogram_name); |
| 189 if (!settings_.extra_suffix.empty()) { | 191 if (!settings_.extra_suffix.empty()) { |
| 190 RecordSingleInteractionToMetrics( | 192 RecordSingleInteractionToMetrics( |
| 191 interaction, histogram_name + "." + settings_.extra_suffix); | 193 interaction, histogram_name + "." + settings_.extra_suffix); |
| 192 } | 194 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 204 } | 206 } |
| 205 | 207 |
| 206 void MetricsHelper::OnGotHistoryCount(bool success, | 208 void MetricsHelper::OnGotHistoryCount(bool success, |
| 207 int num_visits, | 209 int num_visits, |
| 208 base::Time /*first_visit*/) { | 210 base::Time /*first_visit*/) { |
| 209 if (success) | 211 if (success) |
| 210 num_visits_ = num_visits; | 212 num_visits_ = num_visits; |
| 211 } | 213 } |
| 212 | 214 |
| 213 } // namespace security_interstitials | 215 } // namespace security_interstitials |
| OLD | NEW |