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

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

Issue 1317593002: Have SSLErrorHandler decide which type of interstitial to display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests 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/build_time.h"
10 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
11 #include "base/command_line.h"
12 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
13 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
14 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
15 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
16 #include "base/process/launch.h"
17 #include "base/rand_util.h" 14 #include "base/rand_util.h"
18 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
20 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
23 #include "base/time/time.h" 20 #include "base/time/time.h"
24 #include "base/values.h" 21 #include "base/values.h"
25 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
(...skipping 22 matching lines...) Expand all
49 #include "content/public/browser/render_view_host.h" 46 #include "content/public/browser/render_view_host.h"
50 #include "content/public/browser/web_contents.h" 47 #include "content/public/browser/web_contents.h"
51 #include "content/public/common/renderer_preferences.h" 48 #include "content/public/common/renderer_preferences.h"
52 #include "content/public/common/ssl_status.h" 49 #include "content/public/common/ssl_status.h"
53 #include "grit/browser_resources.h" 50 #include "grit/browser_resources.h"
54 #include "net/base/hash_value.h" 51 #include "net/base/hash_value.h"
55 #include "net/base/net_errors.h" 52 #include "net/base/net_errors.h"
56 #include "net/base/net_util.h" 53 #include "net/base/net_util.h"
57 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
58 55
59 #if defined(OS_WIN)
60 #include "base/base_paths_win.h"
61 #include "base/path_service.h"
62 #include "base/strings/string16.h"
63 #include "base/win/windows_version.h"
64 #endif
65
66 #if defined(OS_ANDROID)
67 #include "chrome/browser/android/intent_helper.h"
68 #endif
69
70 #if defined(OS_CHROMEOS)
71 #include "chrome/browser/profiles/profile_manager.h"
72 #include "chrome/browser/ui/chrome_pages.h"
73 #include "chrome/common/url_constants.h"
74 #endif
75
76 using base::ASCIIToUTF16; 56 using base::ASCIIToUTF16;
77 using base::TimeTicks; 57 using base::TimeTicks;
78 using content::InterstitialPage; 58 using content::InterstitialPage;
79 using content::InterstitialPageDelegate; 59 using content::InterstitialPageDelegate;
80 using content::NavigationController; 60 using content::NavigationController;
81 using content::NavigationEntry; 61 using content::NavigationEntry;
82 62
83 namespace { 63 namespace {
84 64
85 // URL for help page. 65 // URL for help page.
86 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; 66 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607";
87 67
88 // Constants for the Experience Sampling instrumentation. 68 // Constants for the Experience Sampling instrumentation.
89 const char kEventNameBase[] = "ssl_interstitial_"; 69 const char kEventNameBase[] = "ssl_interstitial_";
90 const char kEventNotOverridable[] = "notoverridable_"; 70 const char kEventNotOverridable[] = "notoverridable_";
91 const char kEventOverridable[] = "overridable_"; 71 const char kEventOverridable[] = "overridable_";
92 72
93 // Events for UMA. Do not reorder or change! 73 // Events for UMA. Do not reorder or change!
94 enum SSLExpirationAndDecision { 74 enum SSLExpirationAndDecision {
95 EXPIRED_AND_PROCEED, 75 EXPIRED_AND_PROCEED,
96 EXPIRED_AND_DO_NOT_PROCEED, 76 EXPIRED_AND_DO_NOT_PROCEED,
97 NOT_EXPIRED_AND_PROCEED, 77 NOT_EXPIRED_AND_PROCEED,
98 NOT_EXPIRED_AND_DO_NOT_PROCEED, 78 NOT_EXPIRED_AND_DO_NOT_PROCEED,
99 END_OF_SSL_EXPIRATION_AND_DECISION, 79 END_OF_SSL_EXPIRATION_AND_DECISION,
100 }; 80 };
101 81
102 // Rappor prefix 82 // Rappor prefix, which is intentionally the same regardless of whether the
83 // warning is overridable.
103 const char kSSLRapporPrefix[] = "ssl2"; 84 const char kSSLRapporPrefix[] = "ssl2";
104 85
105 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, 86 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed,
106 bool proceed, 87 bool proceed,
107 bool overridable) { 88 bool overridable) {
108 SSLExpirationAndDecision event; 89 SSLExpirationAndDecision event;
109 if (expired_but_previously_allowed && proceed) 90 if (expired_but_previously_allowed && proceed)
110 event = EXPIRED_AND_PROCEED; 91 event = EXPIRED_AND_PROCEED;
111 else if (expired_but_previously_allowed && !proceed) 92 else if (expired_but_previously_allowed && !proceed)
112 event = EXPIRED_AND_DO_NOT_PROCEED; 93 event = EXPIRED_AND_DO_NOT_PROCEED;
113 else if (!expired_but_previously_allowed && proceed) 94 else if (!expired_but_previously_allowed && proceed)
114 event = NOT_EXPIRED_AND_PROCEED; 95 event = NOT_EXPIRED_AND_PROCEED;
115 else 96 else
116 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; 97 event = NOT_EXPIRED_AND_DO_NOT_PROCEED;
117 98
118 if (overridable) { 99 if (overridable) {
119 UMA_HISTOGRAM_ENUMERATION( 100 UMA_HISTOGRAM_ENUMERATION(
120 "interstitial.ssl.expiration_and_decision.overridable", 101 "interstitial.ssl.expiration_and_decision.overridable",
121 event, 102 event,
122 END_OF_SSL_EXPIRATION_AND_DECISION); 103 END_OF_SSL_EXPIRATION_AND_DECISION);
123 } else { 104 } else {
124 UMA_HISTOGRAM_ENUMERATION( 105 UMA_HISTOGRAM_ENUMERATION(
125 "interstitial.ssl.expiration_and_decision.nonoverridable", 106 "interstitial.ssl.expiration_and_decision.nonoverridable",
126 event, 107 event,
127 END_OF_SSL_EXPIRATION_AND_DECISION); 108 END_OF_SSL_EXPIRATION_AND_DECISION);
128 } 109 }
129 } 110 }
130 111
131 void LaunchDateAndTimeSettings() {
132 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
133 // The code for each OS is completely separate, in order to avoid bugs like
134 // https://crbug.com/430877 .
135 #if defined(OS_ANDROID)
136 chrome::android::OpenDateAndTimeSettings();
137
138 #elif defined(OS_CHROMEOS)
139 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
140 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
141 chrome::ShowSettingsSubPageForProfile(
142 ProfileManager::GetActiveUserProfile(), sub_page);
143
144 #elif defined(OS_IOS)
145 // iOS does not have a way to launch the date and time settings.
146 NOTREACHED();
147
148 #elif defined(OS_LINUX)
149 struct ClockCommand {
150 const char* pathname;
151 const char* argument;
152 };
153 static const ClockCommand kClockCommands[] = {
154 // Unity
155 { "/usr/bin/unity-control-center", "datetime" },
156 // GNOME
157 //
158 // NOTE: On old Ubuntu, naming control panels doesn't work, so it
159 // opens the overview. This will have to be good enough.
160 { "/usr/bin/gnome-control-center", "datetime" },
161 { "/usr/local/bin/gnome-control-center", "datetime" },
162 { "/opt/bin/gnome-control-center", "datetime" },
163 // KDE
164 { "/usr/bin/kcmshell4", "clock" },
165 { "/usr/local/bin/kcmshell4", "clock" },
166 { "/opt/bin/kcmshell4", "clock" },
167 };
168
169 base::CommandLine command(base::FilePath(""));
170 for (size_t i = 0; i < arraysize(kClockCommands); ++i) {
171 base::FilePath pathname(kClockCommands[i].pathname);
172 if (base::PathExists(pathname)) {
173 command.SetProgram(pathname);
174 command.AppendArg(kClockCommands[i].argument);
175 break;
176 }
177 }
178 if (command.GetProgram().empty()) {
179 // Alas, there is nothing we can do.
180 return;
181 }
182
183 base::LaunchOptions options;
184 options.wait = false;
185 options.allow_new_privs = true;
186 base::LaunchProcess(command, options);
187
188 #elif defined(OS_MACOSX)
189 base::CommandLine command(base::FilePath("/usr/bin/open"));
190 command.AppendArg("/System/Library/PreferencePanes/DateAndTime.prefPane");
191
192 base::LaunchOptions options;
193 options.wait = false;
194 base::LaunchProcess(command, options);
195
196 #elif defined(OS_WIN)
197 base::FilePath path;
198 PathService::Get(base::DIR_SYSTEM, &path);
199 static const base::char16 kControlPanelExe[] = L"control.exe";
200 path = path.Append(base::string16(kControlPanelExe));
201 base::CommandLine command(path);
202 command.AppendArg(std::string("/name"));
203 command.AppendArg(std::string("Microsoft.DateAndTime"));
204
205 base::LaunchOptions options;
206 options.wait = false;
207 base::LaunchProcess(command, options);
208
209 #else
210 NOTREACHED();
211
212 #endif
213 // Don't add code here! (See the comment at the beginning of the function.)
214 }
215
216 bool IsErrorDueToBadClock(const base::Time& now, int error) {
217 if (SSLErrorInfo::NetErrorToErrorType(error) !=
218 SSLErrorInfo::CERT_DATE_INVALID) {
219 return false;
220 }
221 return SSLErrorClassification::IsUserClockInThePast(now) ||
222 SSLErrorClassification::IsUserClockInTheFuture(now);
223 }
224
225 } // namespace 112 } // namespace
226 113
227 // static 114 // static
228 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting = 115 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting =
229 &SSLBlockingPage::kTypeForTesting; 116 &SSLBlockingPage::kTypeForTesting;
230 117
231 // Note that we always create a navigation entry with SSL errors. 118 // Note that we always create a navigation entry with SSL errors.
232 // No error happening loading a sub-resource triggers an interstitial so far. 119 // No error happening loading a sub-resource triggers an interstitial so far.
233 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, 120 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents,
234 int cert_error, 121 int cert_error,
235 const net::SSLInfo& ssl_info, 122 const net::SSLInfo& ssl_info,
236 const GURL& request_url, 123 const GURL& request_url,
237 int options_mask, 124 int options_mask,
238 const base::Time& time_triggered, 125 const base::Time& time_triggered,
239 scoped_ptr<SSLCertReporter> ssl_cert_reporter, 126 scoped_ptr<SSLCertReporter> ssl_cert_reporter,
240 const base::Callback<void(bool)>& callback) 127 const base::Callback<void(bool)>& callback)
241 : SecurityInterstitialPage(web_contents, request_url), 128 : SecurityInterstitialPage(web_contents, request_url),
242 callback_(callback), 129 callback_(callback),
243 cert_error_(cert_error), 130 cert_error_(cert_error),
244 ssl_info_(ssl_info), 131 ssl_info_(ssl_info),
245 overridable_(IsOverridable( 132 overridable_(IsOverridable(
246 options_mask, 133 options_mask,
247 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), 134 Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
248 danger_overridable_(DoesPolicyAllowDangerOverride( 135 danger_overridable_(DoesPolicyAllowDangerOverride(
249 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), 136 Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
250 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), 137 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0),
251 expired_but_previously_allowed_( 138 expired_but_previously_allowed_(
252 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), 139 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0),
253 time_triggered_(time_triggered) { 140 time_triggered_(time_triggered) {
254 interstitial_reason_ =
255 IsErrorDueToBadClock(time_triggered_, cert_error_) ?
256 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL;
257
258 // We collapse the Rappor metric name to just "ssl" so we don't leak
estark 2015/09/01 13:28:28 I found the comment on line 82 a little confusing,
felt 2015/09/01 15:49:41 Done.
259 // the "overridable" bit. We skip Rappor altogether for bad clocks.
260 // This must be done after calculating |interstitial_reason_| above.
261 security_interstitials::MetricsHelper::ReportDetails reporting_info; 141 security_interstitials::MetricsHelper::ReportDetails reporting_info;
262 reporting_info.metric_prefix = GetUmaHistogramPrefix(); 142 reporting_info.metric_prefix = GetUmaHistogramPrefix();
263 reporting_info.rappor_prefix = kSSLRapporPrefix; 143 reporting_info.rappor_prefix = kSSLRapporPrefix;
264 if (interstitial_reason_ != SSL_REASON_BAD_CLOCK) 144 reporting_info.rappor_report_type = rappor::UMA_RAPPOR_TYPE;
265 reporting_info.rappor_report_type = rappor::UMA_RAPPOR_TYPE;
266 set_metrics_helper(new ChromeMetricsHelper( 145 set_metrics_helper(new ChromeMetricsHelper(
267 web_contents, request_url, reporting_info, GetSamplingEventName())); 146 web_contents, request_url, reporting_info, GetSamplingEventName()));
268 metrics_helper()->RecordUserDecision( 147 metrics_helper()->RecordUserDecision(
269 security_interstitials::MetricsHelper::SHOW); 148 security_interstitials::MetricsHelper::SHOW);
270 metrics_helper()->RecordUserInteraction( 149 metrics_helper()->RecordUserInteraction(
271 security_interstitials::MetricsHelper::TOTAL_VISITS); 150 security_interstitials::MetricsHelper::TOTAL_VISITS);
272 151
273 cert_report_helper_.reset(new CertReportHelper( 152 cert_report_helper_.reset(new CertReportHelper(
274 ssl_cert_reporter.Pass(), web_contents, request_url, ssl_info, 153 ssl_cert_reporter.Pass(), web_contents, request_url, ssl_info,
275 GetCertReportInterstitialReason(), overridable_, metrics_helper())); 154 GetCertReportInterstitialReason(), overridable_, metrics_helper()));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 NotifyDenyCertificate(); 189 NotifyDenyCertificate();
311 } 190 }
312 } 191 }
313 192
314 void SSLBlockingPage::PopulateInterstitialStrings( 193 void SSLBlockingPage::PopulateInterstitialStrings(
315 base::DictionaryValue* load_time_data) { 194 base::DictionaryValue* load_time_data) {
316 CHECK(load_time_data); 195 CHECK(load_time_data);
317 base::string16 url(GetFormattedHostName()); 196 base::string16 url(GetFormattedHostName());
318 // Shared values for both the overridable and non-overridable versions. 197 // Shared values for both the overridable and non-overridable versions.
319 load_time_data->SetString("type", "SSL"); 198 load_time_data->SetString("type", "SSL");
199 load_time_data->SetBoolean("bad_clock", false);
320 200
321 // Shared UI configuration for all SSL interstitials. 201 // Shared UI configuration for all SSL interstitials.
322 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_)); 202 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_));
323 load_time_data->SetString( 203 load_time_data->SetString(
324 "openDetails", 204 "openDetails",
325 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); 205 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON));
326 load_time_data->SetString( 206 load_time_data->SetString(
327 "closeDetails", 207 "closeDetails",
328 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); 208 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON));
329 209
330 // Conditional UI configuration. 210 load_time_data->SetString("tabTitle",
331 if (interstitial_reason_ == SSL_REASON_BAD_CLOCK) { 211 l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
332 load_time_data->SetBoolean("bad_clock", true); 212 load_time_data->SetString("heading",
213 l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
214 load_time_data->SetString(
215 "primaryParagraph",
216 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url));
217
218 if (overridable_) {
219 load_time_data->SetBoolean("overridable", true);
220
221 SSLErrorInfo error_info = SSLErrorInfo::CreateError(
222 SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert.get(),
223 request_url());
224 load_time_data->SetString("explanationParagraph", error_info.details());
225 load_time_data->SetString(
226 "primaryButtonText",
227 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON));
228 load_time_data->SetString(
229 "finalParagraph",
230 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url));
231 } else {
333 load_time_data->SetBoolean("overridable", false); 232 load_time_data->SetBoolean("overridable", false);
334 233
335 #if defined(OS_IOS) 234 SSLErrorInfo::ErrorType type =
336 load_time_data->SetBoolean("hide_primary_button", true); 235 SSLErrorInfo::NetErrorToErrorType(cert_error_);
337 #else 236 if (type == SSLErrorInfo::CERT_INVALID &&
338 load_time_data->SetBoolean("hide_primary_button", false); 237 SSLErrorClassification::MaybeWindowsLacksSHA256Support()) {
339 #endif
340
341 // We're showing the SSL clock warning to be helpful, but we haven't warned
342 // them about the risks. (And there might still be an SSL error after they
343 // fix their clock.) Thus, we don't allow the "danger" override in this
344 // case.
345 danger_overridable_ = false;
346
347 int heading_string =
348 SSLErrorClassification::IsUserClockInTheFuture(time_triggered_) ?
349 IDS_SSL_V2_CLOCK_AHEAD_HEADING :
350 IDS_SSL_V2_CLOCK_BEHIND_HEADING;
351
352 load_time_data->SetString(
353 "tabTitle",
354 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE));
355 load_time_data->SetString(
356 "heading",
357 l10n_util::GetStringUTF16(heading_string));
358 load_time_data->SetString(
359 "primaryParagraph",
360 l10n_util::GetStringFUTF16(
361 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH,
362 url,
363 base::TimeFormatFriendlyDateAndTime(time_triggered_)));
364
365 load_time_data->SetString(
366 "primaryButtonText",
367 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME));
368 load_time_data->SetString(
369 "explanationParagraph",
370 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_EXPLANATION));
371
372 // The interstitial template expects this string, but we're not using it. So
373 // we send a blank string for now.
374 load_time_data->SetString("finalParagraph", std::string());
375 } else {
376 load_time_data->SetBoolean("bad_clock", false);
377
378 load_time_data->SetString(
379 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
380 load_time_data->SetString(
381 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
382 load_time_data->SetString(
383 "primaryParagraph",
384 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url));
385
386 if (overridable_) {
387 load_time_data->SetBoolean("overridable", true);
388
389 SSLErrorInfo error_info =
390 SSLErrorInfo::CreateError(
391 SSLErrorInfo::NetErrorToErrorType(cert_error_),
392 ssl_info_.cert.get(),
393 request_url());
394 load_time_data->SetString("explanationParagraph", error_info.details());
395 load_time_data->SetString( 238 load_time_data->SetString(
396 "primaryButtonText", 239 "explanationParagraph",
397 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); 240 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3,
241 url));
242 } else {
398 load_time_data->SetString( 243 load_time_data->SetString(
399 "finalParagraph", 244 "explanationParagraph",
400 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, 245 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url));
401 url));
402 } else {
403 load_time_data->SetBoolean("overridable", false);
404
405 SSLErrorInfo::ErrorType type =
406 SSLErrorInfo::NetErrorToErrorType(cert_error_);
407 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification::
408 MaybeWindowsLacksSHA256Support()) {
409 load_time_data->SetString(
410 "explanationParagraph",
411 l10n_util::GetStringFUTF16(
412 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url));
413 } else {
414 load_time_data->SetString("explanationParagraph",
415 l10n_util::GetStringFUTF16(
416 IDS_SSL_NONOVERRIDABLE_MORE, url));
417 }
418 load_time_data->SetString(
419 "primaryButtonText",
420 l10n_util::GetStringUTF16(IDS_SSL_RELOAD));
421 // Customize the help link depending on the specific error type.
422 // Only mark as HSTS if none of the more specific error types apply,
423 // and use INVALID as a fallback if no other string is appropriate.
424 load_time_data->SetInteger("errorType", type);
425 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
426 switch (type) {
427 case SSLErrorInfo::CERT_REVOKED:
428 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED;
429 break;
430 case SSLErrorInfo::CERT_PINNED_KEY_MISSING:
431 help_string = IDS_SSL_NONOVERRIDABLE_PINNED;
432 break;
433 case SSLErrorInfo::CERT_INVALID:
434 help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
435 break;
436 default:
437 if (strict_enforcement_)
438 help_string = IDS_SSL_NONOVERRIDABLE_HSTS;
439 }
440 load_time_data->SetString(
441 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url));
442 } 246 }
247 load_time_data->SetString("primaryButtonText",
248 l10n_util::GetStringUTF16(IDS_SSL_RELOAD));
249 // Customize the help link depending on the specific error type.
250 // Only mark as HSTS if none of the more specific error types apply,
251 // and use INVALID as a fallback if no other string is appropriate.
252 load_time_data->SetInteger("errorType", type);
253 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
254 switch (type) {
255 case SSLErrorInfo::CERT_REVOKED:
256 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED;
257 break;
258 case SSLErrorInfo::CERT_PINNED_KEY_MISSING:
259 help_string = IDS_SSL_NONOVERRIDABLE_PINNED;
260 break;
261 case SSLErrorInfo::CERT_INVALID:
262 help_string = IDS_SSL_NONOVERRIDABLE_INVALID;
263 break;
264 default:
265 if (strict_enforcement_)
266 help_string = IDS_SSL_NONOVERRIDABLE_HSTS;
267 }
268 load_time_data->SetString("finalParagraph",
269 l10n_util::GetStringFUTF16(help_string, url));
443 } 270 }
444 271
445 // Set debugging information at the bottom of the warning. 272 // Set debugging information at the bottom of the warning.
446 load_time_data->SetString( 273 load_time_data->SetString(
447 "subject", ssl_info_.cert->subject().GetDisplayName()); 274 "subject", ssl_info_.cert->subject().GetDisplayName());
448 load_time_data->SetString( 275 load_time_data->SetString(
449 "issuer", ssl_info_.cert->issuer().GetDisplayName()); 276 "issuer", ssl_info_.cert->issuer().GetDisplayName());
450 load_time_data->SetString( 277 load_time_data->SetString(
451 "expirationDate", 278 "expirationDate",
452 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); 279 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry()));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 web_contents()->GetController().LoadURLWithParams(help_page_params); 350 web_contents()->GetController().LoadURLWithParams(help_page_params);
524 break; 351 break;
525 } 352 }
526 case CMD_RELOAD: { 353 case CMD_RELOAD: {
527 metrics_helper()->RecordUserInteraction( 354 metrics_helper()->RecordUserInteraction(
528 security_interstitials::MetricsHelper::RELOAD); 355 security_interstitials::MetricsHelper::RELOAD);
529 // The interstitial can't refresh itself. 356 // The interstitial can't refresh itself.
530 web_contents()->GetController().Reload(true); 357 web_contents()->GetController().Reload(true);
531 break; 358 break;
532 } 359 }
533 case CMD_OPEN_DATE_SETTINGS: {
534 metrics_helper()->RecordUserInteraction(
535 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS);
536 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
537 base::Bind(&LaunchDateAndTimeSettings));
538 break;
539 }
540 case CMD_OPEN_REPORTING_PRIVACY: 360 case CMD_OPEN_REPORTING_PRIVACY:
541 OpenExtendedReportingPrivacyPolicy(); 361 OpenExtendedReportingPrivacyPolicy();
542 break; 362 break;
363 case CMD_OPEN_DATE_SETTINGS:
364 // Handled by the bad clock interstitial.
estark 2015/09/01 13:28:28 Is it intentional that this falls through to the N
felt 2015/09/01 15:49:41 Done.
543 case CMD_OPEN_DIAGNOSTIC: 365 case CMD_OPEN_DIAGNOSTIC:
544 // Google doesn't currently have a transparency report for SSL. 366 // Google doesn't currently have a transparency report for SSL.
545 NOTREACHED() << "Unexpected command: " << command; 367 NOTREACHED() << "Unexpected command: " << command;
546 } 368 }
547 } 369 }
548 370
549 void SSLBlockingPage::OverrideRendererPrefs( 371 void SSLBlockingPage::OverrideRendererPrefs(
550 content::RendererPreferences* prefs) { 372 content::RendererPreferences* prefs) {
551 Profile* profile = Profile::FromBrowserContext( 373 Profile* profile = Profile::FromBrowserContext(
552 web_contents()->GetBrowserContext()); 374 web_contents()->GetBrowserContext());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 417 }
596 418
597 void SSLBlockingPage::NotifyAllowCertificate() { 419 void SSLBlockingPage::NotifyAllowCertificate() {
598 DCHECK(!callback_.is_null()); 420 DCHECK(!callback_.is_null());
599 421
600 callback_.Run(true); 422 callback_.Run(true);
601 callback_.Reset(); 423 callback_.Reset();
602 } 424 }
603 425
604 CertificateErrorReport::InterstitialReason 426 CertificateErrorReport::InterstitialReason
605 SSLBlockingPage::GetCertReportInterstitialReason() { 427 SSLBlockingPage::GetCertReportInterstitialReason() {
estark 2015/09/01 13:28:28 You could now just inline this in the one place it
felt 2015/09/01 15:49:41 Done.
606 switch (interstitial_reason_) {
607 case SSL_REASON_SSL:
608 return CertificateErrorReport::INTERSTITIAL_SSL;
609 case SSL_REASON_BAD_CLOCK:
610 return CertificateErrorReport::INTERSTITIAL_CLOCK;
611 }
612
613 NOTREACHED();
614 return CertificateErrorReport::INTERSTITIAL_SSL; 428 return CertificateErrorReport::INTERSTITIAL_SSL;
615 } 429 }
616 430
617 std::string SSLBlockingPage::GetUmaHistogramPrefix() const { 431 std::string SSLBlockingPage::GetUmaHistogramPrefix() const {
618 switch (interstitial_reason_) { 432 if (overridable_)
estark 2015/09/01 13:28:28 nit: `return overridable ? "ssl_overridable" : "ss
felt 2015/09/01 15:49:41 Done.
619 case SSL_REASON_SSL: 433 return "ssl_overridable";
620 if (overridable_) 434 else
621 return "ssl_overridable"; 435 return "ssl_nonoverridable";
622 else
623 return "ssl_nonoverridable";
624 case SSL_REASON_BAD_CLOCK:
625 return "bad_clock";
626 }
627 NOTREACHED();
628 return std::string();
629 } 436 }
630 437
631 std::string SSLBlockingPage::GetSamplingEventName() const { 438 std::string SSLBlockingPage::GetSamplingEventName() const {
632 std::string event_name(kEventNameBase); 439 std::string event_name(kEventNameBase);
633 if (overridable_) 440 if (overridable_)
634 event_name.append(kEventOverridable); 441 event_name.append(kEventOverridable);
635 else 442 else
636 event_name.append(kEventNotOverridable); 443 event_name.append(kEventNotOverridable);
637 event_name.append(net::ErrorToString(cert_error_)); 444 event_name.append(net::ErrorToString(cert_error_));
638 return event_name; 445 return event_name;
639 } 446 }
640 447
641 // static 448 // static
642 bool SSLBlockingPage::IsOverridable(int options_mask, 449 bool SSLBlockingPage::IsOverridable(int options_mask,
643 const Profile* const profile) { 450 const Profile* const profile) {
644 const bool is_overridable = 451 const bool is_overridable =
645 (options_mask & SSLBlockingPage::OVERRIDABLE) && 452 (options_mask & SSLBlockingPage::OVERRIDABLE) &&
646 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && 453 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) &&
647 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); 454 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed);
648 return is_overridable; 455 return is_overridable;
649 } 456 }
650 457
651 // static 458 // static
652 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( 459 bool SSLBlockingPage::DoesPolicyAllowDangerOverride(
653 const Profile* const profile) { 460 const Profile* const profile) {
654 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); 461 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed);
655 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698