| 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 4466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4477 } | 4477 } |
| 4478 | 4478 |
| 4479 if (!_SSLStatusUpdater) { | 4479 if (!_SSLStatusUpdater) { |
| 4480 _SSLStatusUpdater.reset([[CRWSSLStatusUpdater alloc] | 4480 _SSLStatusUpdater.reset([[CRWSSLStatusUpdater alloc] |
| 4481 initWithDataSource:self | 4481 initWithDataSource:self |
| 4482 navigationManager:navManager | 4482 navigationManager:navManager |
| 4483 certGroupID:self.certGroupID]); | 4483 certGroupID:self.certGroupID]); |
| 4484 [_SSLStatusUpdater setDelegate:self]; | 4484 [_SSLStatusUpdater setDelegate:self]; |
| 4485 } | 4485 } |
| 4486 NSString* host = base::SysUTF8ToNSString(_documentURL.host()); | 4486 NSString* host = base::SysUTF8ToNSString(_documentURL.host()); |
| 4487 NSArray* certChain = [_webView certificateChain]; | |
| 4488 BOOL hasOnlySecureContent = [_webView hasOnlySecureContent]; | 4487 BOOL hasOnlySecureContent = [_webView hasOnlySecureContent]; |
| 4488 base::ScopedCFTypeRef<SecTrustRef> trust; |
| 4489 // TODO(crbug.com/628696): Remove these guards after moving to iOS10 SDK. |
| 4490 #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 |
| 4491 if (base::ios::IsRunningOnIOS10OrLater()) { |
| 4492 trust.reset([_webView serverTrust], base::scoped_policy::RETAIN); |
| 4493 } else { |
| 4494 trust = web::CreateServerTrustFromChain([_webView certificateChain], host); |
| 4495 } |
| 4496 #else |
| 4497 trust = web::CreateServerTrustFromChain([_webView certificateChain], host); |
| 4498 #endif |
| 4499 |
| 4489 [_SSLStatusUpdater updateSSLStatusForNavigationItem:currentNavItem | 4500 [_SSLStatusUpdater updateSSLStatusForNavigationItem:currentNavItem |
| 4490 withCertHost:host | 4501 withCertHost:host |
| 4491 certChain:certChain | 4502 trust:std::move(trust) |
| 4492 hasOnlySecureContent:hasOnlySecureContent]; | 4503 hasOnlySecureContent:hasOnlySecureContent]; |
| 4493 } | 4504 } |
| 4494 | 4505 |
| 4495 - (void)didUpdateSSLStatusForCurrentNavigationItem { | 4506 - (void)didUpdateSSLStatusForCurrentNavigationItem { |
| 4496 if ([_delegate respondsToSelector: | 4507 if ([_delegate respondsToSelector: |
| 4497 @selector( | 4508 @selector( |
| 4498 webControllerDidUpdateSSLStatusForCurrentNavigationItem:)]) { | 4509 webControllerDidUpdateSSLStatusForCurrentNavigationItem:)]) { |
| 4499 [_delegate webControllerDidUpdateSSLStatusForCurrentNavigationItem:self]; | 4510 [_delegate webControllerDidUpdateSSLStatusForCurrentNavigationItem:self]; |
| 4500 } | 4511 } |
| 4501 } | 4512 } |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5255 | 5266 |
| 5256 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { | 5267 - (void)webViewWebContentProcessDidTerminate:(WKWebView*)webView { |
| 5257 _certVerificationErrors->Clear(); | 5268 _certVerificationErrors->Clear(); |
| 5258 [self webViewWebProcessDidCrash]; | 5269 [self webViewWebProcessDidCrash]; |
| 5259 } | 5270 } |
| 5260 | 5271 |
| 5261 #pragma mark - | 5272 #pragma mark - |
| 5262 #pragma mark CRWSSLStatusUpdater DataSource/Delegate Methods | 5273 #pragma mark CRWSSLStatusUpdater DataSource/Delegate Methods |
| 5263 | 5274 |
| 5264 - (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater | 5275 - (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater |
| 5265 querySSLStatusForCertChain:(NSArray*)certChain | 5276 querySSLStatusForTrust:(base::ScopedCFTypeRef<SecTrustRef>)trust |
| 5266 host:(NSString*)host | 5277 host:(NSString*)host |
| 5267 completionHandler:(StatusQueryHandler)completionHandler { | 5278 completionHandler:(StatusQueryHandler)completionHandler { |
| 5268 base::ScopedCFTypeRef<SecTrustRef> trust( | |
| 5269 web::CreateServerTrustFromChain(certChain, host)); | |
| 5270 [_certVerificationController querySSLStatusForTrust:std::move(trust) | 5279 [_certVerificationController querySSLStatusForTrust:std::move(trust) |
| 5271 host:host | 5280 host:host |
| 5272 completionHandler:completionHandler]; | 5281 completionHandler:completionHandler]; |
| 5273 } | 5282 } |
| 5274 | 5283 |
| 5275 - (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater | 5284 - (void)SSLStatusUpdater:(CRWSSLStatusUpdater*)SSLStatusUpdater |
| 5276 didChangeSSLStatusForNavigationItem:(web::NavigationItem*)navigationItem { | 5285 didChangeSSLStatusForNavigationItem:(web::NavigationItem*)navigationItem { |
| 5277 web::NavigationItem* currentNavigationItem = | 5286 web::NavigationItem* currentNavigationItem = |
| 5278 self.webState->GetNavigationManager()->GetLastCommittedItem(); | 5287 self.webState->GetNavigationManager()->GetLastCommittedItem(); |
| 5279 if (navigationItem == currentNavigationItem) { | 5288 if (navigationItem == currentNavigationItem) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5662 } | 5671 } |
| 5663 | 5672 |
| 5664 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5673 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5665 } | 5674 } |
| 5666 | 5675 |
| 5667 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5676 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5668 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5677 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5669 } | 5678 } |
| 5670 | 5679 |
| 5671 @end | 5680 @end |
| OLD | NEW |