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

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

Issue 341653006: Add experimental versions of the SSL interstitial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changes for dbeam Created 6 years, 6 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 | Annotate | Revision Log
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #endif 50 #endif
51 51
52 using base::ASCIIToUTF16; 52 using base::ASCIIToUTF16;
53 using base::TimeTicks; 53 using base::TimeTicks;
54 using content::InterstitialPage; 54 using content::InterstitialPage;
55 using content::NavigationController; 55 using content::NavigationController;
56 using content::NavigationEntry; 56 using content::NavigationEntry;
57 57
58 namespace { 58 namespace {
59 59
60 // Constants for the M37 Finch trial.
61 const char kInterstitialTrialName[] = "SSLInterstitialVersion";
62 const char kCondV1[] = "V1";
63 const char kCondV1LayoutV2Text[] = "V1LayoutV2Text";
64 const char kCondV2[] = "V2"; // Also the default.
65 const char kCondV2Guard[] = "V2WithGuard";
66 const char kCondV2Yellow[] = "V2Yellow";
67
68 const char* GetTrialCondition() {
69 CommandLine* cli = CommandLine::ForCurrentProcess();
70 std::string name(base::FieldTrialList::FindFullName(kInterstitialTrialName));
Dan Beam 2014/06/21 00:42:52 nit: declare |name| right before it's needed
felt 2014/06/21 00:56:32 Done.
71 if (cli->HasSwitch(switches::kSSLInterstitialV1))
72 return kCondV1;
73 if (cli->HasSwitch(switches::kSSLInterstitialV2))
74 return kCondV2;
75 if (cli->HasSwitch(switches::kSSLInterstitialV1WithV2Text))
76 return kCondV1LayoutV2Text;
77 if (cli->HasSwitch(switches::kSSLInterstitialV2Guard))
78 return kCondV2Guard;
79 if (cli->HasSwitch(switches::kSSLInterstitialV2Yellow))
80 return kCondV2Yellow;
81
82 if (name == kCondV1)
83 return kCondV1;
84 if (name == kCondV2)
85 return kCondV2;
86 if (name == kCondV1LayoutV2Text)
87 return kCondV1LayoutV2Text;
88 if (name == kCondV2Guard)
89 return kCondV2Guard;
90 if (name == kCondV2Yellow)
91 return kCondV2Yellow;
92 return kCondV2;
93 }
94
60 // Events for UMA. Do not reorder or change! 95 // Events for UMA. Do not reorder or change!
61 enum SSLBlockingPageEvent { 96 enum SSLBlockingPageEvent {
62 SHOW_ALL, 97 SHOW_ALL,
63 SHOW_OVERRIDABLE, 98 SHOW_OVERRIDABLE,
64 PROCEED_OVERRIDABLE, 99 PROCEED_OVERRIDABLE,
65 PROCEED_NAME, 100 PROCEED_NAME,
66 PROCEED_DATE, 101 PROCEED_DATE,
67 PROCEED_AUTHORITY, 102 PROCEED_AUTHORITY,
68 DONT_PROCEED_OVERRIDABLE, 103 DONT_PROCEED_OVERRIDABLE,
69 DONT_PROCEED_NAME, 104 DONT_PROCEED_NAME,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 cert_error_(cert_error), 228 cert_error_(cert_error),
194 ssl_info_(ssl_info), 229 ssl_info_(ssl_info),
195 request_url_(request_url), 230 request_url_(request_url),
196 overridable_(overridable), 231 overridable_(overridable),
197 strict_enforcement_(strict_enforcement), 232 strict_enforcement_(strict_enforcement),
198 internal_(false), 233 internal_(false),
199 num_visits_(-1), 234 num_visits_(-1),
200 captive_portal_detection_enabled_(false), 235 captive_portal_detection_enabled_(false),
201 captive_portal_probe_completed_(false), 236 captive_portal_probe_completed_(false),
202 captive_portal_no_response_(false), 237 captive_portal_no_response_(false),
203 captive_portal_detected_(false) { 238 captive_portal_detected_(false),
239 trial_condition_(GetTrialCondition()) {
204 Profile* profile = Profile::FromBrowserContext( 240 Profile* profile = Profile::FromBrowserContext(
205 web_contents->GetBrowserContext()); 241 web_contents->GetBrowserContext());
206 // For UMA stats. 242 // For UMA stats.
207 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) 243 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets()))
208 internal_ = true; 244 internal_ = true;
209 RecordSSLBlockingPageEventStats(SHOW_ALL); 245 RecordSSLBlockingPageEventStats(SHOW_ALL);
210 if (overridable_ && !strict_enforcement_) { 246 if (overridable_ && !strict_enforcement_) {
211 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); 247 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE);
212 if (internal_) 248 if (internal_)
213 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); 249 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 captive_portal_probe_completed_, 284 captive_portal_probe_completed_,
249 captive_portal_no_response_, 285 captive_portal_no_response_,
250 captive_portal_detected_); 286 captive_portal_detected_);
251 // The page is closed without the user having chosen what to do, default to 287 // The page is closed without the user having chosen what to do, default to
252 // deny. 288 // deny.
253 NotifyDenyCertificate(); 289 NotifyDenyCertificate();
254 } 290 }
255 } 291 }
256 292
257 std::string SSLBlockingPage::GetHTMLContents() { 293 std::string SSLBlockingPage::GetHTMLContents() {
258 if (CommandLine::ForCurrentProcess()->HasSwitch( 294 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text)
259 switches::kSSLInterstitialVersionV1) ||
260 base::FieldTrialList::FindFullName("SSLInterstitialVersion") == "V1") {
261 return GetHTMLContentsV1(); 295 return GetHTMLContentsV1();
262 }
263 return GetHTMLContentsV2(); 296 return GetHTMLContentsV2();
264 } 297 }
265 298
266 std::string SSLBlockingPage::GetHTMLContentsV1() { 299 std::string SSLBlockingPage::GetHTMLContentsV1() {
267 base::DictionaryValue strings; 300 base::DictionaryValue strings;
268 int resource_id; 301 int resource_id;
269 if (overridable_ && !strict_enforcement_) { 302 if (overridable_ && !strict_enforcement_) {
270 // Let's build the overridable error page. 303 // Let's build the overridable error page.
271 SSLErrorInfo error_info = 304 SSLErrorInfo error_info =
272 SSLErrorInfo::CreateError( 305 SSLErrorInfo::CreateError(
273 SSLErrorInfo::NetErrorToErrorType(cert_error_), 306 SSLErrorInfo::NetErrorToErrorType(cert_error_),
274 ssl_info_.cert.get(), 307 ssl_info_.cert.get(),
275 request_url_); 308 request_url_);
309 resource_id = IDR_SSL_ROAD_BLOCK_HTML;
310 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
311 strings.SetString("errorType", "overridable");
312 if (trial_condition_ == kCondV1LayoutV2Text) {
313 base::string16 url(ASCIIToUTF16(request_url_.host()));
314 strings.SetString(
315 "headLine", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
316 strings.SetString(
317 "description",
318 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url));
319 strings.SetString(
320 "moreInfoTitle",
321 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON));
322 strings.SetString("moreInfo1", error_info.details());
323 strings.SetString("moreInfo2", std::string16());
324 strings.SetString("moreInfo3", std::string16());
325 strings.SetString("moreInfo4", std::string16());
326 strings.SetString("moreInfo5", std::string16());
Dan Beam 2014/06/21 00:42:52 dare you to compile this ;)
felt 2014/06/21 00:56:32 http://goo.gl/xR1Dky
327 strings.SetString(
328 "exit",
329 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON));
330 strings.SetString(
331 "title", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
332 strings.SetString(
333 "proceed",
334 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PROCEED_LINK_TEXT));
335 strings.SetString("reasonForNotProceeding", std::string16());
336 } else {
337 strings.SetString("headLine", error_info.title());
338 strings.SetString("description", error_info.details());
339 strings.SetString("moreInfoTitle",
340 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE));
341 SetExtraInfo(&strings, error_info.extra_information());
276 342
277 resource_id = IDR_SSL_ROAD_BLOCK_HTML; 343 strings.SetString(
278 strings.SetString("headLine", error_info.title()); 344 "exit", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_EXIT));
279 strings.SetString("description", error_info.details()); 345 strings.SetString(
280 strings.SetString("moreInfoTitle", 346 "title", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_TITLE));
281 l10n_util::GetStringUTF16(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); 347 strings.SetString(
282 SetExtraInfo(&strings, error_info.extra_information()); 348 "proceed",
283 349 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_PROCEED));
284 strings.SetString( 350 strings.SetString("reasonForNotProceeding",
285 "exit", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_EXIT)); 351 l10n_util::GetStringUTF16(
286 strings.SetString( 352 IDS_SSL_OVERRIDABLE_PAGE_SHOULD_NOT_PROCEED));
287 "title", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_TITLE)); 353 }
288 strings.SetString(
289 "proceed", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_PAGE_PROCEED));
290 strings.SetString(
291 "reasonForNotProceeding", l10n_util::GetStringUTF16(
292 IDS_SSL_OVERRIDABLE_PAGE_SHOULD_NOT_PROCEED));
293 strings.SetString("errorType", "overridable");
294 strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
295 } else { 354 } else {
296 // Let's build the blocking error page. 355 // Let's build the blocking error page.
297 resource_id = IDR_SSL_BLOCKING_HTML; 356 resource_id = IDR_SSL_BLOCKING_HTML;
298 357
299 // Strings that are not dependent on the URL. 358 // Strings that are not dependent on the URL.
300 strings.SetString( 359 strings.SetString(
301 "title", l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); 360 "title", l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE));
302 strings.SetString( 361 strings.SetString(
303 "reloadMsg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD)); 362 "reloadMsg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_RELOAD));
304 strings.SetString( 363 strings.SetString(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 resource_id)); 464 resource_id));
406 return webui::GetI18nTemplateHtml(html, &strings); 465 return webui::GetI18nTemplateHtml(html, &strings);
407 } 466 }
408 467
409 std::string SSLBlockingPage::GetHTMLContentsV2() { 468 std::string SSLBlockingPage::GetHTMLContentsV2() {
410 base::DictionaryValue load_time_data; 469 base::DictionaryValue load_time_data;
411 base::string16 url(ASCIIToUTF16(request_url_.host())); 470 base::string16 url(ASCIIToUTF16(request_url_.host()));
412 if (base::i18n::IsRTL()) 471 if (base::i18n::IsRTL())
413 base::i18n::WrapStringWithLTRFormatting(&url); 472 base::i18n::WrapStringWithLTRFormatting(&url);
414 webui::SetFontAndTextDirection(&load_time_data); 473 webui::SetFontAndTextDirection(&load_time_data);
474 load_time_data.SetString("trialCondition", trial_condition_);
415 475
416 // Shared values for both the overridable and non-overridable versions. 476 // Shared values for both the overridable and non-overridable versions.
417 load_time_data.SetBoolean("ssl", true); 477 load_time_data.SetBoolean("ssl", true);
418 load_time_data.SetBoolean( 478 load_time_data.SetBoolean(
419 "overridable", overridable_ && !strict_enforcement_); 479 "overridable", overridable_ && !strict_enforcement_);
420 load_time_data.SetString( 480 load_time_data.SetString(
421 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); 481 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
422 load_time_data.SetString( 482 load_time_data.SetString(
423 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); 483 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
424 load_time_data.SetString( 484 load_time_data.SetString(
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // sure we don't clear the captive portal flag, since the interstitial was 697 // sure we don't clear the captive portal flag, since the interstitial was
638 // potentially caused by the captive portal. 698 // potentially caused by the captive portal.
639 captive_portal_detected_ = captive_portal_detected_ || 699 captive_portal_detected_ = captive_portal_detected_ ||
640 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 700 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
641 // Also keep track of non-HTTP portals and error cases. 701 // Also keep track of non-HTTP portals and error cases.
642 captive_portal_no_response_ = captive_portal_no_response_ || 702 captive_portal_no_response_ = captive_portal_no_response_ ||
643 (results->result == captive_portal::RESULT_NO_RESPONSE); 703 (results->result == captive_portal::RESULT_NO_RESPONSE);
644 } 704 }
645 #endif 705 #endif
646 } 706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698