Chromium Code Reviews| 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 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/ios/weak_nsobject.h" | 10 #include "base/ios/weak_nsobject.h" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/mac/bind_objc_block.h" | |
| 12 #import "base/mac/scoped_nsobject.h" | 13 #import "base/mac/scoped_nsobject.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #import "base/memory/scoped_ptr.h" | |
| 14 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 15 #include "base/values.h" | 17 #include "base/values.h" |
| 16 #import "ios/net/http_response_headers_util.h" | 18 #import "ios/net/http_response_headers_util.h" |
| 17 #import "ios/web/crw_network_activity_indicator_manager.h" | 19 #import "ios/web/crw_network_activity_indicator_manager.h" |
| 18 #import "ios/web/navigation/crw_session_controller.h" | 20 #import "ios/web/navigation/crw_session_controller.h" |
| 19 #include "ios/web/navigation/web_load_params.h" | 21 #include "ios/web/navigation/web_load_params.h" |
| 22 #include "ios/web/net/cert_verifier_block_adapter.h" | |
| 23 #include "ios/web/public/browser_state.h" | |
| 20 #include "ios/web/public/web_client.h" | 24 #include "ios/web/public/web_client.h" |
| 25 #include "ios/web/public/web_thread.h" | |
| 21 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" | 26 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" |
| 22 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" | 27 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" |
| 23 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" | 28 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" |
| 24 #import "ios/web/ui_web_view_util.h" | 29 #import "ios/web/ui_web_view_util.h" |
| 25 #include "ios/web/web_state/blocked_popup_info.h" | 30 #include "ios/web/web_state/blocked_popup_info.h" |
| 26 #import "ios/web/web_state/error_translation_util.h" | 31 #import "ios/web/web_state/error_translation_util.h" |
| 27 #include "ios/web/web_state/frame_info.h" | 32 #include "ios/web/web_state/frame_info.h" |
| 28 #import "ios/web/web_state/js/crw_js_window_id_manager.h" | 33 #import "ios/web/web_state/js/crw_js_window_id_manager.h" |
| 29 #import "ios/web/web_state/js/page_script_util.h" | 34 #import "ios/web/web_state/js/page_script_util.h" |
| 30 #import "ios/web/web_state/ui/crw_web_controller+protected.h" | 35 #import "ios/web/web_state/ui/crw_web_controller+protected.h" |
| 31 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" | 36 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" |
| 32 #import "ios/web/web_state/ui/web_view_js_utils.h" | 37 #import "ios/web/web_state/ui/web_view_js_utils.h" |
| 33 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" | 38 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" |
| 34 #import "ios/web/web_state/web_state_impl.h" | 39 #import "ios/web/web_state/web_state_impl.h" |
| 35 #import "ios/web/web_state/web_view_internal_creation_util.h" | 40 #import "ios/web/web_state/web_view_internal_creation_util.h" |
| 36 #import "ios/web/webui/crw_web_ui_manager.h" | 41 #import "ios/web/webui/crw_web_ui_manager.h" |
| 37 #import "net/base/mac/url_conversions.h" | 42 #import "net/base/mac/url_conversions.h" |
| 43 #include "net/cert/cert_verify_result.h" | |
| 44 #include "net/ssl/ssl_config_service.h" | |
| 45 #include "net/url_request/url_request_context.h" | |
| 38 | 46 |
| 39 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 47 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
| 40 #include "ios/web/public/cert_store.h" | 48 #include "ios/web/public/cert_store.h" |
| 41 #include "ios/web/public/navigation_item.h" | 49 #include "ios/web/public/navigation_item.h" |
| 42 #include "ios/web/public/ssl_status.h" | 50 #include "ios/web/public/ssl_status.h" |
| 43 #import "ios/web/web_state/wk_web_view_security_util.h" | 51 #import "ios/web/web_state/wk_web_view_security_util.h" |
| 44 #include "net/cert/x509_certificate.h" | 52 #include "net/cert/x509_certificate.h" |
| 45 #include "net/ssl/ssl_info.h" | 53 #include "net/ssl/ssl_info.h" |
| 46 #endif | 54 #endif |
| 47 | 55 |
| 48 namespace { | 56 namespace { |
| 49 // Extracts Referer value from WKNavigationAction request header. | 57 // Extracts Referer value from WKNavigationAction request header. |
| 50 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { | 58 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { |
| 51 return [action.request valueForHTTPHeaderField:@"Referer"]; | 59 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 52 } | 60 } |
| 53 | 61 |
| 62 // Returns net::URLRequestContext obtained from the given |webState|. | |
| 63 // Must be called on IO thread. | |
| 64 net::URLRequestContext* GetURLRequestContext(web::WebState* webState) { | |
| 65 DCHECK(webState); | |
| 66 net::URLRequestContextGetter* contextGetter = | |
| 67 webState->GetBrowserState()->GetRequestContext(); | |
| 68 DCHECK(contextGetter); | |
| 69 return contextGetter->GetURLRequestContext(); | |
| 70 } | |
| 71 | |
| 54 NSString* const kScriptMessageName = @"crwebinvoke"; | 72 NSString* const kScriptMessageName = @"crwebinvoke"; |
| 55 NSString* const kScriptImmediateName = @"crwebinvokeimmediate"; | 73 NSString* const kScriptImmediateName = @"crwebinvokeimmediate"; |
| 56 | 74 |
| 57 // Utility functions for storing the source of NSErrors received by WKWebViews: | 75 // Utility functions for storing the source of NSErrors received by WKWebViews: |
| 58 // - Errors received by |-webView:didFailProvisionalNavigation:withError:| are | 76 // - Errors received by |-webView:didFailProvisionalNavigation:withError:| are |
| 59 // recorded using WKWebViewErrorSource::PROVISIONAL_LOAD. These should be | 77 // recorded using WKWebViewErrorSource::PROVISIONAL_LOAD. These should be |
| 60 // aborted. | 78 // aborted. |
| 61 // - Errors received by |-webView:didFailNavigation:withError:| are recorded | 79 // - Errors received by |-webView:didFailNavigation:withError:| are recorded |
| 62 // using WKWebViewsource::NAVIGATION. These errors should not be aborted, as | 80 // using WKWebViewsource::NAVIGATION. These errors should not be aborted, as |
| 63 // the WKWebView will automatically retry the load. | 81 // the WKWebView will automatically retry the load. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 WKNavigationType _lastNavigationTypeForMainFrame; | 142 WKNavigationType _lastNavigationTypeForMainFrame; |
| 125 | 143 |
| 126 // Whether the web page is currently performing window.history.pushState or | 144 // Whether the web page is currently performing window.history.pushState or |
| 127 // window.history.replaceState | 145 // window.history.replaceState |
| 128 // Set to YES on window.history.willChangeState message. To NO on | 146 // Set to YES on window.history.willChangeState message. To NO on |
| 129 // window.history.didPushState or window.history.didReplaceState. | 147 // window.history.didPushState or window.history.didReplaceState. |
| 130 BOOL _changingHistoryState; | 148 BOOL _changingHistoryState; |
| 131 | 149 |
| 132 // CRWWebUIManager object for loading WebUI pages. | 150 // CRWWebUIManager object for loading WebUI pages. |
| 133 base::scoped_nsobject<CRWWebUIManager> _webUIManager; | 151 base::scoped_nsobject<CRWWebUIManager> _webUIManager; |
| 152 | |
| 153 // Backs up property with the same name. | |
| 154 scoped_ptr<net::CertVerifierBlockAdapter> _certVerifier; | |
| 134 } | 155 } |
| 135 | 156 |
| 136 // Response's MIME type of the last known navigation. | 157 // Response's MIME type of the last known navigation. |
| 137 @property(nonatomic, copy) NSString* documentMIMEType; | 158 @property(nonatomic, copy) NSString* documentMIMEType; |
| 138 | 159 |
| 139 // Dictionary where keys are the names of WKWebView properties and values are | 160 // Dictionary where keys are the names of WKWebView properties and values are |
| 140 // selector names which should be called when a corresponding property has | 161 // selector names which should be called when a corresponding property has |
| 141 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that | 162 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that |
| 142 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is | 163 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is |
| 143 // changed. | 164 // changed. |
| 144 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; | 165 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; |
| 145 | 166 |
| 146 // Activity indicator group ID for this web controller. | 167 // Activity indicator group ID for this web controller. |
| 147 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; | 168 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; |
| 148 | 169 |
| 149 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 170 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
| 150 // Identifier used for storing and retrieving certificates. | 171 // Identifier used for storing and retrieving certificates. |
| 151 @property(nonatomic, readonly) int certGroupID; | 172 @property(nonatomic, readonly) int certGroupID; |
| 152 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 173 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
| 153 | 174 |
| 175 // Cert verification flags. Must be called on IO Thread. | |
| 176 @property(nonatomic, readonly) int certVerifyFlags; | |
| 177 | |
| 178 // Cert verification object which wraps net::CertVerifier. Must be called on | |
| 179 // IO Thread. | |
| 180 @property(nonatomic, readonly) net::CertVerifierBlockAdapter* certVerifier; | |
| 181 | |
| 154 // Returns the WKWebViewConfigurationProvider associated with the web | 182 // Returns the WKWebViewConfigurationProvider associated with the web |
| 155 // controller's BrowserState. | 183 // controller's BrowserState. |
| 156 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; | 184 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; |
| 157 | 185 |
| 158 // Creates a web view with given |config|. No-op if web view is already created. | 186 // Creates a web view with given |config|. No-op if web view is already created. |
| 159 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; | 187 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; |
| 160 | 188 |
| 161 // Returns a new autoreleased web view created with given configuration. | 189 // Returns a new autoreleased web view created with given configuration. |
| 162 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; | 190 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; |
| 163 | 191 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 // _documentURL, and informs the superclass of the change. | 261 // _documentURL, and informs the superclass of the change. |
| 234 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; | 262 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; |
| 235 | 263 |
| 236 // Returns new autoreleased instance of WKUserContentController which has | 264 // Returns new autoreleased instance of WKUserContentController which has |
| 237 // early page script. | 265 // early page script. |
| 238 - (WKUserContentController*)createUserContentController; | 266 - (WKUserContentController*)createUserContentController; |
| 239 | 267 |
| 240 // Attempts to handle a script message. Returns YES on success, NO otherwise. | 268 // Attempts to handle a script message. Returns YES on success, NO otherwise. |
| 241 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; | 269 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; |
| 242 | 270 |
| 271 // Verifies the given |cert| for the given |host| and calls |completionHandler| | |
| 272 // on completion. |completionHandler| can not be null and will be called | |
| 273 // asynchronously on the main thread. | |
| 274 - (void)verifyCert:(scoped_refptr<net::X509Certificate>)cert | |
| 275 forHost:(NSString*)host | |
| 276 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler; | |
| 277 | |
| 243 // Used to decide whether a load that generates errors with the | 278 // Used to decide whether a load that generates errors with the |
| 244 // NSURLErrorCancelled code should be cancelled. | 279 // NSURLErrorCancelled code should be cancelled. |
| 245 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; | 280 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; |
| 246 | 281 |
| 247 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 282 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
| 248 // Called when WKWebView estimatedProgress has been changed. | 283 // Called when WKWebView estimatedProgress has been changed. |
| 249 - (void)webViewEstimatedProgressDidChange; | 284 - (void)webViewEstimatedProgressDidChange; |
| 250 | 285 |
| 251 // Called when WKWebView certificateChain or hasOnlySecureContent property has | 286 // Called when WKWebView certificateChain or hasOnlySecureContent property has |
| 252 // changed. | 287 // changed. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 } | 531 } |
| 497 | 532 |
| 498 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 533 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
| 499 - (int)certGroupID { | 534 - (int)certGroupID { |
| 500 DCHECK(self.webStateImpl); | 535 DCHECK(self.webStateImpl); |
| 501 // Request tracker IDs are used as certificate groups. | 536 // Request tracker IDs are used as certificate groups. |
| 502 return self.webStateImpl->GetRequestTracker()->identifier(); | 537 return self.webStateImpl->GetRequestTracker()->identifier(); |
| 503 } | 538 } |
| 504 #endif | 539 #endif |
| 505 | 540 |
| 541 - (int)certVerifyFlags { | |
| 542 net::URLRequestContext* context = GetURLRequestContext(self.webState); | |
| 543 DCHECK(context); | |
| 544 net::SSLConfigService* SSLConfigService = context->ssl_config_service(); | |
| 545 DCHECK(SSLConfigService); | |
| 546 net::SSLConfig config; | |
| 547 SSLConfigService->GetSSLConfig(&config); | |
| 548 return config.GetCertVerifyFlags(); | |
| 549 } | |
| 550 | |
| 551 - (net::CertVerifierBlockAdapter*)certVerifier { | |
| 552 if (!_certVerifier) { | |
| 553 net::URLRequestContext* context = GetURLRequestContext(self.webState); | |
| 554 DCHECK(context); | |
| 555 _certVerifier.reset(new net::CertVerifierBlockAdapter( | |
| 556 context->cert_verifier(), context->net_log())); | |
| 557 } | |
| 558 return _certVerifier.get(); | |
| 559 } | |
| 560 | |
| 506 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { | 561 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { |
| 507 DCHECK(self.webStateImpl); | 562 DCHECK(self.webStateImpl); |
| 508 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 563 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
| 509 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); | 564 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); |
| 510 } | 565 } |
| 511 | 566 |
| 512 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { | 567 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { |
| 513 if (!_wkWebView) { | 568 if (!_wkWebView) { |
| 514 // Use a separate userContentController for each web view. | 569 // Use a separate userContentController for each web view. |
| 515 // WKUserContentController does not allow adding multiple script message | 570 // WKUserContentController does not allow adding multiple script message |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 (*handlers)["window.history.willChangeState"] = | 900 (*handlers)["window.history.willChangeState"] = |
| 846 @selector(handleWindowHistoryWillChangeStateMessage:context:); | 901 @selector(handleWindowHistoryWillChangeStateMessage:context:); |
| 847 }); | 902 }); |
| 848 DCHECK(handlers); | 903 DCHECK(handlers); |
| 849 auto iter = handlers->find(command); | 904 auto iter = handlers->find(command); |
| 850 return iter != handlers->end() | 905 return iter != handlers->end() |
| 851 ? iter->second | 906 ? iter->second |
| 852 : [super selectorToHandleJavaScriptCommand:command]; | 907 : [super selectorToHandleJavaScriptCommand:command]; |
| 853 } | 908 } |
| 854 | 909 |
| 910 - (void)verifyCert:(scoped_refptr<net::X509Certificate>)cert | |
| 911 forHost:(NSString*)host | |
| 912 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler { | |
| 913 DCHECK(completionHandler); | |
| 914 base::WeakNSObject<CRWWKWebViewWebController> weakSelf(self); | |
| 915 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{ | |
| 916 // WeakNSObject does not work across different threads, hence this block | |
| 917 // retains self. | |
| 918 if ([self isBeingDestroyed]) { | |
| 919 completionHandler(net::CertVerifyResult(), net::ERR_FAILED); | |
| 920 return; | |
| 921 } | |
| 922 | |
| 923 std::string hostname = base::SysNSStringToUTF8(host); | |
| 924 net::CertVerifierBlockAdapter::Params params(cert, hostname); | |
|
Ryan Sleevi
2015/08/07 21:52:12
Shouldn't this be cert.Pass()?
You should either
Eugene But (OOO till 7-30)
2015/08/12 22:00:38
scoped_refptr does not have |Pass|, so that's not
Ryan Sleevi
2015/08/14 02:29:43
Yes it does.
https://code.google.com/p/chromium/c
Eugene But (OOO till 7-30)
2015/08/14 21:18:19
I'm sorry, the code with .Pass() did not compile b
| |
| 925 params.flags = self.certVerifyFlags; | |
| 926 params.crl_set = net::SSLConfigService::GetCRLSet().Pass(); | |
| 927 // OCSP response is not provided by iOS API. | |
| 928 | |
| 929 self.certVerifier->Verify( | |
| 930 params, ^(net::CertVerifyResult result, int status) { | |
| 931 dispatch_async(dispatch_get_main_queue(), ^{ | |
|
Ryan Sleevi
2015/08/07 21:52:12
Why is this double dispatch needed? Why can't you
Eugene But (OOO till 7-30)
2015/08/12 22:00:38
UIKit is not thread safe so I want to call |comple
| |
| 932 completionHandler(result, status); | |
| 933 }); | |
| 934 }); | |
| 935 })); | |
| 936 } | |
| 937 | |
| 855 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { | 938 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { |
| 856 DCHECK_EQ(error.code, NSURLErrorCancelled); | 939 DCHECK_EQ(error.code, NSURLErrorCancelled); |
| 857 // Do not abort the load if it is for an app specific URL, as such errors | 940 // Do not abort the load if it is for an app specific URL, as such errors |
| 858 // are produced during the app specific URL load process. | 941 // are produced during the app specific URL load process. |
| 859 const GURL errorURL = | 942 const GURL errorURL = |
| 860 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); | 943 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); |
| 861 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) | 944 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) |
| 862 return NO; | 945 return NO; |
| 863 // Don't abort NSURLErrorCancelled errors originating from navigation | 946 // Don't abort NSURLErrorCancelled errors originating from navigation |
| 864 // as the WKWebView will automatically retry these loads. | 947 // as the WKWebView will automatically retry these loads. |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 withError:(NSError *)error { | 1264 withError:(NSError *)error { |
| 1182 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) | 1265 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) |
| 1183 inMainFrame:YES]; | 1266 inMainFrame:YES]; |
| 1184 } | 1267 } |
| 1185 | 1268 |
| 1186 - (void)webView:(WKWebView *)webView | 1269 - (void)webView:(WKWebView *)webView |
| 1187 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge | 1270 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge |
| 1188 completionHandler: | 1271 completionHandler: |
| 1189 (void (^)(NSURLSessionAuthChallengeDisposition disposition, | 1272 (void (^)(NSURLSessionAuthChallengeDisposition disposition, |
| 1190 NSURLCredential *credential))completionHandler { | 1273 NSURLCredential *credential))completionHandler { |
| 1191 NOTIMPLEMENTED(); | 1274 if (![challenge.protectionSpace.authenticationMethod |
| 1192 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); | 1275 isEqual:NSURLAuthenticationMethodServerTrust]) { |
| 1276 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); | |
| 1277 return; | |
| 1278 } | |
| 1279 | |
| 1280 SecTrustRef trust = challenge.protectionSpace.serverTrust; | |
| 1281 scoped_refptr<net::X509Certificate> cert = web::CreateCertFromTrust(trust); | |
| 1282 [self verifyCert:cert | |
| 1283 forHost:challenge.protectionSpace.host | |
| 1284 completionHandler:^(net::CertVerifyResult result, int status) { | |
| 1285 bool isCertValid = status == net::OK && | |
| 1286 !net::IsCertStatusError(result.cert_status) && | |
| 1287 !net::IsCertStatusMinorError(result.cert_status); | |
| 1288 if (isCertValid) { | |
| 1289 // Cert is valid. | |
| 1290 } else { | |
| 1291 // Cert is invalid. | |
| 1292 } | |
| 1293 NOTIMPLEMENTED(); | |
| 1294 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); | |
| 1295 }]; | |
| 1193 } | 1296 } |
| 1194 | 1297 |
| 1195 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { | 1298 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { |
| 1196 [self webViewWebProcessDidCrash]; | 1299 [self webViewWebProcessDidCrash]; |
| 1197 } | 1300 } |
| 1198 | 1301 |
| 1199 #pragma mark WKUIDelegate Methods | 1302 #pragma mark WKUIDelegate Methods |
| 1200 | 1303 |
| 1201 - (WKWebView*)webView:(WKWebView*)webView | 1304 - (WKWebView*)webView:(WKWebView*)webView |
| 1202 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration | 1305 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 placeholderText:defaultText | 1384 placeholderText:defaultText |
| 1282 requestURL: | 1385 requestURL: |
| 1283 net::GURLWithNSURL(frame.request.URL) | 1386 net::GURLWithNSURL(frame.request.URL) |
| 1284 completionHandler:completionHandler]; | 1387 completionHandler:completionHandler]; |
| 1285 } else if (completionHandler) { | 1388 } else if (completionHandler) { |
| 1286 completionHandler(nil); | 1389 completionHandler(nil); |
| 1287 } | 1390 } |
| 1288 } | 1391 } |
| 1289 | 1392 |
| 1290 @end | 1393 @end |
| OLD | NEW |