Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / interstitials / chrome_metrics_helper.cc
blobc886e448d1dea7fc45755200c84c92080a056990
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
3 // found in the LICENSE file.
5 #include "chrome/browser/interstitials/chrome_metrics_helper.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/history/history_service_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/history/core/browser/history_service.h"
11 #include "components/rappor/rappor_service.h"
12 #include "content/public/browser/web_contents.h"
14 #if defined(ENABLE_EXTENSIONS)
15 #include "chrome/browser/extensions/api/experience_sampling_private/experience_sampling.h"
16 #endif
18 ChromeMetricsHelper::ChromeMetricsHelper(
19 content::WebContents* web_contents,
20 const GURL& request_url,
21 const security_interstitials::MetricsHelper::ReportDetails settings,
22 const std::string& sampling_event_name)
23 : security_interstitials::MetricsHelper(
24 request_url,
25 settings,
26 HistoryServiceFactory::GetForProfile(
27 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
28 ServiceAccessType::EXPLICIT_ACCESS),
29 g_browser_process->rappor_service()),
30 web_contents_(web_contents),
31 request_url_(request_url),
32 sampling_event_name_(sampling_event_name) {
33 DCHECK(!sampling_event_name_.empty());
36 ChromeMetricsHelper::~ChromeMetricsHelper() {}
38 void ChromeMetricsHelper::RecordExtraUserDecisionMetrics(
39 security_interstitials::MetricsHelper::Decision decision) {
40 #if defined(ENABLE_EXTENSIONS)
41 if (!sampling_event_.get()) {
42 sampling_event_.reset(new extensions::ExperienceSamplingEvent(
43 sampling_event_name_, request_url_,
44 web_contents_->GetLastCommittedURL(),
45 web_contents_->GetBrowserContext()));
47 switch (decision) {
48 case PROCEED:
49 sampling_event_->CreateUserDecisionEvent(
50 extensions::ExperienceSamplingEvent::kProceed);
51 break;
52 case DONT_PROCEED:
53 sampling_event_->CreateUserDecisionEvent(
54 extensions::ExperienceSamplingEvent::kDeny);
55 break;
56 case SHOW:
57 case PROCEEDING_DISABLED:
58 case MAX_DECISION:
59 break;
61 #endif
64 void ChromeMetricsHelper::RecordExtraUserInteractionMetrics(
65 security_interstitials::MetricsHelper::Interaction interaction) {
66 #if defined(ENABLE_EXTENSIONS)
67 if (!sampling_event_.get()) {
68 sampling_event_.reset(new extensions::ExperienceSamplingEvent(
69 sampling_event_name_, request_url_,
70 web_contents_->GetLastCommittedURL(),
71 web_contents_->GetBrowserContext()));
73 switch (interaction) {
74 case SHOW_LEARN_MORE:
75 sampling_event_->set_has_viewed_learn_more(true);
76 break;
77 case SHOW_ADVANCED:
78 sampling_event_->set_has_viewed_details(true);
79 break;
80 case SHOW_PRIVACY_POLICY:
81 case SHOW_DIAGNOSTIC:
82 case RELOAD:
83 case OPEN_TIME_SETTINGS:
84 case TOTAL_VISITS:
85 case SET_EXTENDED_REPORTING_ENABLED:
86 case SET_EXTENDED_REPORTING_DISABLED:
87 case EXTENDED_REPORTING_IS_ENABLED:
88 case REPORT_PHISHING_ERROR:
89 case MAX_INTERACTION:
90 break;
92 #endif