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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 355 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
356 CaptivePortalService* captive_portal_service = | 356 CaptivePortalService* captive_portal_service = |
357 CaptivePortalServiceFactory::GetForProfile(profile); | 357 CaptivePortalServiceFactory::GetForProfile(profile); |
358 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 358 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
359 captive_portal_service ->DetectCaptivePortal(); | 359 captive_portal_service ->DetectCaptivePortal(); |
360 registrar_.Add(this, | 360 registrar_.Add(this, |
361 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 361 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
362 content::Source<Profile>(profile)); | 362 content::Source<Profile>(profile)); |
363 #endif | 363 #endif |
364 | 364 |
| 365 // chrome://interstitials page uses this class without actually creating an |
| 366 // interstitial so that it can be debugged. Set |create_interstitial| to true |
| 367 // if the page is going to be used as an actual interstitial and not just part |
| 368 // of the chrome://interstitials webui. |
365 interstitial_page_ = InterstitialPage::Create( | 369 interstitial_page_ = InterstitialPage::Create( |
366 web_contents_, true, request_url, this); | 370 web_contents_, true, request_url, this); |
367 interstitial_page_->Show(); | |
368 } | 371 } |
369 | 372 |
370 SSLBlockingPage::~SSLBlockingPage() { | 373 SSLBlockingPage::~SSLBlockingPage() { |
371 if (!callback_.is_null()) { | 374 if (!callback_.is_null()) { |
372 RecordSSLBlockingPageDetailedStats(false, | 375 RecordSSLBlockingPageDetailedStats(false, |
373 cert_error_, | 376 cert_error_, |
374 overridable_ && !strict_enforcement_, | 377 overridable_ && !strict_enforcement_, |
375 internal_, | 378 internal_, |
376 num_visits_, | 379 num_visits_, |
377 captive_portal_detection_enabled_, | 380 captive_portal_detection_enabled_, |
378 captive_portal_probe_completed_, | 381 captive_portal_probe_completed_, |
379 captive_portal_no_response_, | 382 captive_portal_no_response_, |
380 captive_portal_detected_); | 383 captive_portal_detected_); |
381 // The page is closed without the user having chosen what to do, default to | 384 // The page is closed without the user having chosen what to do, default to |
382 // deny. | 385 // deny. |
383 NotifyDenyCertificate(); | 386 NotifyDenyCertificate(); |
384 } | 387 } |
385 } | 388 } |
386 | 389 |
| 390 // static |
| 391 void SSLBlockingPage::Show(content::WebContents* web_contents, |
| 392 int cert_error, |
| 393 const net::SSLInfo& ssl_info, |
| 394 const GURL& request_url, |
| 395 bool overridable, |
| 396 bool strict_enforcement, |
| 397 const base::Callback<void(bool)>& callback) { |
| 398 SSLBlockingPage* ssl_blocking_page = new SSLBlockingPage(web_contents, |
| 399 cert_error, |
| 400 ssl_info, |
| 401 request_url, |
| 402 overridable, |
| 403 strict_enforcement, |
| 404 callback); |
| 405 ssl_blocking_page->interstitial_page_->Show(); |
| 406 } |
| 407 |
| 408 // static |
| 409 SSLBlockingPage* SSLBlockingPage::CreateForWebUI( |
| 410 content::WebContents* web_contents, |
| 411 int cert_error, |
| 412 const net::SSLInfo& ssl_info, |
| 413 const GURL& request_url, |
| 414 bool overridable, |
| 415 bool strict_enforcement) { |
| 416 return new SSLBlockingPage(web_contents, |
| 417 cert_error, |
| 418 ssl_info, |
| 419 request_url, |
| 420 overridable, |
| 421 strict_enforcement, |
| 422 base::Callback<void(bool)>()); |
| 423 } |
| 424 |
387 std::string SSLBlockingPage::GetHTMLContents() { | 425 std::string SSLBlockingPage::GetHTMLContents() { |
388 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) | 426 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) |
389 return GetHTMLContentsV1(); | 427 return GetHTMLContentsV1(); |
390 return GetHTMLContentsV2(); | 428 return GetHTMLContentsV2(); |
391 } | 429 } |
392 | 430 |
393 std::string SSLBlockingPage::GetHTMLContentsV1() { | 431 std::string SSLBlockingPage::GetHTMLContentsV1() { |
394 base::DictionaryValue strings; | 432 base::DictionaryValue strings; |
395 int resource_id; | 433 int resource_id; |
396 if (overridable_ && !strict_enforcement_) { | 434 if (overridable_ && !strict_enforcement_) { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 // sure we don't clear the captive portal flag, since the interstitial was | 849 // sure we don't clear the captive portal flag, since the interstitial was |
812 // potentially caused by the captive portal. | 850 // potentially caused by the captive portal. |
813 captive_portal_detected_ = captive_portal_detected_ || | 851 captive_portal_detected_ = captive_portal_detected_ || |
814 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 852 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
815 // Also keep track of non-HTTP portals and error cases. | 853 // Also keep track of non-HTTP portals and error cases. |
816 captive_portal_no_response_ = captive_portal_no_response_ || | 854 captive_portal_no_response_ = captive_portal_no_response_ || |
817 (results->result == captive_portal::RESULT_NO_RESPONSE); | 855 (results->result == captive_portal::RESULT_NO_RESPONSE); |
818 } | 856 } |
819 #endif | 857 #endif |
820 } | 858 } |
OLD | NEW |