| 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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 // DCHECK([contentView.scrollView isDescendantOfView:contentView]); | 1012 // DCHECK([contentView.scrollView isDescendantOfView:contentView]); |
| 1013 [_containerView displayTransientContent:contentView]; | 1013 [_containerView displayTransientContent:contentView]; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 - (id<CRWWebDelegate>)delegate { | 1016 - (id<CRWWebDelegate>)delegate { |
| 1017 return _delegate.get(); | 1017 return _delegate.get(); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 - (void)setDelegate:(id<CRWWebDelegate>)delegate { | 1020 - (void)setDelegate:(id<CRWWebDelegate>)delegate { |
| 1021 _delegate.reset(delegate); | 1021 _delegate.reset(delegate); |
| 1022 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { | 1022 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) |
| 1023 if ([_delegate respondsToSelector:@selector(webController:titleDidChange:)]) | 1023 [self.nativeController setDelegate:self]; |
| 1024 [self.nativeController setDelegate:self]; | |
| 1025 else | |
| 1026 [self.nativeController setDelegate:nil]; | |
| 1027 } | |
| 1028 } | 1024 } |
| 1029 | 1025 |
| 1030 - (void)dealloc { | 1026 - (void)dealloc { |
| 1031 DCHECK([NSThread isMainThread]); | 1027 DCHECK([NSThread isMainThread]); |
| 1032 DCHECK(_isBeingDestroyed); // 'close' must have been called already. | 1028 DCHECK(_isBeingDestroyed); // 'close' must have been called already. |
| 1033 DCHECK(!_webView); | 1029 DCHECK(!_webView); |
| 1034 // TODO(crbug.com/662860): Don't set the delegate to nil. | 1030 // TODO(crbug.com/662860): Don't set the delegate to nil. |
| 1035 [_containerView setDelegate:nil]; | 1031 [_containerView setDelegate:nil]; |
| 1036 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { | 1032 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { |
| 1037 [self.nativeController setDelegate:nil]; | 1033 [self.nativeController setDelegate:nil]; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 @"loading" : @"webViewLoadingStateDidChange", | 1075 @"loading" : @"webViewLoadingStateDidChange", |
| 1080 @"title" : @"webViewTitleDidChange", | 1076 @"title" : @"webViewTitleDidChange", |
| 1081 @"URL" : @"webViewURLDidChange", | 1077 @"URL" : @"webViewURLDidChange", |
| 1082 }]; | 1078 }]; |
| 1083 | 1079 |
| 1084 return result; | 1080 return result; |
| 1085 } | 1081 } |
| 1086 | 1082 |
| 1087 // NativeControllerDelegate method, called to inform that title has changed. | 1083 // NativeControllerDelegate method, called to inform that title has changed. |
| 1088 - (void)nativeContent:(id)content titleDidChange:(NSString*)title { | 1084 - (void)nativeContent:(id)content titleDidChange:(NSString*)title { |
| 1089 // Responsiveness to delegate method was checked in setDelegate:. | 1085 _webStateImpl->OnTitleChanged(); |
| 1090 [_delegate webController:self titleDidChange:title]; | |
| 1091 } | 1086 } |
| 1092 | 1087 |
| 1093 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled { | 1088 - (void)setNativeControllerWebUsageEnabled:(BOOL)webUsageEnabled { |
| 1094 if ([self.nativeController | 1089 if ([self.nativeController |
| 1095 respondsToSelector:@selector(setWebUsageEnabled:)]) { | 1090 respondsToSelector:@selector(setWebUsageEnabled:)]) { |
| 1096 [self.nativeController setWebUsageEnabled:webUsageEnabled]; | 1091 [self.nativeController setWebUsageEnabled:webUsageEnabled]; |
| 1097 } | 1092 } |
| 1098 } | 1093 } |
| 1099 | 1094 |
| 1100 - (void)setWebUsageEnabled:(BOOL)enabled { | 1095 - (void)setWebUsageEnabled:(BOOL)enabled { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 | 1363 |
| 1369 base::string16 newTitle = base::SysNSStringToUTF16(title); | 1364 base::string16 newTitle = base::SysNSStringToUTF16(title); |
| 1370 if (item->GetTitle() == newTitle) | 1365 if (item->GetTitle() == newTitle) |
| 1371 return; | 1366 return; |
| 1372 | 1367 |
| 1373 item->SetTitle(newTitle); | 1368 item->SetTitle(newTitle); |
| 1374 // TODO(crbug.com/546218): See if this can be removed; it's not clear that | 1369 // TODO(crbug.com/546218): See if this can be removed; it's not clear that |
| 1375 // other platforms send this (tab sync triggers need to be compared against | 1370 // other platforms send this (tab sync triggers need to be compared against |
| 1376 // upstream). | 1371 // upstream). |
| 1377 self.navigationManagerImpl->OnNavigationItemChanged(); | 1372 self.navigationManagerImpl->OnNavigationItemChanged(); |
| 1378 | 1373 _webStateImpl->OnTitleChanged(); |
| 1379 if ([_delegate respondsToSelector:@selector(webController:titleDidChange:)]) { | |
| 1380 [_delegate webController:self titleDidChange:title]; | |
| 1381 } | |
| 1382 } | 1374 } |
| 1383 | 1375 |
| 1384 - (BOOL)isCurrentNavigationItemPOST { | 1376 - (BOOL)isCurrentNavigationItemPOST { |
| 1385 // |_pendingNavigationInfo| will be nil if the decidePolicy* delegate methods | 1377 // |_pendingNavigationInfo| will be nil if the decidePolicy* delegate methods |
| 1386 // were not called. | 1378 // were not called. |
| 1387 NSString* HTTPMethod = | 1379 NSString* HTTPMethod = |
| 1388 _pendingNavigationInfo | 1380 _pendingNavigationInfo |
| 1389 ? [_pendingNavigationInfo HTTPMethod] | 1381 ? [_pendingNavigationInfo HTTPMethod] |
| 1390 : [self currentBackForwardListItemHolder]->http_method(); | 1382 : [self currentBackForwardListItemHolder]->http_method(); |
| 1391 return [HTTPMethod isEqual:@"POST"]; | 1383 return [HTTPMethod isEqual:@"POST"]; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 if (loadSuccess) { | 1788 if (loadSuccess) { |
| 1797 _webStateImpl->OnNavigationCommitted(currentURL); | 1789 _webStateImpl->OnNavigationCommitted(currentURL); |
| 1798 } else { | 1790 } else { |
| 1799 _webStateImpl->OnErrorPageNavigation(currentURL); | 1791 _webStateImpl->OnErrorPageNavigation(currentURL); |
| 1800 } | 1792 } |
| 1801 | 1793 |
| 1802 // Perform post-load-finished updates. | 1794 // Perform post-load-finished updates. |
| 1803 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; | 1795 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; |
| 1804 | 1796 |
| 1805 NSString* title = [self.nativeController title]; | 1797 NSString* title = [self.nativeController title]; |
| 1806 if (title) | 1798 if (title) { |
| 1807 [self setNavigationItemTitle:title]; | 1799 [self setNavigationItemTitle:title]; |
| 1800 } |
| 1808 | 1801 |
| 1809 // If the controller handles title change notification, route those to the | 1802 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { |
| 1810 // delegate. | 1803 [self.nativeController setDelegate:self]; |
| 1811 if ([_delegate respondsToSelector:@selector(webController:titleDidChange:)]) { | |
| 1812 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { | |
| 1813 [self.nativeController setDelegate:self]; | |
| 1814 } | |
| 1815 } | 1804 } |
| 1816 } | 1805 } |
| 1817 | 1806 |
| 1818 - (void)loadErrorInNativeView:(NSError*)error { | 1807 - (void)loadErrorInNativeView:(NSError*)error { |
| 1819 [self removeWebViewAllowingCachedReconstruction:NO]; | 1808 [self removeWebViewAllowingCachedReconstruction:NO]; |
| 1820 web::NavigationItem* item = [self currentNavItem]; | 1809 web::NavigationItem* item = [self currentNavItem]; |
| 1821 const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1810 const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
| 1822 | 1811 |
| 1823 if (web::IsWKWebViewSSLCertError(error)) { | 1812 if (web::IsWKWebViewSSLCertError(error)) { |
| 1824 // This could happen only if certificate is absent or could not be parsed. | 1813 // This could happen only if certificate is absent or could not be parsed. |
| (...skipping 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5244 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5233 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5245 _lastRegisteredRequestURL = URL; | 5234 _lastRegisteredRequestURL = URL; |
| 5246 _loadPhase = web::LOAD_REQUESTED; | 5235 _loadPhase = web::LOAD_REQUESTED; |
| 5247 } | 5236 } |
| 5248 | 5237 |
| 5249 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5238 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5250 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5239 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5251 } | 5240 } |
| 5252 | 5241 |
| 5253 @end | 5242 @end |
| OLD | NEW |