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 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 WKNavigationType _lastNavigationTypeForMainFrame; | 132 WKNavigationType _lastNavigationTypeForMainFrame; |
125 | 133 |
126 // Whether the web page is currently performing window.history.pushState or | 134 // Whether the web page is currently performing window.history.pushState or |
127 // window.history.replaceState | 135 // window.history.replaceState |
128 // Set to YES on window.history.willChangeState message. To NO on | 136 // Set to YES on window.history.willChangeState message. To NO on |
129 // window.history.didPushState or window.history.didReplaceState. | 137 // window.history.didPushState or window.history.didReplaceState. |
130 BOOL _changingHistoryState; | 138 BOOL _changingHistoryState; |
131 | 139 |
132 // CRWWebUIManager object for loading WebUI pages. | 140 // CRWWebUIManager object for loading WebUI pages. |
133 base::scoped_nsobject<CRWWebUIManager> _webUIManager; | 141 base::scoped_nsobject<CRWWebUIManager> _webUIManager; |
142 | |
143 // Backs up property with the same name. | |
144 scoped_ptr<net::CertVerifierBlockAdapter> _certVerifier; | |
145 | |
146 // URLRequestContextGetter for obtaining net layer objects. | |
147 net::URLRequestContextGetter* contextGetter_; | |
134 } | 148 } |
135 | 149 |
136 // Response's MIME type of the last known navigation. | 150 // Response's MIME type of the last known navigation. |
137 @property(nonatomic, copy) NSString* documentMIMEType; | 151 @property(nonatomic, copy) NSString* documentMIMEType; |
138 | 152 |
139 // Dictionary where keys are the names of WKWebView properties and values are | 153 // Dictionary where keys are the names of WKWebView properties and values are |
140 // selector names which should be called when a corresponding property has | 154 // selector names which should be called when a corresponding property has |
141 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that | 155 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that |
142 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is | 156 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is |
143 // changed. | 157 // changed. |
144 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; | 158 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; |
145 | 159 |
146 // Activity indicator group ID for this web controller. | 160 // Activity indicator group ID for this web controller. |
147 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; | 161 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; |
148 | 162 |
149 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 163 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
150 // Identifier used for storing and retrieving certificates. | 164 // Identifier used for storing and retrieving certificates. |
151 @property(nonatomic, readonly) int certGroupID; | 165 @property(nonatomic, readonly) int certGroupID; |
152 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 166 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
153 | 167 |
168 // Cert verification flags. Must be called on IO Thread. | |
169 @property(nonatomic, readonly) int certVerifyFlags; | |
170 | |
171 // Cert verification object which wraps net::CertVerifier. Must be called on | |
172 // IO Thread. | |
173 @property(nonatomic, readonly) net::CertVerifierBlockAdapter* certVerifier; | |
174 | |
154 // Returns the WKWebViewConfigurationProvider associated with the web | 175 // Returns the WKWebViewConfigurationProvider associated with the web |
155 // controller's BrowserState. | 176 // controller's BrowserState. |
156 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; | 177 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; |
157 | 178 |
158 // Creates a web view with given |config|. No-op if web view is already created. | 179 // Creates a web view with given |config|. No-op if web view is already created. |
159 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; | 180 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; |
160 | 181 |
161 // Returns a new autoreleased web view created with given configuration. | 182 // Returns a new autoreleased web view created with given configuration. |
162 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; | 183 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; |
163 | 184 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // _documentURL, and informs the superclass of the change. | 254 // _documentURL, and informs the superclass of the change. |
234 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; | 255 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; |
235 | 256 |
236 // Returns new autoreleased instance of WKUserContentController which has | 257 // Returns new autoreleased instance of WKUserContentController which has |
237 // early page script. | 258 // early page script. |
238 - (WKUserContentController*)createUserContentController; | 259 - (WKUserContentController*)createUserContentController; |
239 | 260 |
240 // Attempts to handle a script message. Returns YES on success, NO otherwise. | 261 // Attempts to handle a script message. Returns YES on success, NO otherwise. |
241 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; | 262 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; |
242 | 263 |
264 // Verifies the given |cert| for the given |host| and calls |completionHandler| | |
265 // on completion. |completionHandler| can not be null and will be called | |
266 // asynchronously on the main thread. | |
267 - (void)verifyCert:(scoped_refptr<net::X509Certificate>)cert | |
268 forHost:(NSString*)host | |
269 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler; | |
270 | |
243 // Used to decide whether a load that generates errors with the | 271 // Used to decide whether a load that generates errors with the |
244 // NSURLErrorCancelled code should be cancelled. | 272 // NSURLErrorCancelled code should be cancelled. |
245 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; | 273 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; |
246 | 274 |
247 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 275 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
248 // Called when WKWebView estimatedProgress has been changed. | 276 // Called when WKWebView estimatedProgress has been changed. |
249 - (void)webViewEstimatedProgressDidChange; | 277 - (void)webViewEstimatedProgressDidChange; |
250 | 278 |
251 // Called when WKWebView certificateChain or hasOnlySecureContent property has | 279 // Called when WKWebView certificateChain or hasOnlySecureContent property has |
252 // changed. | 280 // changed. |
253 - (void)webViewSecurityFeaturesDidChange; | 281 - (void)webViewSecurityFeaturesDidChange; |
254 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 282 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
255 | 283 |
256 // Called when WKWebView loading state has been changed. | 284 // Called when WKWebView loading state has been changed. |
257 - (void)webViewLoadingStateDidChange; | 285 - (void)webViewLoadingStateDidChange; |
258 | 286 |
259 // Called when WKWebView title has been changed. | 287 // Called when WKWebView title has been changed. |
260 - (void)webViewTitleDidChange; | 288 - (void)webViewTitleDidChange; |
261 | 289 |
262 // Called when WKWebView URL has been changed. | 290 // Called when WKWebView URL has been changed. |
263 - (void)webViewURLDidChange; | 291 - (void)webViewURLDidChange; |
264 | 292 |
265 @end | 293 @end |
266 | 294 |
267 @implementation CRWWKWebViewWebController | 295 @implementation CRWWKWebViewWebController |
268 | 296 |
269 #pragma mark CRWWebController public methods | 297 #pragma mark CRWWebController public methods |
270 | 298 |
271 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState { | 299 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState { |
272 return [super initWithWebState:webState.Pass()]; | 300 DCHECK(webState); |
301 web::BrowserState* browserState = webState->GetBrowserState(); | |
302 self = [super initWithWebState:webState.Pass()]; | |
303 if (self) { | |
304 contextGetter_ = browserState->GetRequestContext(); | |
305 } | |
306 return self; | |
273 } | 307 } |
274 | 308 |
275 - (BOOL)keyboardDisplayRequiresUserAction { | 309 - (BOOL)keyboardDisplayRequiresUserAction { |
276 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment | 310 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment |
277 // in protected header. | 311 // in protected header. |
278 NOTIMPLEMENTED(); | 312 NOTIMPLEMENTED(); |
279 return NO; | 313 return NO; |
280 } | 314 } |
281 | 315 |
282 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction { | 316 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction { |
(...skipping 21 matching lines...) Expand all Loading... | |
304 [super terminateNetworkActivity]; | 338 [super terminateNetworkActivity]; |
305 } | 339 } |
306 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 340 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
307 | 341 |
308 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy { | 342 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy { |
309 // TODO(eugenebut): implement dialogs/windows suppression using | 343 // TODO(eugenebut): implement dialogs/windows suppression using |
310 // WKNavigationDelegate methods where possible. | 344 // WKNavigationDelegate methods where possible. |
311 [super setPageDialogOpenPolicy:policy]; | 345 [super setPageDialogOpenPolicy:policy]; |
312 } | 346 } |
313 | 347 |
348 - (void)close { | |
349 // cert verifier must be deleted on the same thread where it was created. | |
350 if (_certVerifier) { | |
351 web::WebThread::DeleteSoon(web::WebThread::IO, FROM_HERE, | |
352 _certVerifier.release()); | |
353 } | |
354 [super close]; | |
355 } | |
356 | |
314 #pragma mark - | 357 #pragma mark - |
315 #pragma mark Testing-Only Methods | 358 #pragma mark Testing-Only Methods |
316 | 359 |
317 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { | 360 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { |
318 [super injectWebViewContentView:webViewContentView]; | 361 [super injectWebViewContentView:webViewContentView]; |
319 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; | 362 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; |
320 } | 363 } |
321 | 364 |
322 #pragma mark - Protected property implementations | 365 #pragma mark - Protected property implementations |
323 | 366 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 } | 539 } |
497 | 540 |
498 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) | 541 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) |
499 - (int)certGroupID { | 542 - (int)certGroupID { |
500 DCHECK(self.webStateImpl); | 543 DCHECK(self.webStateImpl); |
501 // Request tracker IDs are used as certificate groups. | 544 // Request tracker IDs are used as certificate groups. |
502 return self.webStateImpl->GetRequestTracker()->identifier(); | 545 return self.webStateImpl->GetRequestTracker()->identifier(); |
503 } | 546 } |
504 #endif | 547 #endif |
505 | 548 |
549 - (int)certVerifyFlags { | |
550 DCHECK(contextGetter_); | |
551 net::URLRequestContext* context = contextGetter_->GetURLRequestContext(); | |
552 DCHECK(context); | |
553 net::SSLConfigService* SSLConfigService = context->ssl_config_service(); | |
554 DCHECK(SSLConfigService); | |
555 net::SSLConfig config; | |
556 SSLConfigService->GetSSLConfig(&config); | |
557 return config.GetCertVerifyFlags(); | |
558 } | |
559 | |
560 - (net::CertVerifierBlockAdapter*)certVerifier { | |
561 if (!_certVerifier) { | |
562 DCHECK(contextGetter_); | |
563 net::URLRequestContext* context = contextGetter_->GetURLRequestContext(); | |
564 DCHECK(context); | |
565 _certVerifier.reset(new net::CertVerifierBlockAdapter( | |
566 context->cert_verifier(), context->net_log())); | |
567 } | |
568 return _certVerifier.get(); | |
569 } | |
570 | |
506 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { | 571 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { |
507 DCHECK(self.webStateImpl); | 572 DCHECK(self.webStateImpl); |
508 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 573 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
509 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); | 574 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); |
510 } | 575 } |
511 | 576 |
512 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { | 577 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { |
513 if (!_wkWebView) { | 578 if (!_wkWebView) { |
514 // Use a separate userContentController for each web view. | 579 // Use a separate userContentController for each web view. |
515 // WKUserContentController does not allow adding multiple script message | 580 // 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"] = | 910 (*handlers)["window.history.willChangeState"] = |
846 @selector(handleWindowHistoryWillChangeStateMessage:context:); | 911 @selector(handleWindowHistoryWillChangeStateMessage:context:); |
847 }); | 912 }); |
848 DCHECK(handlers); | 913 DCHECK(handlers); |
849 auto iter = handlers->find(command); | 914 auto iter = handlers->find(command); |
850 return iter != handlers->end() | 915 return iter != handlers->end() |
851 ? iter->second | 916 ? iter->second |
852 : [super selectorToHandleJavaScriptCommand:command]; | 917 : [super selectorToHandleJavaScriptCommand:command]; |
853 } | 918 } |
854 | 919 |
920 - (void)verifyCert:(scoped_refptr<net::X509Certificate>)cert | |
921 forHost:(NSString*)host | |
922 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler { | |
923 DCHECK(completionHandler); | |
924 web::WebThread::PostTask( | |
925 web::WebThread::IO, FROM_HERE, base::BindBlock(^{ | |
926 // WeakNSObject does not work across different threads, hence this block | |
927 // retains self. | |
928 if ([self isBeingDestroyed]) { | |
929 completionHandler(net::CertVerifyResult(), net::ERR_FAILED); | |
930 return; | |
931 } | |
932 | |
933 std::string hostname = base::SysNSStringToUTF8(host); | |
934 net::CertVerifierBlockAdapter::Params params(cert, hostname); | |
935 params.flags = self.certVerifyFlags; | |
936 params.crl_set = net::SSLConfigService::GetCRLSet().Pass(); | |
937 // OCSP response is not provided by iOS API. | |
938 | |
939 self.certVerifier->Verify( | |
940 params, | |
941 ^(net::CertVerifyResult certVerifyResult, int statusResult) { | |
942 dispatch_async(dispatch_get_main_queue(), ^{ | |
943 completionHandler(certVerifyResult, statusResult); | |
944 }); | |
945 }); | |
946 })); | |
947 } | |
948 | |
855 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { | 949 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { |
856 DCHECK_EQ(error.code, NSURLErrorCancelled); | 950 DCHECK_EQ(error.code, NSURLErrorCancelled); |
857 // Do not abort the load if it is for an app specific URL, as such errors | 951 // 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. | 952 // are produced during the app specific URL load process. |
859 const GURL errorURL = | 953 const GURL errorURL = |
860 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); | 954 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); |
861 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) | 955 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) |
862 return NO; | 956 return NO; |
863 // Don't abort NSURLErrorCancelled errors originating from navigation | 957 // Don't abort NSURLErrorCancelled errors originating from navigation |
864 // as the WKWebView will automatically retry these loads. | 958 // 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 { | 1275 withError:(NSError *)error { |
1182 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) | 1276 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) |
1183 inMainFrame:YES]; | 1277 inMainFrame:YES]; |
1184 } | 1278 } |
1185 | 1279 |
1186 - (void)webView:(WKWebView *)webView | 1280 - (void)webView:(WKWebView *)webView |
1187 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge | 1281 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge |
1188 completionHandler: | 1282 completionHandler: |
1189 (void (^)(NSURLSessionAuthChallengeDisposition disposition, | 1283 (void (^)(NSURLSessionAuthChallengeDisposition disposition, |
1190 NSURLCredential *credential))completionHandler { | 1284 NSURLCredential *credential))completionHandler { |
1191 NOTIMPLEMENTED(); | 1285 if (![challenge.protectionSpace.authenticationMethod |
1192 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); | 1286 isEqual:NSURLAuthenticationMethodServerTrust]) { |
1287 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); | |
1288 return; | |
1289 } | |
1290 | |
1291 SecTrustRef trust = challenge.protectionSpace.serverTrust; | |
1292 scoped_refptr<net::X509Certificate> cert = web::CreateCertFromTrust(trust); | |
1293 [self verifyCert:cert | |
1294 forHost:challenge.protectionSpace.host | |
1295 completionHandler:^(net::CertVerifyResult certVerifyResult, | |
1296 int statusResult) { | |
1297 bool isCertValid = | |
1298 statusResult == net::OK && | |
1299 !net::IsCertStatusError(certVerifyResult.cert_status) && | |
1300 !net::IsCertStatusMinorError(certVerifyResult.cert_status); | |
Ryan Sleevi
2015/08/14 02:29:44
net will never return OK if IsCertStatusError() is
Eugene But (OOO till 7-30)
2015/08/14 21:18:20
Changing to bool isCertValid = statusResult == net
| |
1301 if (isCertValid) { | |
1302 // Cert is valid. | |
1303 } else { | |
1304 // Cert is invalid. | |
1305 } | |
1306 NOTIMPLEMENTED(); | |
1307 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); | |
1308 }]; | |
1193 } | 1309 } |
1194 | 1310 |
1195 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { | 1311 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { |
1196 [self webViewWebProcessDidCrash]; | 1312 [self webViewWebProcessDidCrash]; |
1197 } | 1313 } |
1198 | 1314 |
1199 #pragma mark WKUIDelegate Methods | 1315 #pragma mark WKUIDelegate Methods |
1200 | 1316 |
1201 - (WKWebView*)webView:(WKWebView*)webView | 1317 - (WKWebView*)webView:(WKWebView*)webView |
1202 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration | 1318 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1281 placeholderText:defaultText | 1397 placeholderText:defaultText |
1282 requestURL: | 1398 requestURL: |
1283 net::GURLWithNSURL(frame.request.URL) | 1399 net::GURLWithNSURL(frame.request.URL) |
1284 completionHandler:completionHandler]; | 1400 completionHandler:completionHandler]; |
1285 } else if (completionHandler) { | 1401 } else if (completionHandler) { |
1286 completionHandler(nil); | 1402 completionHandler(nil); |
1287 } | 1403 } |
1288 } | 1404 } |
1289 | 1405 |
1290 @end | 1406 @end |
OLD | NEW |