Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / interstitials / security_interstitial_metrics_helper.h
blobffbe9d184d428f5f648ada34a6943b738ea07a72
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_METRICS_HELPER_H_
6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_METRICS_HELPER_H_
8 #include <string>
10 #include "base/task/cancelable_task_tracker.h"
11 #include "base/time/time.h"
12 #include "url/gurl.h"
14 namespace content {
15 class WebContents;
18 namespace extensions {
19 class ExperienceSamplingEvent;
22 // Most of the security interstitials share a common layout and set of
23 // choices. SecurityInterstitialMetricsHelper is intended to help the security
24 // interstitials record user choices in a common way via METRICS histograms
25 // and RAPPOR metrics.
26 class SecurityInterstitialMetricsHelper {
27 public:
28 // These enums are used for histograms. Don't reorder, delete, or insert
29 // elements. New elements should be added at the end (right before the max).
30 enum SecurityInterstitialDecision {
31 SHOW,
32 PROCEED,
33 DONT_PROCEED,
34 PROCEEDING_DISABLED,
35 MAX_DECISION
37 enum SecurityInterstitialInteraction {
38 TOTAL_VISITS,
39 SHOW_ADVANCED,
40 SHOW_PRIVACY_POLICY,
41 SHOW_DIAGNOSTIC,
42 SHOW_LEARN_MORE,
43 RELOAD,
44 OPEN_TIME_SETTINGS,
45 SET_EXTENDED_REPORTING_ENABLED,
46 SET_EXTENDED_REPORTING_DISABLED,
47 EXTENDED_REPORTING_IS_ENABLED,
48 REPORT_PHISHING_ERROR,
49 MAX_INTERACTION
52 enum RapporReporting {
53 REPORT_RAPPOR,
54 // Only use this for safe-browsing interstitials.
55 REPORT_RAPPOR_FOR_SAFE_BROWSING,
56 SKIP_RAPPOR,
59 // Args:
60 // url: URL of page that triggered the interstitial. Only origin is used.
61 // uma_prefix: Histogram prefix for UMA.
62 // examples: "phishing", "ssl_overridable"
63 // rappor_prefix: Metric prefix for Rappor.
64 // examples: "phishing", "ssl2"
65 // rappor_reporting: Used to skip rappor rapporting if desired.
66 // sampling_event_name: Event name for Experience Sampling.
67 // e.g. "phishing_interstitial_"
68 SecurityInterstitialMetricsHelper(content::WebContents* web_contents,
69 const GURL& url,
70 const std::string& uma_prefix,
71 const std::string& rappor_prefix,
72 RapporReporting rappor_reporting,
73 const std::string& sampling_event_name);
74 ~SecurityInterstitialMetricsHelper();
76 // Record a user decision or interaction to the appropriate UMA histogram
77 // and potentially in a RAPPOR metric.
78 void RecordUserDecision(SecurityInterstitialDecision decision);
79 void RecordUserInteraction(SecurityInterstitialInteraction interaction);
81 private:
82 // Used to query the HistoryService to see if the URL is in history.
83 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit);
85 content::WebContents* web_contents_;
86 const GURL request_url_;
87 const std::string uma_prefix_;
88 const std::string rappor_prefix_;
89 const RapporReporting rappor_reporting_;
90 const std::string sampling_event_name_;
91 int num_visits_;
92 base::CancelableTaskTracker request_tracker_;
93 #if defined(ENABLE_EXTENSIONS)
94 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
95 #endif
97 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialMetricsHelper);
100 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_METRICS_HELPER_H_