| 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 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 // back/forward navigation, for instance, because the callback that would | 1786 // back/forward navigation, for instance, because the callback that would |
| 1787 // populate it is not called in that flow. | 1787 // populate it is not called in that flow. |
| 1788 if ([_pendingNavigationInfo MIMEType]) | 1788 if ([_pendingNavigationInfo MIMEType]) |
| 1789 holder->set_mime_type([_pendingNavigationInfo MIMEType]); | 1789 holder->set_mime_type([_pendingNavigationInfo MIMEType]); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess { | 1792 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess { |
| 1793 const GURL currentURL([self currentURL]); | 1793 const GURL currentURL([self currentURL]); |
| 1794 [self didStartLoadingURL:currentURL updateHistory:loadSuccess]; | 1794 [self didStartLoadingURL:currentURL updateHistory:loadSuccess]; |
| 1795 _loadPhase = web::PAGE_LOADED; | 1795 _loadPhase = web::PAGE_LOADED; |
| 1796 if (loadSuccess) { |
| 1797 _webStateImpl->OnNavigationCommitted(currentURL); |
| 1798 } else { |
| 1799 _webStateImpl->OnErrorPageNavigation(currentURL); |
| 1800 } |
| 1796 | 1801 |
| 1797 // Perform post-load-finished updates. | 1802 // Perform post-load-finished updates. |
| 1798 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; | 1803 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; |
| 1799 | 1804 |
| 1800 NSString* title = [self.nativeController title]; | 1805 NSString* title = [self.nativeController title]; |
| 1801 if (title) | 1806 if (title) |
| 1802 [self setNavigationItemTitle:title]; | 1807 [self setNavigationItemTitle:title]; |
| 1803 | 1808 |
| 1804 // If the controller handles title change notification, route those to the | 1809 // If the controller handles title change notification, route those to the |
| 1805 // delegate. | 1810 // delegate. |
| (...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4036 linkClicked:linkActivatedNavigation]; | 4041 linkClicked:linkActivatedNavigation]; |
| 4037 } | 4042 } |
| 4038 | 4043 |
| 4039 - (CGFloat)headerHeight { | 4044 - (CGFloat)headerHeight { |
| 4040 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) | 4045 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) |
| 4041 return 0.0f; | 4046 return 0.0f; |
| 4042 return [_delegate headerHeightForWebController:self]; | 4047 return [_delegate headerHeightForWebController:self]; |
| 4043 } | 4048 } |
| 4044 | 4049 |
| 4045 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { | 4050 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { |
| 4051 _webStateImpl->OnSamePageNavigation(url); |
| 4046 [_delegate webDidUpdateHistoryStateWithPageURL:url]; | 4052 [_delegate webDidUpdateHistoryStateWithPageURL:url]; |
| 4047 } | 4053 } |
| 4048 | 4054 |
| 4049 - (void)updateSSLStatusForCurrentNavigationItem { | 4055 - (void)updateSSLStatusForCurrentNavigationItem { |
| 4050 if (_isBeingDestroyed) { | 4056 if (_isBeingDestroyed) { |
| 4051 return; | 4057 return; |
| 4052 } | 4058 } |
| 4053 | 4059 |
| 4054 web::NavigationManager* navManager = self.webState->GetNavigationManager(); | 4060 web::NavigationManager* navManager = self.webState->GetNavigationManager(); |
| 4055 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); | 4061 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4894 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED; | 4900 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED; |
| 4895 if (!navigationWasCommitted && | 4901 if (!navigationWasCommitted && |
| 4896 (webViewURL.is_empty() || webViewURL == _documentURL)) { | 4902 (webViewURL.is_empty() || webViewURL == _documentURL)) { |
| 4897 return; | 4903 return; |
| 4898 } | 4904 } |
| 4899 | 4905 |
| 4900 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) { | 4906 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) { |
| 4901 // A fast back/forward within the same origin does not call | 4907 // A fast back/forward within the same origin does not call |
| 4902 // |didCommitNavigation:|, so signal page change explicitly. | 4908 // |didCommitNavigation:|, so signal page change explicitly. |
| 4903 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin()); | 4909 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin()); |
| 4910 BOOL isSameDocumentNavigation = |
| 4911 [self isKVOChangePotentialSameDocumentNavigationToURL:webViewURL]; |
| 4904 [self setDocumentURL:webViewURL]; | 4912 [self setDocumentURL:webViewURL]; |
| 4913 if (isSameDocumentNavigation) { |
| 4914 _webStateImpl->OnSamePageNavigation(webViewURL); |
| 4915 } else { |
| 4916 _webStateImpl->OnNavigationCommitted(webViewURL); |
| 4917 } |
| 4905 [self webPageChanged]; | 4918 [self webPageChanged]; |
| 4906 } | 4919 } |
| 4907 | 4920 |
| 4908 [self updateSSLStatusForCurrentNavigationItem]; | 4921 [self updateSSLStatusForCurrentNavigationItem]; |
| 4909 | 4922 |
| 4910 // Fast back forward navigation may not call |didFinishNavigation:|, so | 4923 // Fast back forward navigation may not call |didFinishNavigation:|, so |
| 4911 // signal did finish navigation explicitly. | 4924 // signal did finish navigation explicitly. |
| 4912 if (_lastRegisteredRequestURL == _documentURL) { | 4925 if (_lastRegisteredRequestURL == _documentURL) { |
| 4913 [self didFinishNavigation]; | 4926 [self didFinishNavigation]; |
| 4914 } | 4927 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5001 if (windowLocationMatchesNewURL && | 5014 if (windowLocationMatchesNewURL && |
| 5002 newURLOriginMatchesDocumentURLOrigin && | 5015 newURLOriginMatchesDocumentURLOrigin && |
| 5003 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) { | 5016 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) { |
| 5004 [self URLDidChangeWithoutDocumentChange:URL]; | 5017 [self URLDidChangeWithoutDocumentChange:URL]; |
| 5005 } | 5018 } |
| 5006 }]; | 5019 }]; |
| 5007 } | 5020 } |
| 5008 } | 5021 } |
| 5009 | 5022 |
| 5010 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { | 5023 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { |
| 5011 DCHECK([_webView isLoading]); | |
| 5012 // If the origin changes, it can't be same-document. | 5024 // If the origin changes, it can't be same-document. |
| 5013 if (_documentURL.GetOrigin().is_empty() || | 5025 if (_documentURL.GetOrigin().is_empty() || |
| 5014 _documentURL.GetOrigin() != newURL.GetOrigin()) { | 5026 _documentURL.GetOrigin() != newURL.GetOrigin()) { |
| 5015 return NO; | 5027 return NO; |
| 5016 } | 5028 } |
| 5017 if (self.loadPhase == web::LOAD_REQUESTED) { | 5029 if (self.loadPhase == web::LOAD_REQUESTED) { |
| 5018 // Normally LOAD_REQUESTED indicates that this is a regular, pending | 5030 // Normally LOAD_REQUESTED indicates that this is a regular, pending |
| 5019 // navigation, but it can also happen during a fast-back navigation across | 5031 // navigation, but it can also happen during a fast-back navigation across |
| 5020 // a hash change, so that case is potentially a same-document navigation. | 5032 // a hash change, so that case is potentially a same-document navigation. |
| 5021 return web::GURLByRemovingRefFromGURL(newURL) == | 5033 return web::GURLByRemovingRefFromGURL(newURL) == |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5049 // If this wasn't a previously-expected load (e.g., certain back/forward | 5061 // If this wasn't a previously-expected load (e.g., certain back/forward |
| 5050 // navigations), register the load request. | 5062 // navigations), register the load request. |
| 5051 if (![self isLoadRequestPendingForURL:newURL]) | 5063 if (![self isLoadRequestPendingForURL:newURL]) |
| 5052 [self registerLoadRequest:newURL]; | 5064 [self registerLoadRequest:newURL]; |
| 5053 } | 5065 } |
| 5054 | 5066 |
| 5055 [self setDocumentURL:newURL]; | 5067 [self setDocumentURL:newURL]; |
| 5056 | 5068 |
| 5057 if (!_changingHistoryState) { | 5069 if (!_changingHistoryState) { |
| 5058 [self didStartLoadingURL:_documentURL updateHistory:YES]; | 5070 [self didStartLoadingURL:_documentURL updateHistory:YES]; |
| 5071 _webStateImpl->OnSamePageNavigation(newURL); |
| 5059 [self updateSSLStatusForCurrentNavigationItem]; | 5072 [self updateSSLStatusForCurrentNavigationItem]; |
| 5060 [self didFinishNavigation]; | 5073 [self didFinishNavigation]; |
| 5061 } | 5074 } |
| 5062 } | 5075 } |
| 5063 | 5076 |
| 5064 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { | 5077 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { |
| 5065 if (self.loadPhase != web::LOAD_REQUESTED) | 5078 if (self.loadPhase != web::LOAD_REQUESTED) |
| 5066 return NO; | 5079 return NO; |
| 5067 | 5080 |
| 5068 web::NavigationItem* pendingItem = | 5081 web::NavigationItem* pendingItem = |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5239 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5252 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5240 _lastRegisteredRequestURL = URL; | 5253 _lastRegisteredRequestURL = URL; |
| 5241 _loadPhase = web::LOAD_REQUESTED; | 5254 _loadPhase = web::LOAD_REQUESTED; |
| 5242 } | 5255 } |
| 5243 | 5256 |
| 5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5257 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5258 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5246 } | 5259 } |
| 5247 | 5260 |
| 5248 @end | 5261 @end |
| OLD | NEW |