Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/interstitials/security_interstitial_metrics_helper.h" | 5 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/history/history_service.h" | 11 #include "chrome/browser/history/history_service.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/metrics/rappor/sampling.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/webdata/web_data_service_factory.h" | 15 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 15 #include "components/rappor/rappor_service.h" | 16 #include "components/rappor/rappor_service.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 18 | 19 |
| 19 #if defined(ENABLE_EXTENSIONS) | 20 #if defined(ENABLE_EXTENSIONS) |
| 20 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" | 21 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 "interstitial." + uma_prefix_ + ".decision"); | 63 "interstitial." + uma_prefix_ + ".decision"); |
| 63 base::HistogramBase* decision_histogram = base::LinearHistogram::FactoryGet( | 64 base::HistogramBase* decision_histogram = base::LinearHistogram::FactoryGet( |
| 64 decision_histogram_name, 1, MAX_DECISION, MAX_DECISION + 1, | 65 decision_histogram_name, 1, MAX_DECISION, MAX_DECISION + 1, |
| 65 base::HistogramBase::kUmaTargetedHistogramFlag); | 66 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 66 decision_histogram->Add(decision); | 67 decision_histogram->Add(decision); |
| 67 | 68 |
| 68 // Rappor | 69 // Rappor |
| 69 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); | 70 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); |
| 70 if (rappor_service && rappor_reporting_ == REPORT_RAPPOR && | 71 if (rappor_service && rappor_reporting_ == REPORT_RAPPOR && |
| 71 (decision == PROCEED || decision == DONT_PROCEED)) { | 72 (decision == PROCEED || decision == DONT_PROCEED)) { |
| 72 // |domain| will be empty for hosts w/o TLDs (localhost, ip addrs) | 73 // |domain| will be empty for hosts w/o TLDs (localhost, ip addrs) |
|
Nathan Parker
2015/02/18 21:56:46
Update this comment. I think it's true still exce
Steven Holte
2015/02/19 23:42:19
Done.
| |
| 73 const std::string domain = | 74 const std::string domain = rappor::GetDomainAndRegistrySampleFromGURL( |
| 74 net::registry_controlled_domains::GetDomainAndRegistry( | 75 request_url_); |
| 75 request_url_, | |
| 76 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | |
| 77 | 76 |
| 78 // e.g. "interstitial.malware.domain" or "interstitial.ssl.domain" | 77 // e.g. "interstitial.malware.domain" or "interstitial.ssl.domain" |
| 79 const std::string metric_name = | 78 const std::string metric_name = |
| 80 "interstitial." + rappor_prefix_ + ".domain"; | 79 "interstitial." + rappor_prefix_ + ".domain"; |
| 81 rappor_service->RecordSample(metric_name, rappor::COARSE_RAPPOR_TYPE, | 80 rappor_service->RecordSample(metric_name, rappor::COARSE_RAPPOR_TYPE, |
| 82 domain); | 81 domain); |
| 83 // TODO(nparker): Add reporting of (num_visits > 0) and decision | 82 // TODO(nparker): Add reporting of (num_visits > 0) and decision |
| 84 // once http://crbug.com/451647 is fixed. | 83 // once http://crbug.com/451647 is fixed. |
| 85 } | 84 } |
| 86 | 85 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 #endif | 156 #endif |
| 158 } | 157 } |
| 159 | 158 |
| 160 void SecurityInterstitialMetricsHelper::OnGotHistoryCount( | 159 void SecurityInterstitialMetricsHelper::OnGotHistoryCount( |
| 161 bool success, | 160 bool success, |
| 162 int num_visits, | 161 int num_visits, |
| 163 base::Time first_visit) { | 162 base::Time first_visit) { |
| 164 if (success) | 163 if (success) |
| 165 num_visits_ = num_visits; | 164 num_visits_ = num_visits; |
| 166 } | 165 } |
| OLD | NEW |