Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ | 5 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ |
| 6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ | 6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 8 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
| 9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 10 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 class WebContents; | 15 class WebContents; |
| 14 } | 16 } |
| 15 | 17 |
| 16 namespace extensions { | 18 namespace extensions { |
| 17 class ExperienceSamplingEvent; | 19 class ExperienceSamplingEvent; |
| 18 } | 20 } |
| 19 | 21 |
| 20 // Most of the security interstitials share a common layout and set of | 22 // Most of the security interstitials share a common layout and set of |
| 21 // choices. SecurityInterstitialUmaHelper is intended to help the security | 23 // choices. SecurityInterstitialUmaHelper is intended to help the security |
| 22 // interstitials record user choices in a common way via UMA histograms. | 24 // interstitials record user choices in a common way via UMA histograms |
| 25 // and RAPPOR metrics. | |
| 26 // TODO(nparker): Rename *UmaHelper to *MetricsHelper | |
| 23 class SecurityInterstitialUmaHelper { | 27 class SecurityInterstitialUmaHelper { |
| 24 public: | 28 public: |
| 25 // These enums are used for histograms. Don't reorder, delete, or insert | 29 // These enums are used for histograms. Don't reorder, delete, or insert |
| 26 // elements. New elements should be added at the end (right before the max). | 30 // elements. New elements should be added at the end (right before the max). |
| 27 enum SecurityInterstitialDecision { | 31 enum SecurityInterstitialDecision { |
| 28 SHOW, | 32 SHOW, |
| 29 PROCEED, | 33 PROCEED, |
| 30 DONT_PROCEED, | 34 DONT_PROCEED, |
| 31 PROCEEDING_DISABLED, | 35 PROCEEDING_DISABLED, |
| 32 MAX_DECISION | 36 MAX_DECISION |
| 33 }; | 37 }; |
| 34 enum SecurityInterstitialInteraction { | 38 enum SecurityInterstitialInteraction { |
| 35 TOTAL_VISITS, | 39 TOTAL_VISITS, |
| 36 SHOW_ADVANCED, | 40 SHOW_ADVANCED, |
| 37 SHOW_PRIVACY_POLICY, | 41 SHOW_PRIVACY_POLICY, |
| 38 SHOW_DIAGNOSTIC, | 42 SHOW_DIAGNOSTIC, |
| 39 SHOW_LEARN_MORE, | 43 SHOW_LEARN_MORE, |
| 40 RELOAD, | 44 RELOAD, |
| 41 OPEN_TIME_SETTINGS, | 45 OPEN_TIME_SETTINGS, |
| 42 MAX_INTERACTION | 46 MAX_INTERACTION |
| 43 }; | 47 }; |
| 44 | 48 |
| 49 // Args: | |
| 50 // url: Full URL of page that triggered the interstitial | |
|
felt
2015/01/28 19:19:17
Does it matter whether it's the full URL or just t
Nathan Parker
2015/01/29 01:36:02
Not currently, no, but I'd rather this code decide
felt
2015/01/29 06:18:36
The history manager lookup only works on a per-ori
Nathan Parker
2015/01/30 00:39:51
Ah, interesting point. So to accurately report (l
| |
| 51 // uma_prefix: Histogram prefix. e.g. "phishing" | |
| 52 // rappor_prefix: Metric prefix. e.g. "SafeBrowsing.Phishing" | |
| 53 // If empty, no data will be reported to Rappor. | |
| 54 // sampling_event_name: Event name for Experience Sampling. | |
| 55 // e.g. "phishing_interstitial_" | |
| 45 SecurityInterstitialUmaHelper(content::WebContents* web_contents, | 56 SecurityInterstitialUmaHelper(content::WebContents* web_contents, |
| 46 const GURL& url, | 57 const GURL& url, |
| 47 const std::string& histogram_prefix, | 58 const std::string& uma_prefix, |
| 59 const std::string& rappor_prefix, | |
| 48 const std::string& sampling_event_name); | 60 const std::string& sampling_event_name); |
| 49 ~SecurityInterstitialUmaHelper(); | 61 ~SecurityInterstitialUmaHelper(); |
| 50 | 62 |
| 51 // Record a user decision or interaction to the appropriate UMA histogram. | 63 // Record a user decision or interaction to the appropriate UMA histogram |
| 64 // and potentially in a RAPPOR metric. | |
| 52 void RecordUserDecision(SecurityInterstitialDecision decision); | 65 void RecordUserDecision(SecurityInterstitialDecision decision); |
| 53 void RecordUserInteraction(SecurityInterstitialInteraction interaction); | 66 void RecordUserInteraction(SecurityInterstitialInteraction interaction); |
| 54 | 67 |
| 55 private: | 68 private: |
| 56 // Used to query the HistoryService to see if the URL is in history. | 69 // Used to query the HistoryService to see if the URL is in history. |
| 57 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); | 70 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); |
| 58 | 71 |
| 59 content::WebContents* web_contents_; | 72 content::WebContents* web_contents_; |
| 60 const GURL request_url_; | 73 const GURL request_url_; |
| 61 const std::string histogram_prefix_; | 74 const std::string uma_prefix_; |
| 75 const std::string rappor_prefix_; | |
| 62 const std::string sampling_event_name_; | 76 const std::string sampling_event_name_; |
| 63 int num_visits_; | 77 int num_visits_; |
| 64 base::CancelableTaskTracker request_tracker_; | 78 base::CancelableTaskTracker request_tracker_; |
| 65 #if defined(ENABLE_EXTENSIONS) | 79 #if defined(ENABLE_EXTENSIONS) |
| 66 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; | 80 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; |
| 67 #endif | 81 #endif |
| 68 | 82 |
| 69 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialUmaHelper); | 83 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialUmaHelper); |
| 70 }; | 84 }; |
| 71 | 85 |
| 72 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ | 86 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_UMA_HELPER_H_ |
| OLD | NEW |