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

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

Issue 1341923002: Create a component for SSL error handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update iOS grit whitelist Created 5 years, 3 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 #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/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/interstitials/chrome_metrics_helper.h" 24 #include "chrome/browser/interstitials/chrome_metrics_helper.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/renderer_preferences_util.h" 26 #include "chrome/browser/renderer_preferences_util.h"
27 #include "chrome/browser/ssl/cert_report_helper.h" 27 #include "chrome/browser/ssl/cert_report_helper.h"
28 #include "chrome/browser/ssl/ssl_cert_reporter.h" 28 #include "chrome/browser/ssl/ssl_cert_reporter.h"
29 #include "chrome/browser/ssl/ssl_error_classification.h" 29 #include "chrome/browser/ssl/ssl_error_classification.h"
30 #include "chrome/browser/ssl/ssl_error_info.h"
31 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
33 #include "chrome/grit/chromium_strings.h" 32 #include "chrome/grit/chromium_strings.h"
34 #include "chrome/grit/generated_resources.h" 33 #include "chrome/grit/generated_resources.h"
35 #include "components/google/core/browser/google_util.h" 34 #include "components/google/core/browser/google_util.h"
35 #include "components/ssl_errors/error_info.h"
36 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/cert_store.h" 37 #include "content/public/browser/cert_store.h"
38 #include "content/public/browser/interstitial_page.h" 38 #include "content/public/browser/interstitial_page.h"
39 #include "content/public/browser/interstitial_page_delegate.h" 39 #include "content/public/browser/interstitial_page_delegate.h"
40 #include "content/public/browser/navigation_controller.h" 40 #include "content/public/browser/navigation_controller.h"
41 #include "content/public/browser/navigation_entry.h" 41 #include "content/public/browser/navigation_entry.h"
42 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/notification_types.h" 43 #include "content/public/browser/notification_types.h"
44 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
45 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); 213 l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
214 load_time_data->SetString("heading", 214 load_time_data->SetString("heading",
215 l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); 215 l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
216 load_time_data->SetString( 216 load_time_data->SetString(
217 "primaryParagraph", 217 "primaryParagraph",
218 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); 218 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url));
219 219
220 if (overridable_) { 220 if (overridable_) {
221 load_time_data->SetBoolean("overridable", true); 221 load_time_data->SetBoolean("overridable", true);
222 222
223 SSLErrorInfo error_info = SSLErrorInfo::CreateError( 223 ssl_errors::ErrorInfo error_info = ssl_errors::ErrorInfo::CreateError(
224 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert.get(), 224 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_),
225 request_url()); 225 ssl_info_.cert.get(), request_url());
226 load_time_data->SetString("explanationParagraph", error_info.details()); 226 load_time_data->SetString("explanationParagraph", error_info.details());
227 load_time_data->SetString( 227 load_time_data->SetString(
228 "primaryButtonText", 228 "primaryButtonText",
229 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); 229 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON));
230 load_time_data->SetString( 230 load_time_data->SetString(
231 "finalParagraph", 231 "finalParagraph",
232 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); 232 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url));
233 } else { 233 } else {
234 load_time_data->SetBoolean("overridable", false); 234 load_time_data->SetBoolean("overridable", false);
235 235
236 SSLErrorInfo::ErrorType type = 236 ssl_errors::ErrorInfo::ErrorType type =
237 SSLErrorInfo::NetErrorToErrorType(cert_error_); 237 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_);
238 if (type == SSLErrorInfo::CERT_INVALID && 238 if (type == ssl_errors::ErrorInfo::CERT_INVALID &&
239 SSLErrorClassification::MaybeWindowsLacksSHA256Support()) { 239 SSLErrorClassification::MaybeWindowsLacksSHA256Support()) {
240 load_time_data->SetString( 240 load_time_data->SetString(
241 "explanationParagraph", 241 "explanationParagraph",
242 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, 242 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3,
243 url)); 243 url));
244 } else { 244 } else {
245 load_time_data->SetString( 245 load_time_data->SetString(
246 "explanationParagraph", 246 "explanationParagraph",
247 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url)); 247 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url));
248 } 248 }
249 load_time_data->SetString("primaryButtonText", 249 load_time_data->SetString("primaryButtonText",
250 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); 250 l10n_util::GetStringUTF16(IDS_SSL_RELOAD));
251 // Customize the help link depending on the specific error type. 251 // Customize the help link depending on the specific error type.
252 // Only mark as HSTS if none of the more specific error types apply, 252 // Only mark as HSTS if none of the more specific error types apply,
253 // and use INVALID as a fallback if no other string is appropriate. 253 // and use INVALID as a fallback if no other string is appropriate.
254 load_time_data->SetInteger("errorType", type); 254 load_time_data->SetInteger("errorType", type);
255 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; 255 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
256 switch (type) { 256 switch (type) {
257 case SSLErrorInfo::CERT_REVOKED: 257 case ssl_errors::ErrorInfo::CERT_REVOKED:
258 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; 258 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED;
259 break; 259 break;
260 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: 260 case ssl_errors::ErrorInfo::CERT_PINNED_KEY_MISSING:
261 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; 261 help_string = IDS_SSL_NONOVERRIDABLE_PINNED;
262 break; 262 break;
263 case SSLErrorInfo::CERT_INVALID: 263 case ssl_errors::ErrorInfo::CERT_INVALID:
264 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; 264 help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
265 break; 265 break;
266 default: 266 default:
267 if (strict_enforcement_) 267 if (strict_enforcement_)
268 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; 268 help_string = IDS_SSL_NONOVERRIDABLE_HSTS;
269 } 269 }
270 load_time_data->SetString("finalParagraph", 270 load_time_data->SetString("finalParagraph",
271 l10n_util::GetStringFUTF16(help_string, url)); 271 l10n_util::GetStringFUTF16(help_string, url));
272 } 272 }
273 273
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && 455 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) &&
456 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); 456 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed);
457 return is_overridable; 457 return is_overridable;
458 } 458 }
459 459
460 // static 460 // static
461 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( 461 bool SSLBlockingPage::DoesPolicyAllowDangerOverride(
462 const Profile* const profile) { 462 const Profile* const profile) {
463 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); 463 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed);
464 } 464 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/bad_clock_blocking_page.cc ('k') | chrome/browser/ssl/ssl_error_classification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698