Commit 8bb6cc36 authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Add mode to IOSSSLErrorHandler that returns error HTML in a callback

This mode will be triggered from PrepareErrorPage in a follow-up CL.

Currently, this new code path doesn't change any behavior because
a null callback from AllowCertificateError will follow the usual
Show() logic.

Bug: 987407
Change-Id: I32c2e1bd0fadb7540204e659b218d0138f168260
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769353
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694852}
parent 38b3393f
...@@ -30,6 +30,9 @@ class IOSSecurityInterstitialPage : public web::WebInterstitialDelegate { ...@@ -30,6 +30,9 @@ class IOSSecurityInterstitialPage : public web::WebInterstitialDelegate {
// Creates an interstitial and shows it. // Creates an interstitial and shows it.
void Show(); void Show();
// web::WebInterstitialDelegate implementation.
std::string GetHtmlContents() const override;
protected: protected:
// Returns true if the interstitial should create a new navigation item. // Returns true if the interstitial should create a new navigation item.
virtual bool ShouldCreateNewNavigation() const = 0; virtual bool ShouldCreateNewNavigation() const = 0;
...@@ -42,9 +45,6 @@ class IOSSecurityInterstitialPage : public web::WebInterstitialDelegate { ...@@ -42,9 +45,6 @@ class IOSSecurityInterstitialPage : public web::WebInterstitialDelegate {
// |web_interstitial_| will now have a value. // |web_interstitial_| will now have a value.
virtual void AfterShow() = 0; virtual void AfterShow() = 0;
// web::WebInterstitialDelegate implementation.
std::string GetHtmlContents() const override;
// Returns the formatted host name for the request url. // Returns the formatted host name for the request url.
base::string16 GetFormattedHostName() const; base::string16 GetFormattedHostName() const;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "components/captive_portal/captive_portal_detector.h" #include "components/captive_portal/captive_portal_detector.h"
#include "components/captive_portal/captive_portal_types.h" #include "components/captive_portal/captive_portal_types.h"
#include "ios/chrome/browser/interstitials/ios_security_interstitial_page.h"
#import "ios/web/public/web_state/web_state_user_data.h" #import "ios/web/public/web_state/web_state_user_data.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -32,12 +33,15 @@ extern const int64_t kSSLInterstitialDelayInSeconds; ...@@ -32,12 +33,15 @@ extern const int64_t kSSLInterstitialDelayInSeconds;
class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> { class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> {
public: public:
// Entry point for the class. // Entry point for the class.
static void HandleSSLError(web::WebState* web_state, static void HandleSSLError(
int cert_error, web::WebState* web_state,
const net::SSLInfo& info, int cert_error,
const GURL& request_url, const net::SSLInfo& info,
bool overridable, const GURL& request_url,
base::OnceCallback<void(bool)> callback); bool overridable,
int64_t navigation_id,
base::OnceCallback<void(bool)> callback,
base::OnceCallback<void(NSString*)> blocking_page_callback);
~IOSSSLErrorHandler() override; ~IOSSSLErrorHandler() override;
private: private:
...@@ -45,16 +49,22 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> { ...@@ -45,16 +49,22 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> {
// Creates an error handler for the given |web_state| and |request_url|. // Creates an error handler for the given |web_state| and |request_url|.
// The |cert_error| and SSL |info| represent the SSL error detected which // The |cert_error| and SSL |info| represent the SSL error detected which
// triggered the display of the SSL interstitial. If |overridable| is true, // triggered the display of the SSL interstitial for a particular
// the interstitial will allow the error to be ignored in order to proceed to // |navigation_id|, which is retrieved from
// NavigationContext::GetNavigationId(). If |overridable| is true, the
// interstitial will allow the error to be ignored in order to proceed to
// |request_url|. |callback| will be called after the user is done interacting // |request_url|. |callback| will be called after the user is done interacting
// with this interstitial. // with this interstitial. |blocking_page_callback| will be called for
IOSSSLErrorHandler(web::WebState* web_state, // committed interstitials to fetch the HTML of the interstitial page.
int cert_error, IOSSSLErrorHandler(
const net::SSLInfo& info, web::WebState* web_state,
const GURL& request_url, int cert_error,
bool overridable, const net::SSLInfo& info,
base::OnceCallback<void(bool)> callback); const GURL& request_url,
bool overridable,
int64_t navigation_id,
base::OnceCallback<void(bool)> callback,
base::OnceCallback<void(NSString*)> blocking_page_callback);
// Begins captive portal detection to determine which interstitial should be // Begins captive portal detection to determine which interstitial should be
// displayed. // displayed.
...@@ -63,10 +73,14 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> { ...@@ -63,10 +73,14 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> {
// portal detection. // portal detection.
void HandleCaptivePortalDetectionResult( void HandleCaptivePortalDetectionResult(
const captive_portal::CaptivePortalDetector::Results& results); const captive_portal::CaptivePortalDetector::Results& results);
// Displays an SSL error page interstitial. // Displays an SSL error page interstitial, or if committed interstitials are
// enabled, returns HTML content for the error page by running
// |blocking_page_callback_|.
void ShowSSLInterstitial(); void ShowSSLInterstitial();
// Displays a Captive Portal interstitial. The |landing_url| is the web page // Displays a Captive Portal interstitial, or if committed interstitials are
// which allows the user to complete their connection to the network. // enabled, returns the HTML content for the error page by running
// |blocking_page_callback_|. The |landing_url| is the web page which allows
// the user to complete their connection to the network.
void ShowCaptivePortalInterstitial(const GURL& landing_url); void ShowCaptivePortalInterstitial(const GURL& landing_url);
// Records a metric to classify if SSL errors are due to a Captive Portal // Records a metric to classify if SSL errors are due to a Captive Portal
// state. // state.
...@@ -84,10 +98,14 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> { ...@@ -84,10 +98,14 @@ class IOSSSLErrorHandler : public web::WebStateUserData<IOSSSLErrorHandler> {
// Whether or not the user can ignore this error in order to continue loading // Whether or not the user can ignore this error in order to continue loading
// |request_url_|. // |request_url_|.
const bool overridable_ = false; const bool overridable_ = false;
// The id of the navigation.
const int64_t navigation_id_ = 0;
// The callback to run after the user is done interacting with this // The callback to run after the user is done interacting with this
// interstitial. |proceed| will be true if the user wants to procced with the // interstitial. |proceed| will be true if the user wants to procced with the
// page load of |request_url_|, false otherwise. // page load of |request_url_|, false otherwise.
base::OnceCallback<void(bool proceed)> callback_; base::OnceCallback<void(bool proceed)> callback_;
// The callback to run for showing a committed interstitial.
base::OnceCallback<void(NSString*)> blocking_page_callback_;
// A timer to display the SSL interstitial if the captive portal detection // A timer to display the SSL interstitial if the captive portal detection
// takes too long. // takes too long.
base::OneShotTimer timer_; base::OneShotTimer timer_;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "components/captive_portal/captive_portal_detector.h" #include "components/captive_portal/captive_portal_detector.h"
#include "components/security_interstitials/core/ssl_error_ui.h" #include "components/security_interstitials/core/ssl_error_ui.h"
#include "ios/chrome/browser/ssl/captive_portal_detector_tab_helper.h" #include "ios/chrome/browser/ssl/captive_portal_detector_tab_helper.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "ios/chrome/browser/ssl/captive_portal_metrics.h" #include "ios/chrome/browser/ssl/captive_portal_metrics.h"
#include "ios/chrome/browser/ssl/ios_captive_portal_blocking_page.h" #include "ios/chrome/browser/ssl/ios_captive_portal_blocking_page.h"
#include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" #include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h"
#import "ios/chrome/browser/ssl/ios_ssl_error_tab_helper.h"
#include "ios/web/public/browser_state.h" #include "ios/web/public/browser_state.h"
#import "ios/web/public/web_state.h" #import "ios/web/public/web_state.h"
#include "net/ssl/ssl_info.h" #include "net/ssl/ssl_info.h"
...@@ -38,7 +40,9 @@ void IOSSSLErrorHandler::HandleSSLError( ...@@ -38,7 +40,9 @@ void IOSSSLErrorHandler::HandleSSLError(
const net::SSLInfo& info, const net::SSLInfo& info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
base::OnceCallback<void(bool)> callback) { int64_t navigation_id,
base::OnceCallback<void(bool)> callback,
base::OnceCallback<void(NSString*)> blocking_page_callback) {
DCHECK(!web_state->IsShowingWebInterstitial()); DCHECK(!web_state->IsShowingWebInterstitial());
DCHECK(web_state); DCHECK(web_state);
DCHECK(!FromWebState(web_state)); DCHECK(!FromWebState(web_state));
...@@ -46,26 +50,32 @@ void IOSSSLErrorHandler::HandleSSLError( ...@@ -46,26 +50,32 @@ void IOSSSLErrorHandler::HandleSSLError(
// check if the cert is from a known captive portal. // check if the cert is from a known captive portal.
web_state->SetUserData( web_state->SetUserData(
UserDataKey(), base::WrapUnique(new IOSSSLErrorHandler( UserDataKey(),
web_state, cert_error, info, request_url, overridable, base::WrapUnique(new IOSSSLErrorHandler(
std::move(callback)))); web_state, cert_error, info, request_url, overridable, navigation_id,
std::move(callback), std::move(blocking_page_callback))));
FromWebState(web_state)->StartHandlingError(); FromWebState(web_state)->StartHandlingError();
} }
IOSSSLErrorHandler::~IOSSSLErrorHandler() = default; IOSSSLErrorHandler::~IOSSSLErrorHandler() = default;
IOSSSLErrorHandler::IOSSSLErrorHandler(web::WebState* web_state, IOSSSLErrorHandler::IOSSSLErrorHandler(
int cert_error, web::WebState* web_state,
const net::SSLInfo& info, int cert_error,
const GURL& request_url, const net::SSLInfo& info,
bool overridable, const GURL& request_url,
base::OnceCallback<void(bool)> callback) bool overridable,
int64_t navigation_id,
base::OnceCallback<void(bool)> callback,
base::OnceCallback<void(NSString*)> blocking_page_callback)
: web_state_(web_state), : web_state_(web_state),
cert_error_(cert_error), cert_error_(cert_error),
ssl_info_(info), ssl_info_(info),
request_url_(request_url), request_url_(request_url),
overridable_(overridable), overridable_(overridable),
navigation_id_(navigation_id),
callback_(std::move(callback)), callback_(std::move(callback)),
blocking_page_callback_(std::move(blocking_page_callback)),
weak_factory_(this) {} weak_factory_(this) {}
void IOSSSLErrorHandler::StartHandlingError() { void IOSSSLErrorHandler::StartHandlingError() {
...@@ -120,11 +130,21 @@ void IOSSSLErrorHandler::ShowSSLInterstitial() { ...@@ -120,11 +130,21 @@ void IOSSSLErrorHandler::ShowSSLInterstitial() {
int options_mask = int options_mask =
overridable_ ? security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED overridable_ ? security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED
: security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; : security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT;
// SSLBlockingPage deletes itself when it's dismissed. if (!blocking_page_callback_.is_null()) {
IOSSSLBlockingPage* page = new IOSSSLBlockingPage( auto page = std::make_unique<IOSSSLBlockingPage>(
web_state_, cert_error_, ssl_info_, request_url_, options_mask, web_state_, cert_error_, ssl_info_, request_url_, options_mask,
base::Time::NowFromSystemTime(), std::move(callback_)); base::Time::NowFromSystemTime(), std::move(callback_));
page->Show(); std::string error_html = page->GetHtmlContents();
IOSSSLErrorTabHelper::AssociateBlockingPage(web_state_, navigation_id_,
std::move(page));
std::move(blocking_page_callback_).Run(base::SysUTF8ToNSString(error_html));
} else {
// SSLBlockingPage deletes itself when it's dismissed.
IOSSSLBlockingPage* page = new IOSSSLBlockingPage(
web_state_, cert_error_, ssl_info_, request_url_, options_mask,
base::Time::NowFromSystemTime(), std::move(callback_));
page->Show();
}
// Once an interstitial is displayed, no need to keep the handler around. // Once an interstitial is displayed, no need to keep the handler around.
// This is the equivalent of "delete this". // This is the equivalent of "delete this".
RemoveFromWebState(web_state_); RemoveFromWebState(web_state_);
...@@ -132,10 +152,19 @@ void IOSSSLErrorHandler::ShowSSLInterstitial() { ...@@ -132,10 +152,19 @@ void IOSSSLErrorHandler::ShowSSLInterstitial() {
void IOSSSLErrorHandler::ShowCaptivePortalInterstitial( void IOSSSLErrorHandler::ShowCaptivePortalInterstitial(
const GURL& landing_url) { const GURL& landing_url) {
// IOSCaptivePortalBlockingPage deletes itself when it's dismissed. if (!blocking_page_callback_.is_null()) {
IOSCaptivePortalBlockingPage* page = new IOSCaptivePortalBlockingPage( auto page = std::make_unique<IOSCaptivePortalBlockingPage>(
web_state_, request_url_, landing_url, std::move(callback_)); web_state_, request_url_, landing_url, std::move(callback_));
page->Show(); std::string error_html = page->GetHtmlContents();
IOSSSLErrorTabHelper::AssociateBlockingPage(web_state_, navigation_id_,
std::move(page));
std::move(blocking_page_callback_).Run(base::SysUTF8ToNSString(error_html));
} else {
// IOSCaptivePortalBlockingPage deletes itself when it's dismissed.
IOSCaptivePortalBlockingPage* page = new IOSCaptivePortalBlockingPage(
web_state_, request_url_, landing_url, std::move(callback_));
page->Show();
}
// Once an interstitial is displayed, no need to keep the handler around. // Once an interstitial is displayed, no need to keep the handler around.
// This is the equivalent of "delete this". // This is the equivalent of "delete this".
RemoveFromWebState(web_state_); RemoveFromWebState(web_state_);
......
...@@ -92,12 +92,14 @@ TEST_F(IOSSSLErrorHandlerTest, NonOverridable) { ...@@ -92,12 +92,14 @@ TEST_F(IOSSSLErrorHandlerTest, NonOverridable) {
ssl_info.cert = cert(); ssl_info.cert = cert();
GURL url(kTestHostName); GURL url(kTestHostName);
__block bool do_not_proceed_callback_called = false; __block bool do_not_proceed_callback_called = false;
base::OnceCallback<void(NSString*)> null_callback;
IOSSSLErrorHandler::HandleSSLError( IOSSSLErrorHandler::HandleSSLError(
web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, false, web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, false, 0,
base::BindRepeating(^(bool proceed) { base::BindRepeating(^(bool proceed) {
EXPECT_FALSE(proceed); EXPECT_FALSE(proceed);
do_not_proceed_callback_called = true; do_not_proceed_callback_called = true;
})); }),
std::move(null_callback));
EXPECT_TRUE(WaitForInterstitialDisplayed()); EXPECT_TRUE(WaitForInterstitialDisplayed());
web::WebInterstitial* interstitial = web_state()->GetWebInterstitial(); web::WebInterstitial* interstitial = web_state()->GetWebInterstitial();
...@@ -115,12 +117,14 @@ TEST_F(IOSSSLErrorHandlerTest, DISABLED_OverridableProceed) { ...@@ -115,12 +117,14 @@ TEST_F(IOSSSLErrorHandlerTest, DISABLED_OverridableProceed) {
ssl_info.cert = cert(); ssl_info.cert = cert();
GURL url(kTestHostName); GURL url(kTestHostName);
__block bool proceed_callback_called = false; __block bool proceed_callback_called = false;
base::OnceCallback<void(NSString*)> null_callback;
IOSSSLErrorHandler::HandleSSLError( IOSSSLErrorHandler::HandleSSLError(
web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, true, web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, true, 0,
base::BindRepeating(^(bool proceed) { base::BindRepeating(^(bool proceed) {
EXPECT_TRUE(proceed); EXPECT_TRUE(proceed);
proceed_callback_called = true; proceed_callback_called = true;
})); }),
std::move(null_callback));
EXPECT_TRUE(WaitForInterstitialDisplayed()); EXPECT_TRUE(WaitForInterstitialDisplayed());
web::WebInterstitial* interstitial = web_state()->GetWebInterstitial(); web::WebInterstitial* interstitial = web_state()->GetWebInterstitial();
...@@ -137,12 +141,14 @@ TEST_F(IOSSSLErrorHandlerTest, OverridableDontProceed) { ...@@ -137,12 +141,14 @@ TEST_F(IOSSSLErrorHandlerTest, OverridableDontProceed) {
ssl_info.cert = cert(); ssl_info.cert = cert();
GURL url(kTestHostName); GURL url(kTestHostName);
__block bool do_not_proceed_callback_called = false; __block bool do_not_proceed_callback_called = false;
base::OnceCallback<void(NSString*)> null_callback;
IOSSSLErrorHandler::HandleSSLError( IOSSSLErrorHandler::HandleSSLError(
web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, true, web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, true, 0,
base::BindRepeating(^(bool proceed) { base::BindRepeating(^(bool proceed) {
EXPECT_FALSE(proceed); EXPECT_FALSE(proceed);
do_not_proceed_callback_called = true; do_not_proceed_callback_called = true;
})); }),
std::move(null_callback));
EXPECT_TRUE(WaitForInterstitialDisplayed()); EXPECT_TRUE(WaitForInterstitialDisplayed());
web::WebInterstitial* interstitial = web_state()->GetWebInterstitial(); web::WebInterstitial* interstitial = web_state()->GetWebInterstitial();
...@@ -152,3 +158,23 @@ TEST_F(IOSSSLErrorHandlerTest, OverridableDontProceed) { ...@@ -152,3 +158,23 @@ TEST_F(IOSSSLErrorHandlerTest, OverridableDontProceed) {
interstitial->DontProceed(); interstitial->DontProceed();
EXPECT_TRUE(do_not_proceed_callback_called); EXPECT_TRUE(do_not_proceed_callback_called);
} }
// Tests that error HTML is returned instead of calling the usual show
// interstitial logic when passed a non-null |blocking_page_callback|.
TEST_F(IOSSSLErrorHandlerTest, CommittedInterstitialErrorHtml) {
net::SSLInfo ssl_info;
ssl_info.cert = cert();
GURL url(kTestHostName);
__block bool blocking_page_callback_called = false;
base::OnceCallback<void(bool)> null_callback;
base::OnceCallback<void(NSString*)> blocking_page_callback =
base::BindOnce(^(NSString* blocking_page_html) {
EXPECT_NE(blocking_page_html, nil);
blocking_page_callback_called = true;
});
IOSSSLErrorHandler::HandleSSLError(
web_state(), net::ERR_CERT_AUTHORITY_INVALID, ssl_info, url, true, 0,
std::move(null_callback), std::move(blocking_page_callback));
EXPECT_FALSE(WaitForInterstitialDisplayed());
EXPECT_TRUE(blocking_page_callback_called);
}
...@@ -48,6 +48,7 @@ class ChromeWebClient : public web::WebClient { ...@@ -48,6 +48,7 @@ class ChromeWebClient : public web::WebClient {
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback) override; const base::Callback<void(bool)>& callback) override;
void PrepareErrorPage( void PrepareErrorPage(
web::WebState* web_state, web::WebState* web_state,
......
...@@ -184,13 +184,16 @@ void ChromeWebClient::AllowCertificateError( ...@@ -184,13 +184,16 @@ void ChromeWebClient::AllowCertificateError(
const net::SSLInfo& info, const net::SSLInfo& info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
base::OnceCallback<void(NSString*)> null_callback;
// TODO(crbug.com/760873): IOSSSLErrorHandler will present an interstitial // TODO(crbug.com/760873): IOSSSLErrorHandler will present an interstitial
// for the user to decide if it is safe to proceed. // for the user to decide if it is safe to proceed.
// Handle the case of web_state not presenting UI to users like prerender tabs // Handle the case of web_state not presenting UI to users like prerender tabs
// or web_state used to fetch offline content in Reading List. // or web_state used to fetch offline content in Reading List.
IOSSSLErrorHandler::HandleSSLError(web_state, cert_error, info, request_url, IOSSSLErrorHandler::HandleSSLError(web_state, cert_error, info, request_url,
overridable, callback); overridable, navigation_id, callback,
std::move(null_callback));
} }
void ChromeWebClient::PrepareErrorPage( void ChromeWebClient::PrepareErrorPage(
......
...@@ -1567,7 +1567,7 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -1567,7 +1567,7 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
// Ask web client if this cert error should be allowed. // Ask web client if this cert error should be allowed.
web::GetWebClient()->AllowCertificateError( web::GetWebClient()->AllowCertificateError(
self.webStateImpl, net::MapCertStatusToNetError(info.cert_status), info, self.webStateImpl, net::MapCertStatusToNetError(info.cert_status), info,
net::GURLWithNSURL(requestURL), recoverable, net::GURLWithNSURL(requestURL), recoverable, context->GetNavigationId(),
base::BindRepeating(^(bool proceed) { base::BindRepeating(^(bool proceed) {
if (proceed) { if (proceed) {
DCHECK(recoverable); DCHECK(recoverable);
......
...@@ -44,6 +44,7 @@ class TestWebClient : public web::WebClient { ...@@ -44,6 +44,7 @@ class TestWebClient : public web::WebClient {
const net::SSLInfo&, const net::SSLInfo&,
const GURL&, const GURL&,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>&) override; const base::Callback<void(bool)>&) override;
void PrepareErrorPage(WebState* web_state, void PrepareErrorPage(WebState* web_state,
const GURL& url, const GURL& url,
......
...@@ -73,6 +73,7 @@ void TestWebClient::AllowCertificateError( ...@@ -73,6 +73,7 @@ void TestWebClient::AllowCertificateError(
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
last_cert_error_code_ = cert_error; last_cert_error_code_ = cert_error;
last_cert_error_ssl_info_ = ssl_info; last_cert_error_ssl_info_ = ssl_info;
......
...@@ -141,15 +141,18 @@ class WebClient { ...@@ -141,15 +141,18 @@ class WebClient {
// Informs the embedder that a certificate error has occurred. |cert_error| is // Informs the embedder that a certificate error has occurred. |cert_error| is
// a network error code defined in //net/base/net_error_list.h. If // a network error code defined in //net/base/net_error_list.h. If
// |overridable| is true, the user can ignore the error and continue. The // |overridable| is true, the user can ignore the error and continue.
// embedder can call the |callback| asynchronously (an argument of true means // |navigation_id| is retrieved from NavigationContext::GetNavigationId() and
// that |cert_error| should be ignored and web// should load the page). // indicates which navigation triggered the certificate error. The embedder
// can call the |callback| asynchronously (an argument of true means that
// |cert_error| should be ignored and web// should load the page).
virtual void AllowCertificateError( virtual void AllowCertificateError(
WebState* web_state, WebState* web_state,
int cert_error, int cert_error,
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback); const base::Callback<void(bool)>& callback);
// Calls the given |callback| with the contents of an error page to display // Calls the given |callback| with the contents of an error page to display
......
...@@ -36,6 +36,7 @@ class ShellWebClient : public WebClient { ...@@ -36,6 +36,7 @@ class ShellWebClient : public WebClient {
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback) override; const base::Callback<void(bool)>& callback) override;
ShellBrowserState* browser_state() const; ShellBrowserState* browser_state() const;
......
...@@ -89,6 +89,7 @@ void ShellWebClient::AllowCertificateError( ...@@ -89,6 +89,7 @@ void ShellWebClient::AllowCertificateError(
const net::SSLInfo&, const net::SSLInfo&,
const GURL&, const GURL&,
bool overridable, bool overridable,
int64_t /*navigation_id*/,
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
base::Callback<void(bool)> block_callback(callback); base::Callback<void(bool)> block_callback(callback);
UIAlertController* alert = [UIAlertController UIAlertController* alert = [UIAlertController
......
...@@ -82,6 +82,7 @@ void WebClient::AllowCertificateError( ...@@ -82,6 +82,7 @@ void WebClient::AllowCertificateError(
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
callback.Run(false); callback.Run(false);
} }
......
...@@ -34,6 +34,7 @@ class WebViewWebClient : public web::WebClient { ...@@ -34,6 +34,7 @@ class WebViewWebClient : public web::WebClient {
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::RepeatingCallback<void(bool)>& callback) override; const base::RepeatingCallback<void(bool)>& callback) override;
private: private:
......
...@@ -102,6 +102,7 @@ void WebViewWebClient::AllowCertificateError( ...@@ -102,6 +102,7 @@ void WebViewWebClient::AllowCertificateError(
const net::SSLInfo& ssl_info, const net::SSLInfo& ssl_info,
const GURL& request_url, const GURL& request_url,
bool overridable, bool overridable,
int64_t navigation_id,
const base::RepeatingCallback<void(bool)>& callback) { const base::RepeatingCallback<void(bool)>& callback) {
CWVWebView* web_view = [CWVWebView webViewForWebState:web_state]; CWVWebView* web_view = [CWVWebView webViewForWebState:web_state];
base::RepeatingCallback<void(bool)> callback_copy = callback; base::RepeatingCallback<void(bool)> callback_copy = callback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment