Index: ios/chrome/browser/ssl/ios_ssl_error_handler.mm |
diff --git a/ios/chrome/browser/ssl/ios_ssl_error_handler.mm b/ios/chrome/browser/ssl/ios_ssl_error_handler.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bd49e4841a686dc66c6b4993dc4f4e7aaa6e0751 |
--- /dev/null |
+++ b/ios/chrome/browser/ssl/ios_ssl_error_handler.mm |
@@ -0,0 +1,49 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ios/chrome/browser/ssl/ios_ssl_error_handler.h" |
+ |
+#include "base/bind.h" |
+#include "components/security_interstitials/core/ssl_error_ui.h" |
+#include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" |
+#import "ios/web/public/navigation_manager.h" |
+#import "ios/web/public/web_state/web_state.h" |
+#include "net/ssl/ssl_info.h" |
+ |
+IOSSSLErrorHandler::IOSSSLErrorHandler() {} |
+IOSSSLErrorHandler::~IOSSSLErrorHandler() {} |
sdefresne
2016/06/30 11:58:16
Can you add new line between method definitions?
Eugene But (OOO till 7-30)
2016/06/30 18:35:57
These were removed.
|
+ |
+/*static*/ |
sdefresne
2016/06/30 11:58:16
"// static" is more common than "/* static */".
Eugene But (OOO till 7-30)
2016/06/30 18:35:57
Done.
|
+void IOSSSLErrorHandler::HandleSSLError( |
+ web::WebState* web_state, |
+ int cert_error, |
+ const net::SSLInfo& info, |
+ const GURL& request_url, |
+ bool overridable, |
+ const base::Callback<void(bool)>& callback) { |
+ DCHECK(!web_state->IsShowingWebInterstitial()); |
+ |
+ int options_mask = |
+ overridable ? security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED |
+ : security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; |
+ // SSLBlockingPage deletes itself when it's dismissed. |
+ auto dismissal_callback( |
+ base::Bind(&IOSSSLErrorHandler::InterstitialWasDismissed, |
+ base::Unretained(web_state), callback)); |
+ IOSSSLBlockingPage* page = new IOSSSLBlockingPage( |
+ web_state, cert_error, info, request_url, options_mask, |
+ base::Time::NowFromSystemTime(), dismissal_callback); |
+ page->Show(); |
+} |
+ |
+/*static*/ |
+void IOSSSLErrorHandler::InterstitialWasDismissed( |
+ web::WebState* web_state, |
+ const base::Callback<void(bool)>& callback, |
+ bool proceed) { |
+ if (!proceed) { |
+ web_state->GetNavigationManager()->Reload(true /* check_for_repost */); |
+ } |
+ callback.Run(proceed); |
+} |