OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_error_handler.h" | 5 #include "chrome/browser/ssl/ssl_error_handler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 content::Details<CaptivePortalService::Results>(details).ptr(); | 387 content::Details<CaptivePortalService::Results>(details).ptr(); |
388 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) | 388 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) |
389 ShowCaptivePortalInterstitial(results->landing_url); | 389 ShowCaptivePortalInterstitial(results->landing_url); |
390 else | 390 else |
391 ShowSSLInterstitial(); | 391 ShowSSLInterstitial(); |
392 #endif | 392 #endif |
393 } | 393 } |
394 | 394 |
395 void SSLErrorHandler::DidStartNavigationToPendingEntry( | 395 void SSLErrorHandler::DidStartNavigationToPendingEntry( |
396 const GURL& /* url */, | 396 const GURL& /* url */, |
397 content::NavigationController::ReloadType /* reload_type */) { | 397 content::ReloadType /* reload_type */) { |
398 // Destroy the error handler on all new navigations. This ensures that the | 398 // Destroy the error handler on all new navigations. This ensures that the |
399 // handler is properly recreated when a hanging page is navigated to an SSL | 399 // handler is properly recreated when a hanging page is navigated to an SSL |
400 // error, even when the tab's WebContents doesn't change. | 400 // error, even when the tab's WebContents doesn't change. |
401 DeleteSSLErrorHandler(); | 401 DeleteSSLErrorHandler(); |
402 } | 402 } |
403 | 403 |
404 void SSLErrorHandler::NavigationStopped() { | 404 void SSLErrorHandler::NavigationStopped() { |
405 // Destroy the error handler when the page load is stopped. | 405 // Destroy the error handler when the page load is stopped. |
406 DeleteSSLErrorHandler(); | 406 DeleteSSLErrorHandler(); |
407 } | 407 } |
408 | 408 |
409 void SSLErrorHandler::DeleteSSLErrorHandler() { | 409 void SSLErrorHandler::DeleteSSLErrorHandler() { |
410 // Need to explicity deny the certificate via the callback, otherwise memory | 410 // Need to explicity deny the certificate via the callback, otherwise memory |
411 // is leaked. | 411 // is leaked. |
412 if (!callback_.is_null()) { | 412 if (!callback_.is_null()) { |
413 base::ResetAndReturn(&callback_) | 413 base::ResetAndReturn(&callback_) |
414 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); | 414 .Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); |
415 } | 415 } |
416 if (common_name_mismatch_handler_) { | 416 if (common_name_mismatch_handler_) { |
417 common_name_mismatch_handler_->Cancel(); | 417 common_name_mismatch_handler_->Cancel(); |
418 common_name_mismatch_handler_.reset(); | 418 common_name_mismatch_handler_.reset(); |
419 } | 419 } |
420 // Deletes |this| and also destroys the timer. | 420 // Deletes |this| and also destroys the timer. |
421 web_contents_->RemoveUserData(UserDataKey()); | 421 web_contents_->RemoveUserData(UserDataKey()); |
422 } | 422 } |
OLD | NEW |