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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 // Note that we always create a navigation entry with SSL errors. | 231 // Note that we always create a navigation entry with SSL errors. |
232 // No error happening loading a sub-resource triggers an interstitial so far. | 232 // No error happening loading a sub-resource triggers an interstitial so far. |
233 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 233 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
234 int cert_error, | 234 int cert_error, |
235 const net::SSLInfo& ssl_info, | 235 const net::SSLInfo& ssl_info, |
236 const GURL& request_url, | 236 const GURL& request_url, |
237 int options_mask, | 237 int options_mask, |
238 const base::Time& time_triggered, | 238 const base::Time& time_triggered, |
239 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 239 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
240 const base::Callback<void(bool)>& callback) | 240 const base::Callback<void(bool)>& callback, |
| 241 const GURL& suggested_url) |
241 : SecurityInterstitialPage(web_contents, request_url), | 242 : SecurityInterstitialPage(web_contents, request_url), |
242 callback_(callback), | 243 callback_(callback), |
243 cert_error_(cert_error), | 244 cert_error_(cert_error), |
244 ssl_info_(ssl_info), | 245 ssl_info_(ssl_info), |
245 overridable_(IsOverridable( | 246 overridable_(IsOverridable( |
246 options_mask, | 247 options_mask, |
247 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 248 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
248 danger_overridable_(DoesPolicyAllowDangerOverride( | 249 danger_overridable_(DoesPolicyAllowDangerOverride( |
249 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 250 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
250 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 251 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
251 expired_but_previously_allowed_( | 252 expired_but_previously_allowed_( |
252 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), | 253 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), |
253 time_triggered_(time_triggered) { | 254 time_triggered_(time_triggered), |
| 255 suggested_url_(suggested_url) { |
254 interstitial_reason_ = | 256 interstitial_reason_ = |
255 IsErrorDueToBadClock(time_triggered_, cert_error_) ? | 257 IsErrorDueToBadClock(time_triggered_, cert_error_) ? |
256 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; | 258 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; |
257 | 259 |
258 // We collapse the Rappor metric name to just "ssl" so we don't leak | 260 // We collapse the Rappor metric name to just "ssl" so we don't leak |
259 // the "overridable" bit. We skip Rappor altogether for bad clocks. | 261 // the "overridable" bit. We skip Rappor altogether for bad clocks. |
260 // This must be done after calculating |interstitial_reason_| above. | 262 // This must be done after calculating |interstitial_reason_| above. |
261 set_metrics_helper(new SecurityInterstitialMetricsHelper( | 263 set_metrics_helper(new SecurityInterstitialMetricsHelper( |
262 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix, | 264 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix, |
263 (interstitial_reason_ == SSL_REASON_BAD_CLOCK | 265 (interstitial_reason_ == SSL_REASON_BAD_CLOCK |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 385 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
384 | 386 |
385 if (overridable_) { | 387 if (overridable_) { |
386 load_time_data->SetBoolean("overridable", true); | 388 load_time_data->SetBoolean("overridable", true); |
387 | 389 |
388 SSLErrorInfo error_info = | 390 SSLErrorInfo error_info = |
389 SSLErrorInfo::CreateError( | 391 SSLErrorInfo::CreateError( |
390 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 392 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
391 ssl_info_.cert.get(), | 393 ssl_info_.cert.get(), |
392 request_url()); | 394 request_url()); |
| 395 |
| 396 // If suggested url is not empty, display a modified message |
| 397 // with a link to suggested_url. |
| 398 if (!suggested_url_.is_empty()) { |
| 399 load_time_data->SetString( |
| 400 "primaryParagraph", |
| 401 l10n_util::GetStringFUTF16( |
| 402 IDS_SSL_COMMON_NAME_MISMATCH_PRIMARY_PARAGRAPH, |
| 403 base::UTF8ToUTF16(request_url().host()), |
| 404 base::UTF8ToUTF16(suggested_url_.host()), |
| 405 base::UTF8ToUTF16(suggested_url_.spec()))); |
| 406 } |
| 407 |
393 load_time_data->SetString("explanationParagraph", error_info.details()); | 408 load_time_data->SetString("explanationParagraph", error_info.details()); |
394 load_time_data->SetString( | 409 load_time_data->SetString( |
395 "primaryButtonText", | 410 "primaryButtonText", |
396 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 411 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
397 load_time_data->SetString( | 412 load_time_data->SetString( |
398 "finalParagraph", | 413 "finalParagraph", |
399 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | 414 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
400 url)); | 415 url)); |
401 } else { | 416 } else { |
402 load_time_data->SetBoolean("overridable", false); | 417 load_time_data->SetBoolean("overridable", false); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && | 660 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && |
646 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 661 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
647 return is_overridable; | 662 return is_overridable; |
648 } | 663 } |
649 | 664 |
650 // static | 665 // static |
651 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( | 666 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( |
652 const Profile* const profile) { | 667 const Profile* const profile) { |
653 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 668 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
654 } | 669 } |
OLD | NEW |