OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 [self.nativeController setDelegate:self]; | 1924 [self.nativeController setDelegate:self]; |
1925 } | 1925 } |
1926 } | 1926 } |
1927 } | 1927 } |
1928 | 1928 |
1929 - (void)loadErrorInNativeView:(NSError*)error { | 1929 - (void)loadErrorInNativeView:(NSError*)error { |
1930 [self removeWebViewAllowingCachedReconstruction:NO]; | 1930 [self removeWebViewAllowingCachedReconstruction:NO]; |
1931 | 1931 |
1932 const GURL currentUrl = [self currentNavigationURL]; | 1932 const GURL currentUrl = [self currentNavigationURL]; |
1933 | 1933 |
1934 error = web::NetErrorFromError(error); | 1934 if (web::IsWKWebViewSSLCertError(error)) { |
| 1935 // This could happen only if certificate is absent or could not be parsed. |
| 1936 error = web::NetErrorFromError(error, net::ERR_SSL_SERVER_CERT_BAD_FORMAT); |
| 1937 #if defined(DEBUG) |
| 1938 net::SSLInfo info; |
| 1939 web::GetSSLInfoFromWKWebViewSSLCertError(error, &info); |
| 1940 CHECK(!error.cert); |
| 1941 #endif |
| 1942 } else { |
| 1943 error = web::NetErrorFromError(error); |
| 1944 } |
| 1945 |
1935 BOOL isPost = [self isCurrentNavigationItemPOST]; | 1946 BOOL isPost = [self isCurrentNavigationItemPOST]; |
1936 [self setNativeController:[_nativeProvider controllerForURL:currentUrl | 1947 [self setNativeController:[_nativeProvider controllerForURL:currentUrl |
1937 withError:error | 1948 withError:error |
1938 isPost:isPost]]; | 1949 isPost:isPost]]; |
1939 [self loadNativeViewWithSuccess:NO]; | 1950 [self loadNativeViewWithSuccess:NO]; |
1940 } | 1951 } |
1941 | 1952 |
1942 // Load the current URL in a native controller, retrieved from the native | 1953 // Load the current URL in a native controller, retrieved from the native |
1943 // provider. Call |loadNativeViewWithSuccess:YES| to load the native controller. | 1954 // provider. Call |loadNativeViewWithSuccess:YES| to load the native controller. |
1944 - (void)loadCurrentURLInNativeView { | 1955 - (void)loadCurrentURLInNativeView { |
(...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4475 CHECK(web::IsWKWebViewSSLCertError(error)); | 4486 CHECK(web::IsWKWebViewSSLCertError(error)); |
4476 | 4487 |
4477 net::SSLInfo info; | 4488 net::SSLInfo info; |
4478 web::GetSSLInfoFromWKWebViewSSLCertError(error, &info); | 4489 web::GetSSLInfoFromWKWebViewSSLCertError(error, &info); |
4479 | 4490 |
4480 // TODO(crbug.com/602298): Remove |status| variable, once |presentSSLError:| | 4491 // TODO(crbug.com/602298): Remove |status| variable, once |presentSSLError:| |
4481 // callback is dropped. | 4492 // callback is dropped. |
4482 web::SSLStatus status; | 4493 web::SSLStatus status; |
4483 status.security_style = web::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 4494 status.security_style = web::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
4484 status.cert_status = info.cert_status; | 4495 status.cert_status = info.cert_status; |
4485 // |info.cert| can be null if certChain in NSError is empty or can not be | 4496 if (!info.cert) { |
4486 // parsed. | 4497 // |info.cert| can be null if certChain in NSError is empty or can not be |
4487 if (info.cert) { | 4498 // parsed, in this case do not ask delegate if error should be allowed, it |
4488 status.cert_id = web::CertStore::GetInstance()->StoreCert(info.cert.get(), | 4499 // should not be. |
4489 self.certGroupID); | 4500 [self handleLoadError:error inMainFrame:YES]; |
| 4501 return; |
4490 } | 4502 } |
4491 | 4503 |
| 4504 status.cert_id = web::CertStore::GetInstance()->StoreCert(info.cert.get(), |
| 4505 self.certGroupID); |
| 4506 |
4492 // Retrieve verification results from _certVerificationErrors cache to avoid | 4507 // Retrieve verification results from _certVerificationErrors cache to avoid |
4493 // unnecessary recalculations. Verification results are cached for the leaf | 4508 // unnecessary recalculations. Verification results are cached for the leaf |
4494 // cert, because the cert chain in |didReceiveAuthenticationChallenge:| is | 4509 // cert, because the cert chain in |didReceiveAuthenticationChallenge:| is |
4495 // the OS constructed chain, while |chain| is the chain from the server. | 4510 // the OS constructed chain, while |chain| is the chain from the server. |
4496 NSArray* chain = error.userInfo[web::kNSErrorPeerCertificateChainKey]; | 4511 NSArray* chain = error.userInfo[web::kNSErrorPeerCertificateChainKey]; |
4497 NSURL* requestURL = error.userInfo[web::kNSErrorFailingURLKey]; | 4512 NSURL* requestURL = error.userInfo[web::kNSErrorFailingURLKey]; |
4498 NSString* host = [requestURL host]; | 4513 NSString* host = [requestURL host]; |
4499 scoped_refptr<net::X509Certificate> leafCert; | 4514 scoped_refptr<net::X509Certificate> leafCert; |
4500 BOOL recoverable = NO; | 4515 BOOL recoverable = NO; |
4501 if (chain.count && host.length) { | 4516 if (chain.count && host.length) { |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5606 } | 5621 } |
5607 | 5622 |
5608 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5623 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5609 } | 5624 } |
5610 | 5625 |
5611 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5626 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5612 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5627 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5613 } | 5628 } |
5614 | 5629 |
5615 @end | 5630 @end |
OLD | NEW |