Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: chrome/browser/interstitials/chrome_metrics_helper.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/interstitials/chrome_metrics_helper.h ('k') | chrome/browser/io_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/features.h" 10 #include "chrome/common/features.h"
11 #include "components/history/core/browser/history_service.h" 11 #include "components/history/core/browser/history_service.h"
12 #include "components/rappor/rappor_service.h" 12 #include "components/rappor/rappor_service.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "extensions/features/features.h"
14 15
15 #if defined(ENABLE_EXTENSIONS) 16 #if BUILDFLAG(ENABLE_EXTENSIONS)
16 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 17 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
17 #endif 18 #endif
18 19
19 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 20 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
20 #include "chrome/browser/ssl/captive_portal_metrics_recorder.h" 21 #include "chrome/browser/ssl/captive_portal_metrics_recorder.h"
21 #endif 22 #endif
22 23
23 ChromeMetricsHelper::ChromeMetricsHelper( 24 ChromeMetricsHelper::ChromeMetricsHelper(
24 content::WebContents* web_contents, 25 content::WebContents* web_contents,
25 const GURL& request_url, 26 const GURL& request_url,
26 const security_interstitials::MetricsHelper::ReportDetails settings, 27 const security_interstitials::MetricsHelper::ReportDetails settings,
27 const std::string& sampling_event_name) 28 const std::string& sampling_event_name)
28 : security_interstitials::MetricsHelper( 29 : security_interstitials::MetricsHelper(
29 request_url, 30 request_url,
30 settings, 31 settings,
31 HistoryServiceFactory::GetForProfile( 32 HistoryServiceFactory::GetForProfile(
32 Profile::FromBrowserContext(web_contents->GetBrowserContext()), 33 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
33 ServiceAccessType::EXPLICIT_ACCESS), 34 ServiceAccessType::EXPLICIT_ACCESS),
34 g_browser_process->rappor_service() 35 g_browser_process->rappor_service()
35 ? g_browser_process->rappor_service()->AsWeakPtr() 36 ? g_browser_process->rappor_service()->AsWeakPtr()
36 : base::WeakPtr<rappor::RapporService>()), 37 : base::WeakPtr<rappor::RapporService>()),
37 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) || defined(ENABLE_EXTENSIONS) 38 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) || BUILDFLAG(ENABLE_EXTENSIONS)
38 web_contents_(web_contents), 39 web_contents_(web_contents),
39 #endif 40 #endif
40 request_url_(request_url), 41 request_url_(request_url),
41 sampling_event_name_(sampling_event_name) { 42 sampling_event_name_(sampling_event_name) {
42 DCHECK(!sampling_event_name_.empty()); 43 DCHECK(!sampling_event_name_.empty());
43 } 44 }
44 45
45 ChromeMetricsHelper::~ChromeMetricsHelper() {} 46 ChromeMetricsHelper::~ChromeMetricsHelper() {}
46 47
47 void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(bool overridable) { 48 void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(bool overridable) {
48 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 49 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
49 captive_portal_recorder_.reset( 50 captive_portal_recorder_.reset(
50 new CaptivePortalMetricsRecorder(web_contents_, overridable)); 51 new CaptivePortalMetricsRecorder(web_contents_, overridable));
51 #endif 52 #endif
52 } 53 }
53 54
54 void ChromeMetricsHelper::RecordExtraShutdownMetrics() { 55 void ChromeMetricsHelper::RecordExtraShutdownMetrics() {
55 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 56 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
56 // The captive portal metrics should be recorded when the interstitial is 57 // The captive portal metrics should be recorded when the interstitial is
57 // closing (or destructing). 58 // closing (or destructing).
58 if (captive_portal_recorder_) 59 if (captive_portal_recorder_)
59 captive_portal_recorder_->RecordCaptivePortalUMAStatistics(); 60 captive_portal_recorder_->RecordCaptivePortalUMAStatistics();
60 #endif 61 #endif
61 } 62 }
62 63
63 void ChromeMetricsHelper::RecordExtraUserDecisionMetrics( 64 void ChromeMetricsHelper::RecordExtraUserDecisionMetrics(
64 security_interstitials::MetricsHelper::Decision decision) { 65 security_interstitials::MetricsHelper::Decision decision) {
65 #if defined(ENABLE_EXTENSIONS) 66 #if BUILDFLAG(ENABLE_EXTENSIONS)
66 if (!sampling_event_.get()) { 67 if (!sampling_event_.get()) {
67 sampling_event_.reset(new extensions::ExperienceSamplingEvent( 68 sampling_event_.reset(new extensions::ExperienceSamplingEvent(
68 sampling_event_name_, request_url_, 69 sampling_event_name_, request_url_,
69 web_contents_->GetLastCommittedURL(), 70 web_contents_->GetLastCommittedURL(),
70 web_contents_->GetBrowserContext())); 71 web_contents_->GetBrowserContext()));
71 } 72 }
72 switch (decision) { 73 switch (decision) {
73 case PROCEED: 74 case PROCEED:
74 sampling_event_->CreateUserDecisionEvent( 75 sampling_event_->CreateUserDecisionEvent(
75 extensions::ExperienceSamplingEvent::kProceed); 76 extensions::ExperienceSamplingEvent::kProceed);
76 break; 77 break;
77 case DONT_PROCEED: 78 case DONT_PROCEED:
78 sampling_event_->CreateUserDecisionEvent( 79 sampling_event_->CreateUserDecisionEvent(
79 extensions::ExperienceSamplingEvent::kDeny); 80 extensions::ExperienceSamplingEvent::kDeny);
80 break; 81 break;
81 case SHOW: 82 case SHOW:
82 case PROCEEDING_DISABLED: 83 case PROCEEDING_DISABLED:
83 case MAX_DECISION: 84 case MAX_DECISION:
84 break; 85 break;
85 } 86 }
86 #endif 87 #endif
87 } 88 }
88 89
89 void ChromeMetricsHelper::RecordExtraUserInteractionMetrics( 90 void ChromeMetricsHelper::RecordExtraUserInteractionMetrics(
90 security_interstitials::MetricsHelper::Interaction interaction) { 91 security_interstitials::MetricsHelper::Interaction interaction) {
91 #if defined(ENABLE_EXTENSIONS) 92 #if BUILDFLAG(ENABLE_EXTENSIONS)
92 if (!sampling_event_.get()) { 93 if (!sampling_event_.get()) {
93 sampling_event_.reset(new extensions::ExperienceSamplingEvent( 94 sampling_event_.reset(new extensions::ExperienceSamplingEvent(
94 sampling_event_name_, request_url_, 95 sampling_event_name_, request_url_,
95 web_contents_->GetLastCommittedURL(), 96 web_contents_->GetLastCommittedURL(),
96 web_contents_->GetBrowserContext())); 97 web_contents_->GetBrowserContext()));
97 } 98 }
98 switch (interaction) { 99 switch (interaction) {
99 case SHOW_LEARN_MORE: 100 case SHOW_LEARN_MORE:
100 sampling_event_->set_has_viewed_learn_more(true); 101 sampling_event_->set_has_viewed_learn_more(true);
101 break; 102 break;
102 case SHOW_ADVANCED: 103 case SHOW_ADVANCED:
103 sampling_event_->set_has_viewed_details(true); 104 sampling_event_->set_has_viewed_details(true);
104 break; 105 break;
105 case SHOW_PRIVACY_POLICY: 106 case SHOW_PRIVACY_POLICY:
106 case SHOW_DIAGNOSTIC: 107 case SHOW_DIAGNOSTIC:
107 case RELOAD: 108 case RELOAD:
108 case OPEN_TIME_SETTINGS: 109 case OPEN_TIME_SETTINGS:
109 case TOTAL_VISITS: 110 case TOTAL_VISITS:
110 case SET_EXTENDED_REPORTING_ENABLED: 111 case SET_EXTENDED_REPORTING_ENABLED:
111 case SET_EXTENDED_REPORTING_DISABLED: 112 case SET_EXTENDED_REPORTING_DISABLED:
112 case EXTENDED_REPORTING_IS_ENABLED: 113 case EXTENDED_REPORTING_IS_ENABLED:
113 case REPORT_PHISHING_ERROR: 114 case REPORT_PHISHING_ERROR:
114 case SHOW_WHITEPAPER: 115 case SHOW_WHITEPAPER:
115 case MAX_INTERACTION: 116 case MAX_INTERACTION:
116 break; 117 break;
117 } 118 }
118 #endif 119 #endif
119 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/interstitials/chrome_metrics_helper.h ('k') | chrome/browser/io_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698