Chromium Code Reviews| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace | 219 } // namespace |
| 220 | 220 |
| 221 // Note that we always create a navigation entry with SSL errors. | 221 // Note that we always create a navigation entry with SSL errors. |
| 222 // No error happening loading a sub-resource triggers an interstitial so far. | 222 // No error happening loading a sub-resource triggers an interstitial so far. |
| 223 SSLBlockingPage::SSLBlockingPage( | 223 SSLBlockingPage::SSLBlockingPage( |
| 224 content::WebContents* web_contents, | 224 content::WebContents* web_contents, |
| 225 bool create_interstitial, | |
| 225 int cert_error, | 226 int cert_error, |
| 226 const net::SSLInfo& ssl_info, | 227 const net::SSLInfo& ssl_info, |
| 227 const GURL& request_url, | 228 const GURL& request_url, |
| 228 bool overridable, | 229 bool overridable, |
| 229 bool strict_enforcement, | 230 bool strict_enforcement, |
| 230 const base::Callback<void(bool)>& callback) | 231 const base::Callback<void(bool)>& callback) |
| 231 : callback_(callback), | 232 : callback_(callback), |
| 232 web_contents_(web_contents), | 233 web_contents_(web_contents), |
| 233 cert_error_(cert_error), | 234 cert_error_(cert_error), |
| 234 ssl_info_(ssl_info), | 235 ssl_info_(ssl_info), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 272 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 272 CaptivePortalService* captive_portal_service = | 273 CaptivePortalService* captive_portal_service = |
| 273 CaptivePortalServiceFactory::GetForProfile(profile); | 274 CaptivePortalServiceFactory::GetForProfile(profile); |
| 274 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 275 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
| 275 captive_portal_service ->DetectCaptivePortal(); | 276 captive_portal_service ->DetectCaptivePortal(); |
| 276 registrar_.Add(this, | 277 registrar_.Add(this, |
| 277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 278 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
| 278 content::Source<Profile>(profile)); | 279 content::Source<Profile>(profile)); |
| 279 #endif | 280 #endif |
| 280 | 281 |
| 281 interstitial_page_ = InterstitialPage::Create( | 282 // chrome://interstitials page uses this class without actually creating an |
| 282 web_contents_, true, request_url, this); | 283 // interstitial so that it can be debugged. Set |create_interstitial| to true |
| 283 interstitial_page_->Show(); | 284 // if the page is going to be used as an actual interstitial and not just part |
| 285 // of the chrome://interstitials webui. | |
| 286 if (create_interstitial) { | |
| 287 interstitial_page_ = InterstitialPage::Create( | |
| 288 web_contents_, true, request_url, this); | |
| 289 interstitial_page_->Show(); | |
| 290 } | |
| 284 } | 291 } |
| 285 | 292 |
| 286 SSLBlockingPage::~SSLBlockingPage() { | 293 SSLBlockingPage::~SSLBlockingPage() { |
| 287 if (!callback_.is_null()) { | 294 if (!callback_.is_null()) { |
| 288 RecordSSLBlockingPageDetailedStats(false, | 295 RecordSSLBlockingPageDetailedStats(false, |
| 289 cert_error_, | 296 cert_error_, |
| 290 overridable_ && !strict_enforcement_, | 297 overridable_ && !strict_enforcement_, |
| 291 internal_, | 298 internal_, |
| 292 num_visits_, | 299 num_visits_, |
| 293 captive_portal_detection_enabled_, | 300 captive_portal_detection_enabled_, |
| 294 captive_portal_probe_completed_, | 301 captive_portal_probe_completed_, |
| 295 captive_portal_no_response_, | 302 captive_portal_no_response_, |
| 296 captive_portal_detected_); | 303 captive_portal_detected_); |
| 297 // The page is closed without the user having chosen what to do, default to | 304 // The page is closed without the user having chosen what to do, default to |
| 298 // deny. | 305 // deny. |
| 299 NotifyDenyCertificate(); | 306 NotifyDenyCertificate(); |
| 300 } | 307 } |
| 301 } | 308 } |
| 302 | 309 |
| 310 // static | |
| 311 void SSLBlockingPage::Show(content::WebContents* web_contents, | |
| 312 int cert_error, | |
| 313 const net::SSLInfo& ssl_info, | |
| 314 const GURL& request_url, | |
| 315 bool overridable, | |
| 316 bool strict_enforcement, | |
| 317 const base::Callback<void(bool)>& callback) { | |
| 318 // The interstitial created by the blocking page owns the blocking page. | |
| 319 new SSLBlockingPage(web_contents, | |
| 320 true, | |
|
Bernhard Bauer
2014/07/16 21:49:59
What I meant was that you could show it from here,
meacer
2014/07/17 21:24:09
Done.
| |
| 321 cert_error, | |
| 322 ssl_info, | |
| 323 request_url, | |
| 324 overridable, | |
| 325 strict_enforcement, | |
| 326 callback); | |
| 327 } | |
| 328 | |
| 329 // static | |
| 330 SSLBlockingPage* SSLBlockingPage::CreateForWebUI( | |
| 331 content::WebContents* web_contents, | |
| 332 int cert_error, | |
| 333 const net::SSLInfo& ssl_info, | |
| 334 const GURL& request_url, | |
| 335 bool overridable, | |
| 336 bool strict_enforcement) { | |
| 337 // The callee owns the blocking page. | |
|
Bernhard Bauer
2014/07/16 21:49:59
This comment would be better off in the header. Bu
meacer
2014/07/17 21:24:09
Returning scoped_ptr makes the code slightly more
| |
| 338 return new SSLBlockingPage(web_contents, | |
| 339 false, | |
| 340 cert_error, | |
| 341 ssl_info, | |
| 342 request_url, | |
| 343 overridable, | |
| 344 strict_enforcement, | |
| 345 base::Callback<void(bool)>()); | |
| 346 } | |
| 347 | |
| 303 std::string SSLBlockingPage::GetHTMLContents() { | 348 std::string SSLBlockingPage::GetHTMLContents() { |
| 304 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) | 349 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) |
| 305 return GetHTMLContentsV1(); | 350 return GetHTMLContentsV1(); |
| 306 return GetHTMLContentsV2(); | 351 return GetHTMLContentsV2(); |
| 307 } | 352 } |
| 308 | 353 |
| 309 std::string SSLBlockingPage::GetHTMLContentsV1() { | 354 std::string SSLBlockingPage::GetHTMLContentsV1() { |
| 310 base::DictionaryValue strings; | 355 base::DictionaryValue strings; |
| 311 int resource_id; | 356 int resource_id; |
| 312 if (overridable_ && !strict_enforcement_) { | 357 if (overridable_ && !strict_enforcement_) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 // sure we don't clear the captive portal flag, since the interstitial was | 766 // sure we don't clear the captive portal flag, since the interstitial was |
| 722 // potentially caused by the captive portal. | 767 // potentially caused by the captive portal. |
| 723 captive_portal_detected_ = captive_portal_detected_ || | 768 captive_portal_detected_ = captive_portal_detected_ || |
| 724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 769 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 725 // Also keep track of non-HTTP portals and error cases. | 770 // Also keep track of non-HTTP portals and error cases. |
| 726 captive_portal_no_response_ = captive_portal_no_response_ || | 771 captive_portal_no_response_ = captive_portal_no_response_ || |
| 727 (results->result == captive_portal::RESULT_NO_RESPONSE); | 772 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 728 } | 773 } |
| 729 #endif | 774 #endif |
| 730 } | 775 } |
| OLD | NEW |