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

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.h

Issue 839183002: Remove redundancy in security interstitial UMA logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Answering mattm's questions Created 5 years, 11 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SSL_SSL_BLOCKING_PAGE_H_ 5 #ifndef CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
6 #define CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_ 6 #define CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/task/cancelable_task_tracker.h" 13 #include "base/task/cancelable_task_tracker.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/history/history_service.h"
16 #include "chrome/browser/interstitials/security_interstitial_page.h" 15 #include "chrome/browser/interstitials/security_interstitial_page.h"
16 #include "chrome/browser/interstitials/security_interstitial_uma_helper.h"
17 #include "net/ssl/ssl_info.h" 17 #include "net/ssl/ssl_info.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 #if defined(ENABLE_EXTENSIONS) 20 #if defined(ENABLE_EXTENSIONS)
21 namespace extensions { 21 namespace extensions {
22 class ExperienceSamplingEvent; 22 class ExperienceSamplingEvent;
23 } 23 }
24 #endif 24 #endif
25 25
26 class SSLErrorClassification; 26 class SSLErrorClassification;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SSLBlockingPage(content::WebContents* web_contents, 68 SSLBlockingPage(content::WebContents* web_contents,
69 int cert_error, 69 int cert_error,
70 const net::SSLInfo& ssl_info, 70 const net::SSLInfo& ssl_info,
71 const GURL& request_url, 71 const GURL& request_url,
72 int options_mask, 72 int options_mask,
73 const base::Callback<void(bool)>& callback); 73 const base::Callback<void(bool)>& callback);
74 74
75 // SecurityInterstitialPage method: 75 // SecurityInterstitialPage method:
76 const void* GetTypeForTesting() const override; 76 const void* GetTypeForTesting() const override;
77 77
78 // A method that sets strings in the specified dictionary from the passed
79 // vector so that they can be used to resource the ssl_roadblock.html/
80 // ssl_error.html files.
81 // Note: there can be up to 5 strings in |extra_info|.
82 static void SetExtraInfo(base::DictionaryValue* strings,
83 const std::vector<base::string16>& extra_info);
84
85 // Returns true if |options_mask| refers to an overridable SSL error. 78 // Returns true if |options_mask| refers to an overridable SSL error.
86 static bool IsOptionsOverridable(int options_mask); 79 static bool IsOptionsOverridable(int options_mask);
87 80
88 protected: 81 protected:
89 // InterstitialPageDelegate implementation. 82 // InterstitialPageDelegate implementation.
90 void CommandReceived(const std::string& command) override; 83 void CommandReceived(const std::string& command) override;
91 void OverrideEntry(content::NavigationEntry* entry) override; 84 void OverrideEntry(content::NavigationEntry* entry) override;
92 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; 85 void OverrideRendererPrefs(content::RendererPreferences* prefs) override;
93 void OnProceed() override; 86 void OnProceed() override;
94 void OnDontProceed() override; 87 void OnDontProceed() override;
95 88
96 // SecurityInterstitialPage implementation: 89 // SecurityInterstitialPage implementation:
97 bool ShouldCreateNewNavigation() const override; 90 bool ShouldCreateNewNavigation() const override;
98 void PopulateInterstitialStrings( 91 void PopulateInterstitialStrings(
99 base::DictionaryValue* load_time_data) override; 92 base::DictionaryValue* load_time_data) override;
100 93
101 private: 94 private:
102 void NotifyDenyCertificate(); 95 void NotifyDenyCertificate();
103 void NotifyAllowCertificate(); 96 void NotifyAllowCertificate();
104 97
105 // Used to query the HistoryService to see if the URL is in history. For UMA. 98 std::string GetHistogramPrefix() const;
106 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); 99 std::string GetSamplingEventName() const;
107 100
108 base::Callback<void(bool)> callback_; 101 base::Callback<void(bool)> callback_;
109 102
110 const int cert_error_; 103 const int cert_error_;
111 const net::SSLInfo ssl_info_; 104 const net::SSLInfo ssl_info_;
112 // There are two ways for the user to override an interstitial: 105 // There are two ways for the user to override an interstitial:
113 // 106 //
114 // overridable_) By clicking on "Advanced" and then "Proceed". 107 // overridable_) By clicking on "Advanced" and then "Proceed".
115 // - This corresponds to "the user can override using the UI". 108 // - This corresponds to "the user can override using the UI".
116 // danger_overridable_) By typing the word "danger". 109 // danger_overridable_) By typing the word "danger".
117 // - This is an undocumented workaround. 110 // - This is an undocumented workaround.
118 // - This can be set to "false" dynamically to prevent the behaviour. 111 // - This can be set to "false" dynamically to prevent the behaviour.
119 const bool overridable_; 112 const bool overridable_;
120 bool danger_overridable_; 113 bool danger_overridable_;
121 // Has the site requested strict enforcement of certificate errors? 114 // Has the site requested strict enforcement of certificate errors?
122 const bool strict_enforcement_; 115 const bool strict_enforcement_;
123 // Is the hostname for an internal network?
124 bool internal_;
125 // How many times is this same URL in history?
126 int num_visits_;
127 // Used for getting num_visits_.
128 base::CancelableTaskTracker request_tracker_;
129 // Did the user previously allow a bad certificate but the decision has now 116 // Did the user previously allow a bad certificate but the decision has now
130 // expired? 117 // expired?
131 const bool expired_but_previously_allowed_; 118 const bool expired_but_previously_allowed_;
132 scoped_ptr<SSLErrorClassification> ssl_error_classification_; 119 scoped_ptr<SSLErrorClassification> ssl_error_classification_;
120 scoped_ptr<SecurityInterstitialUmaHelper> uma_helper_;
133 121
134 #if defined(ENABLE_EXTENSIONS) 122 // Which type of Safe Browsing interstitial this is.
135 // For Chrome Experience Sampling Platform: this maintains event state. 123 enum SSLInterstitialReason {
136 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 124 SSL_REASON_SSL,
137 #endif 125 SSL_REASON_BAD_CLOCK
138 126 } interstitial_reason_;
139 content::NotificationRegistrar registrar_;
140 127
141 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage); 128 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage);
142 }; 129 };
143 130
144 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_ 131 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698