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 "chrome/browser/interstitials/chrome_metrics_helper.h" | 5 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/history/history_service_factory.h" | 8 #include "chrome/browser/history/history_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ssl/captive_portal_metrics_recorder.h" | |
11 #include "components/history/core/browser/history_service.h" | 10 #include "components/history/core/browser/history_service.h" |
12 #include "components/rappor/rappor_service.h" | 11 #include "components/rappor/rappor_service.h" |
13 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
14 | 13 |
15 #if defined(ENABLE_EXTENSIONS) | 14 #if defined(ENABLE_EXTENSIONS) |
16 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" | 15 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
17 #endif | 16 #endif |
18 | 17 |
| 18 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 19 #include "chrome/browser/ssl/captive_portal_metrics_recorder.h" |
| 20 #endif |
| 21 |
19 ChromeMetricsHelper::ChromeMetricsHelper( | 22 ChromeMetricsHelper::ChromeMetricsHelper( |
20 content::WebContents* web_contents, | 23 content::WebContents* web_contents, |
21 const GURL& request_url, | 24 const GURL& request_url, |
22 const security_interstitials::MetricsHelper::ReportDetails settings, | 25 const security_interstitials::MetricsHelper::ReportDetails settings, |
23 const std::string& sampling_event_name) | 26 const std::string& sampling_event_name) |
24 : security_interstitials::MetricsHelper( | 27 : security_interstitials::MetricsHelper( |
25 request_url, | 28 request_url, |
26 settings, | 29 settings, |
27 HistoryServiceFactory::GetForProfile( | 30 HistoryServiceFactory::GetForProfile( |
28 Profile::FromBrowserContext(web_contents->GetBrowserContext()), | 31 Profile::FromBrowserContext(web_contents->GetBrowserContext()), |
29 ServiceAccessType::EXPLICIT_ACCESS), | 32 ServiceAccessType::EXPLICIT_ACCESS), |
30 g_browser_process->rappor_service()), | 33 g_browser_process->rappor_service()), |
31 web_contents_(web_contents), | 34 web_contents_(web_contents), |
32 request_url_(request_url), | 35 request_url_(request_url), |
33 sampling_event_name_(sampling_event_name) { | 36 sampling_event_name_(sampling_event_name) { |
34 DCHECK(!sampling_event_name_.empty()); | 37 DCHECK(!sampling_event_name_.empty()); |
35 } | 38 } |
36 | 39 |
37 ChromeMetricsHelper::~ChromeMetricsHelper() {} | 40 ChromeMetricsHelper::~ChromeMetricsHelper() {} |
38 | 41 |
39 void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(bool overridable) { | 42 void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(bool overridable) { |
| 43 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
40 captive_portal_recorder_.reset( | 44 captive_portal_recorder_.reset( |
41 new CaptivePortalMetricsRecorder(web_contents_, overridable)); | 45 new CaptivePortalMetricsRecorder(web_contents_, overridable)); |
| 46 #endif |
42 } | 47 } |
43 | 48 |
44 void ChromeMetricsHelper::RecordExtraShutdownMetrics() { | 49 void ChromeMetricsHelper::RecordExtraShutdownMetrics() { |
| 50 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
45 // The captive portal metrics should be recorded when the interstitial is | 51 // The captive portal metrics should be recorded when the interstitial is |
46 // closing (or destructing). | 52 // closing (or destructing). |
47 if (captive_portal_recorder_) | 53 if (captive_portal_recorder_) |
48 captive_portal_recorder_->RecordCaptivePortalUMAStatistics(); | 54 captive_portal_recorder_->RecordCaptivePortalUMAStatistics(); |
| 55 #endif |
49 } | 56 } |
50 | 57 |
51 void ChromeMetricsHelper::RecordExtraUserDecisionMetrics( | 58 void ChromeMetricsHelper::RecordExtraUserDecisionMetrics( |
52 security_interstitials::MetricsHelper::Decision decision) { | 59 security_interstitials::MetricsHelper::Decision decision) { |
53 #if defined(ENABLE_EXTENSIONS) | 60 #if defined(ENABLE_EXTENSIONS) |
54 if (!sampling_event_.get()) { | 61 if (!sampling_event_.get()) { |
55 sampling_event_.reset(new extensions::ExperienceSamplingEvent( | 62 sampling_event_.reset(new extensions::ExperienceSamplingEvent( |
56 sampling_event_name_, request_url_, | 63 sampling_event_name_, request_url_, |
57 web_contents_->GetLastCommittedURL(), | 64 web_contents_->GetLastCommittedURL(), |
58 web_contents_->GetBrowserContext())); | 65 web_contents_->GetBrowserContext())); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 case TOTAL_VISITS: | 104 case TOTAL_VISITS: |
98 case SET_EXTENDED_REPORTING_ENABLED: | 105 case SET_EXTENDED_REPORTING_ENABLED: |
99 case SET_EXTENDED_REPORTING_DISABLED: | 106 case SET_EXTENDED_REPORTING_DISABLED: |
100 case EXTENDED_REPORTING_IS_ENABLED: | 107 case EXTENDED_REPORTING_IS_ENABLED: |
101 case REPORT_PHISHING_ERROR: | 108 case REPORT_PHISHING_ERROR: |
102 case MAX_INTERACTION: | 109 case MAX_INTERACTION: |
103 break; | 110 break; |
104 } | 111 } |
105 #endif | 112 #endif |
106 } | 113 } |
OLD | NEW |