Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1418)

Side by Side Diff: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm

Issue 1230033005: WKWebView: Added cert verification API to web controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put CertVerifierBlockAdapter to web namespace. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "ios/web/navigation/crw_session_entry.h" 21 #import "ios/web/navigation/crw_session_entry.h"
20 #include "ios/web/navigation/navigation_item_impl.h" 22 #include "ios/web/navigation/navigation_item_impl.h"
21 #include "ios/web/navigation/web_load_params.h" 23 #include "ios/web/navigation/web_load_params.h"
24 #include "ios/web/net/cert_verifier_block_adapter.h"
25 #include "ios/web/public/browser_state.h"
22 #include "ios/web/public/web_client.h" 26 #include "ios/web/public/web_client.h"
27 #include "ios/web/public/web_thread.h"
23 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" 28 #import "ios/web/public/web_state/js/crw_js_injection_manager.h"
24 #import "ios/web/public/web_state/ui/crw_native_content_provider.h" 29 #import "ios/web/public/web_state/ui/crw_native_content_provider.h"
25 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h" 30 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h"
26 #import "ios/web/ui_web_view_util.h" 31 #import "ios/web/ui_web_view_util.h"
27 #include "ios/web/web_state/blocked_popup_info.h" 32 #include "ios/web/web_state/blocked_popup_info.h"
28 #import "ios/web/web_state/error_translation_util.h" 33 #import "ios/web/web_state/error_translation_util.h"
29 #include "ios/web/web_state/frame_info.h" 34 #include "ios/web/web_state/frame_info.h"
30 #import "ios/web/web_state/js/crw_js_window_id_manager.h" 35 #import "ios/web/web_state/js/crw_js_window_id_manager.h"
31 #import "ios/web/web_state/js/page_script_util.h" 36 #import "ios/web/web_state/js/page_script_util.h"
32 #import "ios/web/web_state/ui/crw_web_controller+protected.h" 37 #import "ios/web/web_state/ui/crw_web_controller+protected.h"
33 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" 38 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h"
34 #import "ios/web/web_state/ui/web_view_js_utils.h" 39 #import "ios/web/web_state/ui/web_view_js_utils.h"
35 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h" 40 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h"
36 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" 41 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
37 #import "ios/web/web_state/web_state_impl.h" 42 #import "ios/web/web_state/web_state_impl.h"
38 #import "ios/web/web_state/web_view_internal_creation_util.h" 43 #import "ios/web/web_state/web_view_internal_creation_util.h"
39 #import "ios/web/webui/crw_web_ui_manager.h" 44 #import "ios/web/webui/crw_web_ui_manager.h"
40 #import "net/base/mac/url_conversions.h" 45 #import "net/base/mac/url_conversions.h"
46 #include "net/cert/cert_verify_result.h"
47 #include "net/ssl/ssl_config_service.h"
48 #include "net/url_request/url_request_context.h"
41 49
42 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 50 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
43 #include "ios/web/public/cert_store.h" 51 #include "ios/web/public/cert_store.h"
44 #include "ios/web/public/navigation_item.h" 52 #include "ios/web/public/navigation_item.h"
45 #include "ios/web/public/ssl_status.h" 53 #include "ios/web/public/ssl_status.h"
46 #import "ios/web/web_state/wk_web_view_security_util.h" 54 #import "ios/web/web_state/wk_web_view_security_util.h"
47 #include "net/cert/x509_certificate.h" 55 #include "net/cert/x509_certificate.h"
48 #include "net/ssl/ssl_info.h" 56 #include "net/ssl/ssl_info.h"
49 #endif 57 #endif
50 58
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 scoped_ptr<WKNavigationType> _pendingNavigationTypeForMainFrame; 135 scoped_ptr<WKNavigationType> _pendingNavigationTypeForMainFrame;
128 136
129 // Whether the web page is currently performing window.history.pushState or 137 // Whether the web page is currently performing window.history.pushState or
130 // window.history.replaceState 138 // window.history.replaceState
131 // Set to YES on window.history.willChangeState message. To NO on 139 // Set to YES on window.history.willChangeState message. To NO on
132 // window.history.didPushState or window.history.didReplaceState. 140 // window.history.didPushState or window.history.didReplaceState.
133 BOOL _changingHistoryState; 141 BOOL _changingHistoryState;
134 142
135 // CRWWebUIManager object for loading WebUI pages. 143 // CRWWebUIManager object for loading WebUI pages.
136 base::scoped_nsobject<CRWWebUIManager> _webUIManager; 144 base::scoped_nsobject<CRWWebUIManager> _webUIManager;
145
146 // Backs up property with the same name.
147 scoped_ptr<web::CertVerifierBlockAdapter> _certVerifier;
148
149 // URLRequestContextGetter for obtaining net layer objects.
150 net::URLRequestContextGetter* _contextGetter;
137 } 151 }
138 152
139 // Response's MIME type of the last known navigation. 153 // Response's MIME type of the last known navigation.
140 @property(nonatomic, copy) NSString* documentMIMEType; 154 @property(nonatomic, copy) NSString* documentMIMEType;
141 155
142 // Dictionary where keys are the names of WKWebView properties and values are 156 // Dictionary where keys are the names of WKWebView properties and values are
143 // selector names which should be called when a corresponding property has 157 // selector names which should be called when a corresponding property has
144 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that 158 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that
145 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is 159 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is
146 // changed. 160 // changed.
147 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; 161 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers;
148 162
149 // Activity indicator group ID for this web controller. 163 // Activity indicator group ID for this web controller.
150 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; 164 @property(nonatomic, readonly) NSString* activityIndicatorGroupID;
151 165
152 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 166 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
153 // Identifier used for storing and retrieving certificates. 167 // Identifier used for storing and retrieving certificates.
154 @property(nonatomic, readonly) int certGroupID; 168 @property(nonatomic, readonly) int certGroupID;
155 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 169 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
156 170
171 // Cert verification flags. Must be called on IO Thread.
stuartmorgan 2015/08/20 20:42:21 s/called/used/
Eugene But (OOO till 7-30) 2015/08/20 22:03:52 Done.
172 @property(nonatomic, readonly) int certVerifyFlags;
173
174 // Cert verification object which wraps net::CertVerifier. Must be called on
stuartmorgan 2015/08/20 20:42:21 same
Eugene But (OOO till 7-30) 2015/08/20 22:03:52 Done.
175 // IO Thread.
176 @property(nonatomic, readonly) web::CertVerifierBlockAdapter* certVerifier;
177
157 // Returns the WKWebViewConfigurationProvider associated with the web 178 // Returns the WKWebViewConfigurationProvider associated with the web
158 // controller's BrowserState. 179 // controller's BrowserState.
159 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; 180 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider;
160 181
161 // Creates a web view with given |config|. No-op if web view is already created. 182 // Creates a web view with given |config|. No-op if web view is already created.
162 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; 183 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config;
163 184
164 // Returns a new autoreleased web view created with given configuration. 185 // Returns a new autoreleased web view created with given configuration.
165 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; 186 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config;
166 187
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // _documentURL, and informs the superclass of the change. 263 // _documentURL, and informs the superclass of the change.
243 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; 264 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL;
244 265
245 // Returns new autoreleased instance of WKUserContentController which has 266 // Returns new autoreleased instance of WKUserContentController which has
246 // early page script. 267 // early page script.
247 - (WKUserContentController*)createUserContentController; 268 - (WKUserContentController*)createUserContentController;
248 269
249 // Attempts to handle a script message. Returns YES on success, NO otherwise. 270 // Attempts to handle a script message. Returns YES on success, NO otherwise.
250 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; 271 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage;
251 272
273 // Verifies the given |cert| for the given |host| and calls |completionHandler|
274 // on completion. |completionHandler| can not be null and will be called
stuartmorgan 2015/08/20 20:42:21 cannot
Eugene But (OOO till 7-30) 2015/08/20 22:03:52 Done.
275 // asynchronously on the main thread.
276 - (void)verifyCert:(const scoped_refptr<net::X509Certificate>&)cert
277 forHost:(NSString*)host
278 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler;
279
252 // Used to decide whether a load that generates errors with the 280 // Used to decide whether a load that generates errors with the
253 // NSURLErrorCancelled code should be cancelled. 281 // NSURLErrorCancelled code should be cancelled.
254 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; 282 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error;
255 283
256 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 284 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
257 // Called when WKWebView estimatedProgress has been changed. 285 // Called when WKWebView estimatedProgress has been changed.
258 - (void)webViewEstimatedProgressDidChange; 286 - (void)webViewEstimatedProgressDidChange;
259 287
260 // Called when WKWebView certificateChain or hasOnlySecureContent property has 288 // Called when WKWebView certificateChain or hasOnlySecureContent property has
261 // changed. 289 // changed.
262 - (void)webViewSecurityFeaturesDidChange; 290 - (void)webViewSecurityFeaturesDidChange;
263 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 291 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
264 292
265 // Called when WKWebView loading state has been changed. 293 // Called when WKWebView loading state has been changed.
266 - (void)webViewLoadingStateDidChange; 294 - (void)webViewLoadingStateDidChange;
267 295
268 // Called when WKWebView title has been changed. 296 // Called when WKWebView title has been changed.
269 - (void)webViewTitleDidChange; 297 - (void)webViewTitleDidChange;
270 298
271 // Called when WKWebView URL has been changed. 299 // Called when WKWebView URL has been changed.
272 - (void)webViewURLDidChange; 300 - (void)webViewURLDidChange;
273 301
274 @end 302 @end
275 303
276 @implementation CRWWKWebViewWebController 304 @implementation CRWWKWebViewWebController
277 305
278 #pragma mark CRWWebController public methods 306 #pragma mark CRWWebController public methods
279 307
280 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState { 308 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState {
281 return [super initWithWebState:webState.Pass()]; 309 DCHECK(webState);
310 web::BrowserState* browserState = webState->GetBrowserState();
311 self = [super initWithWebState:webState.Pass()];
312 if (self) {
313 _contextGetter = browserState->GetRequestContext();
314 }
315 return self;
282 } 316 }
283 317
284 - (BOOL)keyboardDisplayRequiresUserAction { 318 - (BOOL)keyboardDisplayRequiresUserAction {
285 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment 319 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment
286 // in protected header. 320 // in protected header.
287 NOTIMPLEMENTED(); 321 NOTIMPLEMENTED();
288 return NO; 322 return NO;
289 } 323 }
290 324
291 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction { 325 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction {
(...skipping 21 matching lines...) Expand all
313 [super terminateNetworkActivity]; 347 [super terminateNetworkActivity];
314 } 348 }
315 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 349 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
316 350
317 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy { 351 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy {
318 // TODO(eugenebut): implement dialogs/windows suppression using 352 // TODO(eugenebut): implement dialogs/windows suppression using
319 // WKNavigationDelegate methods where possible. 353 // WKNavigationDelegate methods where possible.
320 [super setPageDialogOpenPolicy:policy]; 354 [super setPageDialogOpenPolicy:policy];
321 } 355 }
322 356
357 - (void)close {
358 // _certVerifier must be deleted on the same thread where it was created.
359 if (_certVerifier) {
360 web::WebThread::DeleteSoon(web::WebThread::IO, FROM_HERE,
361 _certVerifier.release());
362 }
363 [super close];
364 }
365
323 #pragma mark - 366 #pragma mark -
324 #pragma mark Testing-Only Methods 367 #pragma mark Testing-Only Methods
325 368
326 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { 369 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView {
327 [super injectWebViewContentView:webViewContentView]; 370 [super injectWebViewContentView:webViewContentView];
328 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; 371 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)];
329 } 372 }
330 373
331 #pragma mark - Protected property implementations 374 #pragma mark - Protected property implementations
332 375
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 615 }
573 616
574 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 617 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
575 - (int)certGroupID { 618 - (int)certGroupID {
576 DCHECK(self.webStateImpl); 619 DCHECK(self.webStateImpl);
577 // Request tracker IDs are used as certificate groups. 620 // Request tracker IDs are used as certificate groups.
578 return self.webStateImpl->GetRequestTracker()->identifier(); 621 return self.webStateImpl->GetRequestTracker()->identifier();
579 } 622 }
580 #endif 623 #endif
581 624
625 - (int)certVerifyFlags {
626 DCHECK(web::WebThread::CurrentlyOn(web::WebThread::IO));
627 DCHECK(_contextGetter);
628 net::URLRequestContext* context = _contextGetter->GetURLRequestContext();
629 DCHECK(context);
630 net::SSLConfigService* SSLConfigService = context->ssl_config_service();
631 DCHECK(SSLConfigService);
632 net::SSLConfig config;
633 SSLConfigService->GetSSLConfig(&config);
634 return config.GetCertVerifyFlags();
635 }
636
637 - (web::CertVerifierBlockAdapter*)certVerifier {
638 DCHECK(web::WebThread::CurrentlyOn(web::WebThread::IO));
639 if (!_certVerifier) {
640 DCHECK(_contextGetter);
641 net::URLRequestContext* context = _contextGetter->GetURLRequestContext();
642 DCHECK(context);
643 _certVerifier.reset(new web::CertVerifierBlockAdapter(
644 context->cert_verifier(), context->net_log()));
645 }
646 return _certVerifier.get();
647 }
648
582 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { 649 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider {
583 DCHECK(self.webStateImpl); 650 DCHECK(self.webStateImpl);
584 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); 651 web::BrowserState* browserState = self.webStateImpl->GetBrowserState();
585 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); 652 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState);
586 } 653 }
587 654
588 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { 655 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config {
589 if (!_wkWebView) { 656 if (!_wkWebView) {
590 // Use a separate userContentController for each web view. 657 // Use a separate userContentController for each web view.
591 // WKUserContentController does not allow adding multiple script message 658 // WKUserContentController does not allow adding multiple script message
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 (*handlers)["window.history.willChangeState"] = 1012 (*handlers)["window.history.willChangeState"] =
946 @selector(handleWindowHistoryWillChangeStateMessage:context:); 1013 @selector(handleWindowHistoryWillChangeStateMessage:context:);
947 }); 1014 });
948 DCHECK(handlers); 1015 DCHECK(handlers);
949 auto iter = handlers->find(command); 1016 auto iter = handlers->find(command);
950 return iter != handlers->end() 1017 return iter != handlers->end()
951 ? iter->second 1018 ? iter->second
952 : [super selectorToHandleJavaScriptCommand:command]; 1019 : [super selectorToHandleJavaScriptCommand:command];
953 } 1020 }
954 1021
1022 - (void)verifyCert:(const scoped_refptr<net::X509Certificate>&)cert
1023 forHost:(NSString*)host
1024 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler {
1025 DCHECK(completionHandler);
1026 __block scoped_refptr<net::X509Certificate> blockCert = cert;
1027 web::WebThread::PostTask(
1028 web::WebThread::IO, FROM_HERE, base::BindBlock(^{
1029 // WeakNSObject does not work across different threads, hence this block
1030 // retains self.
1031 if ([self isBeingDestroyed]) {
1032 completionHandler(net::CertVerifyResult(), net::ERR_FAILED);
1033 return;
1034 }
1035
1036 web::CertVerifierBlockAdapter::Params params(
1037 blockCert.Pass(), base::SysNSStringToUTF8(host));
1038 params.flags = self.certVerifyFlags;
1039 params.crl_set = net::SSLConfigService::GetCRLSet();
1040 // OCSP response is not provided by iOS API.
1041
1042 self.certVerifier->Verify(params,
1043 ^(net::CertVerifyResult result, int error) {
1044 dispatch_async(dispatch_get_main_queue(), ^{
1045 completionHandler(result, error);
1046 });
1047 });
1048 }));
1049 }
1050
955 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { 1051 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error {
956 DCHECK_EQ(error.code, NSURLErrorCancelled); 1052 DCHECK_EQ(error.code, NSURLErrorCancelled);
957 // Do not abort the load if it is for an app specific URL, as such errors 1053 // Do not abort the load if it is for an app specific URL, as such errors
958 // are produced during the app specific URL load process. 1054 // are produced during the app specific URL load process.
959 const GURL errorURL = 1055 const GURL errorURL =
960 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); 1056 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]);
961 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) 1057 if (web::GetWebClient()->IsAppSpecificURL(errorURL))
962 return NO; 1058 return NO;
963 // Don't abort NSURLErrorCancelled errors originating from navigation 1059 // Don't abort NSURLErrorCancelled errors originating from navigation
964 // as the WKWebView will automatically retry these loads. 1060 // as the WKWebView will automatically retry these loads.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 withError:(NSError *)error { 1379 withError:(NSError *)error {
1284 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) 1380 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION)
1285 inMainFrame:YES]; 1381 inMainFrame:YES];
1286 } 1382 }
1287 1383
1288 - (void)webView:(WKWebView *)webView 1384 - (void)webView:(WKWebView *)webView
1289 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 1385 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
1290 completionHandler: 1386 completionHandler:
1291 (void (^)(NSURLSessionAuthChallengeDisposition disposition, 1387 (void (^)(NSURLSessionAuthChallengeDisposition disposition,
1292 NSURLCredential *credential))completionHandler { 1388 NSURLCredential *credential))completionHandler {
1293 NOTIMPLEMENTED(); 1389 if (![challenge.protectionSpace.authenticationMethod
1294 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); 1390 isEqual:NSURLAuthenticationMethodServerTrust]) {
1391 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
1392 return;
1393 }
1394
1395 SecTrustRef trust = challenge.protectionSpace.serverTrust;
1396 scoped_refptr<net::X509Certificate> cert = web::CreateCertFromTrust(trust);
1397 [self verifyCert:cert
1398 forHost:challenge.protectionSpace.host
1399 completionHandler:^(net::CertVerifyResult, int error) {
1400 if (error == net::OK) {
1401 // Cert is valid.
1402 } else {
1403 // Cert is invalid or its state is unknown.
1404 }
1405 NOTIMPLEMENTED();
1406 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil);
1407 }];
1295 } 1408 }
1296 1409
1297 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { 1410 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView {
1298 [self webViewWebProcessDidCrash]; 1411 [self webViewWebProcessDidCrash];
1299 } 1412 }
1300 1413
1301 #pragma mark WKUIDelegate Methods 1414 #pragma mark WKUIDelegate Methods
1302 1415
1303 - (WKWebView*)webView:(WKWebView*)webView 1416 - (WKWebView*)webView:(WKWebView*)webView
1304 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration 1417 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 placeholderText:defaultText 1496 placeholderText:defaultText
1384 requestURL: 1497 requestURL:
1385 net::GURLWithNSURL(frame.request.URL) 1498 net::GURLWithNSURL(frame.request.URL)
1386 completionHandler:completionHandler]; 1499 completionHandler:completionHandler];
1387 } else if (completionHandler) { 1500 } else if (completionHandler) {
1388 completionHandler(nil); 1501 completionHandler(nil);
1389 } 1502 }
1390 } 1503 }
1391 1504
1392 @end 1505 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698