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 #include "chrome/browser/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
6 | 6 |
7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/renderer_preferences_util.h" | 24 #include "chrome/browser/renderer_preferences_util.h" |
25 #include "chrome/browser/ssl/ssl_error_classification.h" | 25 #include "chrome/browser/ssl/ssl_error_classification.h" |
26 #include "chrome/browser/ssl/ssl_error_info.h" | 26 #include "chrome/browser/ssl/ssl_error_info.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/grit/chromium_strings.h" | 28 #include "chrome/grit/chromium_strings.h" |
29 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
30 #include "components/google/core/browser/google_util.h" | 30 #include "components/google/core/browser/google_util.h" |
31 #include "content/public/browser/cert_store.h" | 31 #include "content/public/browser/cert_store.h" |
32 #include "content/public/browser/interstitial_page.h" | 32 #include "content/public/browser/interstitial_page.h" |
| 33 #include "content/public/browser/interstitial_page_delegate.h" |
33 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
34 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
38 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
40 #include "content/public/common/renderer_preferences.h" | 41 #include "content/public/common/renderer_preferences.h" |
41 #include "content/public/common/ssl_status.h" | 42 #include "content/public/common/ssl_status.h" |
42 #include "grit/browser_resources.h" | 43 #include "grit/browser_resources.h" |
(...skipping 15 matching lines...) Expand all Loading... |
58 | 59 |
59 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
60 #include "chrome/browser/profiles/profile_manager.h" | 61 #include "chrome/browser/profiles/profile_manager.h" |
61 #include "chrome/browser/ui/chrome_pages.h" | 62 #include "chrome/browser/ui/chrome_pages.h" |
62 #include "chrome/common/url_constants.h" | 63 #include "chrome/common/url_constants.h" |
63 #endif | 64 #endif |
64 | 65 |
65 using base::ASCIIToUTF16; | 66 using base::ASCIIToUTF16; |
66 using base::TimeTicks; | 67 using base::TimeTicks; |
67 using content::InterstitialPage; | 68 using content::InterstitialPage; |
| 69 using content::InterstitialPageDelegate; |
68 using content::NavigationController; | 70 using content::NavigationController; |
69 using content::NavigationEntry; | 71 using content::NavigationEntry; |
70 | 72 |
71 namespace { | 73 namespace { |
72 | 74 |
73 // URL for help page. | 75 // URL for help page. |
74 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; | 76 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; |
75 | 77 |
76 // Constants for the Experience Sampling instrumentation. | 78 // Constants for the Experience Sampling instrumentation. |
77 const char kEventNameBase[] = "ssl_interstitial_"; | 79 const char kEventNameBase[] = "ssl_interstitial_"; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 SSLErrorInfo::CERT_DATE_INVALID) { | 207 SSLErrorInfo::CERT_DATE_INVALID) { |
206 return false; | 208 return false; |
207 } | 209 } |
208 return SSLErrorClassification::IsUserClockInThePast(now) || | 210 return SSLErrorClassification::IsUserClockInThePast(now) || |
209 SSLErrorClassification::IsUserClockInTheFuture(now); | 211 SSLErrorClassification::IsUserClockInTheFuture(now); |
210 } | 212 } |
211 | 213 |
212 } // namespace | 214 } // namespace |
213 | 215 |
214 // static | 216 // static |
215 const void* SSLBlockingPage::kTypeForTesting = | 217 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting = |
216 &SSLBlockingPage::kTypeForTesting; | 218 &SSLBlockingPage::kTypeForTesting; |
217 | 219 |
218 // Note that we always create a navigation entry with SSL errors. | 220 // Note that we always create a navigation entry with SSL errors. |
219 // No error happening loading a sub-resource triggers an interstitial so far. | 221 // No error happening loading a sub-resource triggers an interstitial so far. |
220 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 222 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
221 int cert_error, | 223 int cert_error, |
222 const net::SSLInfo& ssl_info, | 224 const net::SSLInfo& ssl_info, |
223 const GURL& request_url, | 225 const GURL& request_url, |
224 int options_mask, | 226 int options_mask, |
225 const base::Time& time_triggered, | 227 const base::Time& time_triggered, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 ssl_error_classification_->RecordUMAStatistics(overridable_); | 263 ssl_error_classification_->RecordUMAStatistics(overridable_); |
262 | 264 |
263 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 265 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
264 // it leaks memory, so don't create it here. | 266 // it leaks memory, so don't create it here. |
265 } | 267 } |
266 | 268 |
267 bool SSLBlockingPage::ShouldCreateNewNavigation() const { | 269 bool SSLBlockingPage::ShouldCreateNewNavigation() const { |
268 return true; | 270 return true; |
269 } | 271 } |
270 | 272 |
271 const void* SSLBlockingPage::GetTypeForTesting() const { | 273 InterstitialPageDelegate::TypeID SSLBlockingPage::GetTypeForTesting() const { |
272 return SSLBlockingPage::kTypeForTesting; | 274 return SSLBlockingPage::kTypeForTesting; |
273 } | 275 } |
274 | 276 |
275 SSLBlockingPage::~SSLBlockingPage() { | 277 SSLBlockingPage::~SSLBlockingPage() { |
276 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 278 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
277 // Captive portal detection results can arrive anytime during the interstitial | 279 // Captive portal detection results can arrive anytime during the interstitial |
278 // is being displayed, so record it when the interstitial is going away. | 280 // is being displayed, so record it when the interstitial is going away. |
279 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); | 281 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); |
280 #endif | 282 #endif |
281 if (!callback_.is_null()) { | 283 if (!callback_.is_null()) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 event_name.append(kEventNotOverridable); | 567 event_name.append(kEventNotOverridable); |
566 event_name.append(net::ErrorToString(cert_error_)); | 568 event_name.append(net::ErrorToString(cert_error_)); |
567 return event_name; | 569 return event_name; |
568 } | 570 } |
569 | 571 |
570 // static | 572 // static |
571 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { | 573 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { |
572 return (options_mask & SSLBlockingPage::OVERRIDABLE) && | 574 return (options_mask & SSLBlockingPage::OVERRIDABLE) && |
573 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); | 575 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); |
574 } | 576 } |
OLD | NEW |