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

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: Fixed threading bugs Created 5 years, 3 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
« no previous file with comments | « ios/web/public/test/test_browser_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "url/url_constants.h" 49 #include "url/url_constants.h"
42 50
43 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 51 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
44 #include "ios/web/public/cert_store.h" 52 #include "ios/web/public/cert_store.h"
45 #include "ios/web/public/navigation_item.h" 53 #include "ios/web/public/navigation_item.h"
46 #include "ios/web/public/ssl_status.h" 54 #include "ios/web/public/ssl_status.h"
47 #import "ios/web/web_state/wk_web_view_security_util.h" 55 #import "ios/web/web_state/wk_web_view_security_util.h"
48 #include "net/cert/x509_certificate.h" 56 #include "net/cert/x509_certificate.h"
49 #include "net/ssl/ssl_info.h" 57 #include "net/ssl/ssl_info.h"
50 #endif 58 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 scoped_ptr<WKNavigationType> _pendingNavigationTypeForMainFrame; 136 scoped_ptr<WKNavigationType> _pendingNavigationTypeForMainFrame;
129 137
130 // Whether the web page is currently performing window.history.pushState or 138 // Whether the web page is currently performing window.history.pushState or
131 // window.history.replaceState 139 // window.history.replaceState
132 // Set to YES on window.history.willChangeState message. To NO on 140 // Set to YES on window.history.willChangeState message. To NO on
133 // window.history.didPushState or window.history.didReplaceState. 141 // window.history.didPushState or window.history.didReplaceState.
134 BOOL _changingHistoryState; 142 BOOL _changingHistoryState;
135 143
136 // CRWWebUIManager object for loading WebUI pages. 144 // CRWWebUIManager object for loading WebUI pages.
137 base::scoped_nsobject<CRWWebUIManager> _webUIManager; 145 base::scoped_nsobject<CRWWebUIManager> _webUIManager;
146
147 // Cert verification object which wraps |net::CertVerifier|. Must be created,
148 // used and destroyed on IO Thread.
149 scoped_ptr<web::CertVerifierBlockAdapter> _certVerifier;
150
151 // URLRequestContextGetter for obtaining net layer objects.
152 net::URLRequestContextGetter* _contextGetter;
138 } 153 }
139 154
140 // Response's MIME type of the last known navigation. 155 // Response's MIME type of the last known navigation.
141 @property(nonatomic, copy) NSString* documentMIMEType; 156 @property(nonatomic, copy) NSString* documentMIMEType;
142 157
143 // Dictionary where keys are the names of WKWebView properties and values are 158 // Dictionary where keys are the names of WKWebView properties and values are
144 // selector names which should be called when a corresponding property has 159 // selector names which should be called when a corresponding property has
145 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that 160 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that
146 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is 161 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is
147 // changed. 162 // changed.
148 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers; 163 @property(nonatomic, readonly) NSDictionary* wkWebViewObservers;
149 164
150 // Returns the string to use as the request group ID in the user agent. Returns 165 // Returns the string to use as the request group ID in the user agent. Returns
151 // nil unless the network stack is enabled. 166 // nil unless the network stack is enabled.
152 @property(nonatomic, readonly) NSString* requestGroupIDForUserAgent; 167 @property(nonatomic, readonly) NSString* requestGroupIDForUserAgent;
153 168
154 // Activity indicator group ID for this web controller. 169 // Activity indicator group ID for this web controller.
155 @property(nonatomic, readonly) NSString* activityIndicatorGroupID; 170 @property(nonatomic, readonly) NSString* activityIndicatorGroupID;
156 171
157 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 172 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
158 // Identifier used for storing and retrieving certificates. 173 // Identifier used for storing and retrieving certificates.
159 @property(nonatomic, readonly) int certGroupID; 174 @property(nonatomic, readonly) int certGroupID;
160 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 175 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
161 176
177 // Cert verification flags. Must be used on IO Thread.
178 @property(nonatomic, readonly) int certVerifyFlags;
179
180 // Creates _certVerifier object on IO thread.
181 - (void)createCertVerifier;
182
162 // Returns the WKWebViewConfigurationProvider associated with the web 183 // Returns the WKWebViewConfigurationProvider associated with the web
163 // controller's BrowserState. 184 // controller's BrowserState.
164 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider; 185 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider;
165 186
166 // Creates a web view with given |config|. No-op if web view is already created. 187 // Creates a web view with given |config|. No-op if web view is already created.
167 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; 188 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config;
168 189
169 // Returns a new autoreleased web view created with given configuration. 190 // Returns a new autoreleased web view created with given configuration.
170 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config; 191 - (WKWebView*)createWebViewWithConfiguration:(WKWebViewConfiguration*)config;
171 192
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // _documentURL, and informs the superclass of the change. 268 // _documentURL, and informs the superclass of the change.
248 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL; 269 - (void)URLDidChangeWithoutDocumentChange:(const GURL&)URL;
249 270
250 // Returns new autoreleased instance of WKUserContentController which has 271 // Returns new autoreleased instance of WKUserContentController which has
251 // early page script. 272 // early page script.
252 - (WKUserContentController*)createUserContentController; 273 - (WKUserContentController*)createUserContentController;
253 274
254 // Attempts to handle a script message. Returns YES on success, NO otherwise. 275 // Attempts to handle a script message. Returns YES on success, NO otherwise.
255 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage; 276 - (BOOL)respondToWKScriptMessage:(WKScriptMessage*)scriptMessage;
256 277
278 // Verifies the given |cert| for the given |host| and calls |completionHandler|
279 // on completion. |completionHandler| cannot be null and will be called
280 // asynchronously on the main thread.
281 - (void)verifyCert:(const scoped_refptr<net::X509Certificate>&)cert
282 forHost:(NSString*)host
283 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler;
284
257 // Used to decide whether a load that generates errors with the 285 // Used to decide whether a load that generates errors with the
258 // NSURLErrorCancelled code should be cancelled. 286 // NSURLErrorCancelled code should be cancelled.
259 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error; 287 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error;
260 288
261 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 289 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
262 // Called when WKWebView estimatedProgress has been changed. 290 // Called when WKWebView estimatedProgress has been changed.
263 - (void)webViewEstimatedProgressDidChange; 291 - (void)webViewEstimatedProgressDidChange;
264 292
265 // Called when WKWebView certificateChain or hasOnlySecureContent property has 293 // Called when WKWebView certificateChain or hasOnlySecureContent property has
266 // changed. 294 // changed.
267 - (void)webViewSecurityFeaturesDidChange; 295 - (void)webViewSecurityFeaturesDidChange;
268 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 296 #endif // !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
269 297
270 // Called when WKWebView loading state has been changed. 298 // Called when WKWebView loading state has been changed.
271 - (void)webViewLoadingStateDidChange; 299 - (void)webViewLoadingStateDidChange;
272 300
273 // Called when WKWebView title has been changed. 301 // Called when WKWebView title has been changed.
274 - (void)webViewTitleDidChange; 302 - (void)webViewTitleDidChange;
275 303
276 // Called when WKWebView URL has been changed. 304 // Called when WKWebView URL has been changed.
277 - (void)webViewURLDidChange; 305 - (void)webViewURLDidChange;
278 306
279 @end 307 @end
280 308
281 @implementation CRWWKWebViewWebController 309 @implementation CRWWKWebViewWebController
282 310
283 #pragma mark CRWWebController public methods 311 #pragma mark CRWWebController public methods
284 312
285 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState { 313 - (instancetype)initWithWebState:(scoped_ptr<web::WebStateImpl>)webState {
286 return [super initWithWebState:webState.Pass()]; 314 DCHECK(webState);
315 web::BrowserState* browserState = webState->GetBrowserState();
316 self = [super initWithWebState:webState.Pass()];
317 if (self) {
318 _contextGetter = browserState->GetRequestContext();
319 [self createCertVerifier];
320 }
321 return self;
287 } 322 }
288 323
289 - (BOOL)keyboardDisplayRequiresUserAction { 324 - (BOOL)keyboardDisplayRequiresUserAction {
290 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment 325 // TODO(stuartmorgan): Find out whether YES or NO is correct; see comment
291 // in protected header. 326 // in protected header.
292 NOTIMPLEMENTED(); 327 NOTIMPLEMENTED();
293 return NO; 328 return NO;
294 } 329 }
295 330
296 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction { 331 - (void)setKeyboardDisplayRequiresUserAction:(BOOL)requiresUserAction {
(...skipping 21 matching lines...) Expand all
318 [super terminateNetworkActivity]; 353 [super terminateNetworkActivity];
319 } 354 }
320 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 355 #endif // #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
321 356
322 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy { 357 - (void)setPageDialogOpenPolicy:(web::PageDialogOpenPolicy)policy {
323 // TODO(eugenebut): implement dialogs/windows suppression using 358 // TODO(eugenebut): implement dialogs/windows suppression using
324 // WKNavigationDelegate methods where possible. 359 // WKNavigationDelegate methods where possible.
325 [super setPageDialogOpenPolicy:policy]; 360 [super setPageDialogOpenPolicy:policy];
326 } 361 }
327 362
363 - (void)close {
364 // _certVerifier must be accessed only on IO thread.
365 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{
366 _certVerifier.reset();
367 // Make sure that WebController is deallocated on the main thread.
368 [[self retain] autorelease];
stuartmorgan 2015/08/24 17:14:19 I don't see how this does what the comment says. D
Eugene But (OOO till 7-30) 2015/08/24 18:56:50 This block will be destroyed on IO thread, so in c
stuartmorgan 2015/08/24 19:55:24 I'm 99.9% sure this is not true; that would mean a
Eugene But (OOO till 7-30) 2015/08/24 20:05:31 I think |autorelease| is type-agnostic. Anyhow it
369 }));
370 [super close];
371 }
372
328 #pragma mark - 373 #pragma mark -
329 #pragma mark Testing-Only Methods 374 #pragma mark Testing-Only Methods
330 375
331 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView { 376 - (void)injectWebViewContentView:(CRWWebViewContentView*)webViewContentView {
332 [super injectWebViewContentView:webViewContentView]; 377 [super injectWebViewContentView:webViewContentView];
333 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)]; 378 [self setWebView:static_cast<WKWebView*>(webViewContentView.webView)];
334 } 379 }
335 380
336 #pragma mark - Protected property implementations 381 #pragma mark - Protected property implementations
337 382
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 630 }
586 631
587 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW) 632 #if !defined(ENABLE_CHROME_NET_STACK_FOR_WKWEBVIEW)
588 - (int)certGroupID { 633 - (int)certGroupID {
589 DCHECK(self.webStateImpl); 634 DCHECK(self.webStateImpl);
590 // Request tracker IDs are used as certificate groups. 635 // Request tracker IDs are used as certificate groups.
591 return self.webStateImpl->GetRequestTracker()->identifier(); 636 return self.webStateImpl->GetRequestTracker()->identifier();
592 } 637 }
593 #endif 638 #endif
594 639
640 - (int)certVerifyFlags {
641 DCHECK(web::WebThread::CurrentlyOn(web::WebThread::IO));
642 DCHECK(_contextGetter);
643 net::URLRequestContext* context = _contextGetter->GetURLRequestContext();
stuartmorgan 2015/08/24 17:14:19 Since there was a fair amount of discussion, it's
Eugene But (OOO till 7-30) 2015/08/24 18:56:50 Done.
644 DCHECK(context);
645 net::SSLConfigService* SSLConfigService = context->ssl_config_service();
646 DCHECK(SSLConfigService);
647 net::SSLConfig config;
648 SSLConfigService->GetSSLConfig(&config);
649 return config.GetCertVerifyFlags();
650 }
651
652 - (void)createCertVerifier {
653 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, base::BindBlock(^{
654 net::URLRequestContext* context = _contextGetter->GetURLRequestContext();
655 _certVerifier.reset(new web::CertVerifierBlockAdapter(
656 context->cert_verifier(), context->net_log()));
657 }));
658 }
659
595 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider { 660 - (web::WKWebViewConfigurationProvider&)webViewConfigurationProvider {
596 DCHECK(self.webStateImpl); 661 DCHECK(self.webStateImpl);
597 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); 662 web::BrowserState* browserState = self.webStateImpl->GetBrowserState();
598 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState); 663 return web::WKWebViewConfigurationProvider::FromBrowserState(browserState);
599 } 664 }
600 665
601 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { 666 - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config {
602 if (!_wkWebView) { 667 if (!_wkWebView) {
603 // Use a separate userContentController for each web view. 668 // Use a separate userContentController for each web view.
604 // WKUserContentController does not allow adding multiple script message 669 // WKUserContentController does not allow adding multiple script message
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 (*handlers)["window.history.willChangeState"] = 1021 (*handlers)["window.history.willChangeState"] =
957 @selector(handleWindowHistoryWillChangeStateMessage:context:); 1022 @selector(handleWindowHistoryWillChangeStateMessage:context:);
958 }); 1023 });
959 DCHECK(handlers); 1024 DCHECK(handlers);
960 auto iter = handlers->find(command); 1025 auto iter = handlers->find(command);
961 return iter != handlers->end() 1026 return iter != handlers->end()
962 ? iter->second 1027 ? iter->second
963 : [super selectorToHandleJavaScriptCommand:command]; 1028 : [super selectorToHandleJavaScriptCommand:command];
964 } 1029 }
965 1030
1031 - (void)verifyCert:(const scoped_refptr<net::X509Certificate>&)cert
1032 forHost:(NSString*)host
1033 completionHandler:(void (^)(net::CertVerifyResult, int))completionHandler {
1034 DCHECK(completionHandler);
1035 __block scoped_refptr<net::X509Certificate> blockCert = cert;
1036 web::WebThread::PostTask(
1037 web::WebThread::IO, FROM_HERE, base::BindBlock(^{
1038 // WeakNSObject does not work across different threads, hence this block
1039 // retains self.
1040 if (!_certVerifier) {
1041 completionHandler(net::CertVerifyResult(), net::ERR_FAILED);
davidben 2015/08/24 17:43:31 This needs a dispatch_async, etc., right?
Eugene But (OOO till 7-30) 2015/08/24 18:56:50 D'oh. Thanks for catching that. I see one concret
1042 return;
1043 }
1044
1045 web::CertVerifierBlockAdapter::Params params(
1046 blockCert.Pass(), base::SysNSStringToUTF8(host));
1047 params.flags = self.certVerifyFlags;
1048 params.crl_set = net::SSLConfigService::GetCRLSet();
1049 // OCSP response is not provided by iOS API.
1050
1051 _certVerifier->Verify(params,
1052 ^(net::CertVerifyResult result, int error) {
1053 dispatch_async(dispatch_get_main_queue(), ^{
1054 completionHandler(result, error);
1055 });
1056 });
1057 }));
1058 }
1059
966 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error { 1060 - (BOOL)shouldAbortLoadForCancelledError:(NSError*)error {
967 DCHECK_EQ(error.code, NSURLErrorCancelled); 1061 DCHECK_EQ(error.code, NSURLErrorCancelled);
968 // Do not abort the load if it is for an app specific URL, as such errors 1062 // Do not abort the load if it is for an app specific URL, as such errors
969 // are produced during the app specific URL load process. 1063 // are produced during the app specific URL load process.
970 const GURL errorURL = 1064 const GURL errorURL =
971 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]); 1065 net::GURLWithNSURL(error.userInfo[NSURLErrorFailingURLErrorKey]);
972 if (web::GetWebClient()->IsAppSpecificURL(errorURL)) 1066 if (web::GetWebClient()->IsAppSpecificURL(errorURL))
973 return NO; 1067 return NO;
974 // Don't abort NSURLErrorCancelled errors originating from navigation 1068 // Don't abort NSURLErrorCancelled errors originating from navigation
975 // as the WKWebView will automatically retry these loads. 1069 // as the WKWebView will automatically retry these loads.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 withError:(NSError *)error { 1395 withError:(NSError *)error {
1302 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION) 1396 [self handleLoadError:WKWebViewErrorWithSource(error, NAVIGATION)
1303 inMainFrame:YES]; 1397 inMainFrame:YES];
1304 } 1398 }
1305 1399
1306 - (void)webView:(WKWebView *)webView 1400 - (void)webView:(WKWebView *)webView
1307 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 1401 didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
1308 completionHandler: 1402 completionHandler:
1309 (void (^)(NSURLSessionAuthChallengeDisposition disposition, 1403 (void (^)(NSURLSessionAuthChallengeDisposition disposition,
1310 NSURLCredential *credential))completionHandler { 1404 NSURLCredential *credential))completionHandler {
1311 NOTIMPLEMENTED(); 1405 if (![challenge.protectionSpace.authenticationMethod
1312 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); 1406 isEqual:NSURLAuthenticationMethodServerTrust]) {
1407 completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
1408 return;
1409 }
1410
1411 SecTrustRef trust = challenge.protectionSpace.serverTrust;
1412 scoped_refptr<net::X509Certificate> cert = web::CreateCertFromTrust(trust);
1413 [self verifyCert:cert
1414 forHost:challenge.protectionSpace.host
1415 completionHandler:^(net::CertVerifyResult, int error) {
1416 if (error == net::OK) {
1417 // Cert is valid.
1418 } else {
1419 // Cert is invalid or its state is unknown.
1420 }
1421 NOTIMPLEMENTED();
1422 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil);
1423 }];
1313 } 1424 }
1314 1425
1315 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { 1426 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView {
1316 [self webViewWebProcessDidCrash]; 1427 [self webViewWebProcessDidCrash];
1317 } 1428 }
1318 1429
1319 #pragma mark WKUIDelegate Methods 1430 #pragma mark WKUIDelegate Methods
1320 1431
1321 - (WKWebView*)webView:(WKWebView*)webView 1432 - (WKWebView*)webView:(WKWebView*)webView
1322 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration 1433 createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 placeholderText:defaultText 1512 placeholderText:defaultText
1402 requestURL: 1513 requestURL:
1403 net::GURLWithNSURL(frame.request.URL) 1514 net::GURLWithNSURL(frame.request.URL)
1404 completionHandler:completionHandler]; 1515 completionHandler:completionHandler];
1405 } else if (completionHandler) { 1516 } else if (completionHandler) {
1406 completionHandler(nil); 1517 completionHandler(nil);
1407 } 1518 }
1408 } 1519 }
1409 1520
1410 @end 1521 @end
OLDNEW
« no previous file with comments | « ios/web/public/test/test_browser_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698