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