OLD | NEW |
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/interstitials/security_interstitial_metrics_helper.h" | |
16 #include "chrome/browser/interstitials/security_interstitial_page.h" | 15 #include "chrome/browser/interstitials/security_interstitial_page.h" |
17 #include "net/ssl/ssl_info.h" | 16 #include "net/ssl/ssl_info.h" |
18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
19 | 18 |
20 #if defined(ENABLE_EXTENSIONS) | 19 #if defined(ENABLE_EXTENSIONS) |
21 namespace extensions { | 20 namespace extensions { |
22 class ExperienceSamplingEvent; | 21 class ExperienceSamplingEvent; |
23 } | 22 } |
24 #endif | 23 #endif |
25 | 24 |
| 25 class SafeBrowsingUIManager; |
26 class SSLErrorClassification; | 26 class SSLErrorClassification; |
27 | 27 |
28 // This class is responsible for showing/hiding the interstitial page that is | 28 // This class is responsible for showing/hiding the interstitial page that is |
29 // shown when a certificate error happens. | 29 // shown when a certificate error happens. |
30 // It deletes itself when the interstitial page is closed. | 30 // It deletes itself when the interstitial page is closed. |
31 class SSLBlockingPage : public SecurityInterstitialPage { | 31 class SSLBlockingPage : public SecurityInterstitialPage { |
32 public: | 32 public: |
33 enum SSLBlockingPageOptionsMask { | 33 enum SSLBlockingPageOptionsMask { |
34 // Indicates whether or not the user could (assuming perfect knowledge) | 34 // Indicates whether or not the user could (assuming perfect knowledge) |
35 // successfully override the error and still get the security guarantees | 35 // successfully override the error and still get the security guarantees |
(...skipping 16 matching lines...) Expand all Loading... |
52 // Creates an SSL blocking page. If the blocking page isn't shown, the caller | 52 // Creates an SSL blocking page. If the blocking page isn't shown, the caller |
53 // is responsible for cleaning up the blocking page, otherwise the | 53 // is responsible for cleaning up the blocking page, otherwise the |
54 // interstitial takes ownership when shown. |options_mask| must be a bitwise | 54 // interstitial takes ownership when shown. |options_mask| must be a bitwise |
55 // mask of SSLBlockingPageOptionsMask values. | 55 // mask of SSLBlockingPageOptionsMask values. |
56 SSLBlockingPage(content::WebContents* web_contents, | 56 SSLBlockingPage(content::WebContents* web_contents, |
57 int cert_error, | 57 int cert_error, |
58 const net::SSLInfo& ssl_info, | 58 const net::SSLInfo& ssl_info, |
59 const GURL& request_url, | 59 const GURL& request_url, |
60 int options_mask, | 60 int options_mask, |
61 const base::Time& time_triggered, | 61 const base::Time& time_triggered, |
| 62 SafeBrowsingUIManager* safe_browsing_ui_manager, |
62 const base::Callback<void(bool)>& callback); | 63 const base::Callback<void(bool)>& callback); |
63 | 64 |
64 // InterstitialPageDelegate method: | 65 // InterstitialPageDelegate method: |
65 InterstitialPageDelegate::TypeID GetTypeForTesting() const override; | 66 InterstitialPageDelegate::TypeID GetTypeForTesting() const override; |
66 | 67 |
67 // Returns true if |options_mask| refers to an overridable SSL error. | 68 // Returns true if |options_mask| refers to an overridable SSL error. |
68 static bool IsOptionsOverridable(int options_mask); | 69 static bool IsOptionsOverridable(int options_mask); |
69 | 70 |
70 protected: | 71 protected: |
71 // InterstitialPageDelegate implementation. | 72 // InterstitialPageDelegate implementation. |
72 void CommandReceived(const std::string& command) override; | 73 void CommandReceived(const std::string& command) override; |
73 void OverrideEntry(content::NavigationEntry* entry) override; | 74 void OverrideEntry(content::NavigationEntry* entry) override; |
74 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; | 75 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; |
75 void OnProceed() override; | 76 void OnProceed() override; |
76 void OnDontProceed() override; | 77 void OnDontProceed() override; |
77 | 78 |
78 // SecurityInterstitialPage implementation: | 79 // SecurityInterstitialPage implementation: |
79 bool ShouldCreateNewNavigation() const override; | 80 bool ShouldCreateNewNavigation() const override; |
80 void PopulateInterstitialStrings( | 81 void PopulateInterstitialStrings( |
81 base::DictionaryValue* load_time_data) override; | 82 base::DictionaryValue* load_time_data) override; |
82 | 83 |
| 84 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); |
| 85 |
83 private: | 86 private: |
84 void NotifyDenyCertificate(); | 87 void NotifyDenyCertificate(); |
85 void NotifyAllowCertificate(); | 88 void NotifyAllowCertificate(); |
86 | 89 |
87 std::string GetUmaHistogramPrefix() const; | 90 std::string GetUmaHistogramPrefix() const; |
88 std::string GetSamplingEventName() const; | 91 std::string GetSamplingEventName() const; |
89 | 92 |
| 93 // Send a report about an invalid certificate to the server. Takes |
| 94 // care of calling certificate_report_callback_for_testing_. |
| 95 void FinishCertCollection(); |
| 96 |
90 base::Callback<void(bool)> callback_; | 97 base::Callback<void(bool)> callback_; |
91 | 98 |
92 const int cert_error_; | 99 const int cert_error_; |
93 const net::SSLInfo ssl_info_; | 100 const net::SSLInfo ssl_info_; |
94 // There are two ways for the user to override an interstitial: | 101 // There are two ways for the user to override an interstitial: |
95 // | 102 // |
96 // overridable_) By clicking on "Advanced" and then "Proceed". | 103 // overridable_) By clicking on "Advanced" and then "Proceed". |
97 // - This corresponds to "the user can override using the UI". | 104 // - This corresponds to "the user can override using the UI". |
98 // danger_overridable_) By typing the word "danger". | 105 // danger_overridable_) By typing the word "danger". |
99 // - This is an undocumented workaround. | 106 // - This is an undocumented workaround. |
100 // - This can be set to "false" dynamically to prevent the behaviour. | 107 // - This can be set to "false" dynamically to prevent the behaviour. |
101 const bool overridable_; | 108 const bool overridable_; |
102 bool danger_overridable_; | 109 bool danger_overridable_; |
103 // Has the site requested strict enforcement of certificate errors? | 110 // Has the site requested strict enforcement of certificate errors? |
104 const bool strict_enforcement_; | 111 const bool strict_enforcement_; |
105 // Did the user previously allow a bad certificate but the decision has now | 112 // Did the user previously allow a bad certificate but the decision has now |
106 // expired? | 113 // expired? |
107 const bool expired_but_previously_allowed_; | 114 const bool expired_but_previously_allowed_; |
108 scoped_ptr<SSLErrorClassification> ssl_error_classification_; | 115 scoped_ptr<SSLErrorClassification> ssl_error_classification_; |
109 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; | 116 |
110 // The time at which the interstitial was triggered. The interstitial | 117 // The time at which the interstitial was triggered. The interstitial |
111 // calculates all times relative to this. | 118 // calculates all times relative to this. |
112 const base::Time time_triggered_; | 119 const base::Time time_triggered_; |
113 | 120 |
| 121 // For reporting invalid SSL certificates as part of Safe Browsing |
| 122 // Extended Reporting. |
| 123 SafeBrowsingUIManager* safe_browsing_ui_manager_; |
| 124 |
114 // Which type of interstitial this is. | 125 // Which type of interstitial this is. |
115 enum SSLInterstitialReason { | 126 enum SSLInterstitialReason { |
116 SSL_REASON_SSL, | 127 SSL_REASON_SSL, |
117 SSL_REASON_BAD_CLOCK | 128 SSL_REASON_BAD_CLOCK |
118 } interstitial_reason_; | 129 } interstitial_reason_; |
119 | 130 |
120 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage); | 131 DISALLOW_COPY_AND_ASSIGN(SSLBlockingPage); |
121 }; | 132 }; |
122 | 133 |
123 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_ | 134 #endif // CHROME_BROWSER_SSL_SSL_BLOCKING_PAGE_H_ |
OLD | NEW |