Chromium Code Reviews| 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 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 // back/forward navigation, for instance, because the callback that would | 1778 // back/forward navigation, for instance, because the callback that would |
| 1779 // populate it is not called in that flow. | 1779 // populate it is not called in that flow. |
| 1780 if ([_pendingNavigationInfo MIMEType]) | 1780 if ([_pendingNavigationInfo MIMEType]) |
| 1781 holder->set_mime_type([_pendingNavigationInfo MIMEType]); | 1781 holder->set_mime_type([_pendingNavigationInfo MIMEType]); |
| 1782 } | 1782 } |
| 1783 | 1783 |
| 1784 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess { | 1784 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess { |
| 1785 const GURL currentURL([self currentURL]); | 1785 const GURL currentURL([self currentURL]); |
| 1786 [self didStartLoadingURL:currentURL updateHistory:loadSuccess]; | 1786 [self didStartLoadingURL:currentURL updateHistory:loadSuccess]; |
| 1787 _loadPhase = web::PAGE_LOADED; | 1787 _loadPhase = web::PAGE_LOADED; |
| 1788 if (loadSuccess) { | |
| 1789 _webStateImpl->OnNavigationCommitted(currentURL); | |
| 1790 } else { | |
| 1791 _webStateImpl->OnErrorPageNavigation(currentURL); | |
| 1792 } | |
| 1788 | 1793 |
| 1789 // Perform post-load-finished updates. | 1794 // Perform post-load-finished updates. |
| 1790 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; | 1795 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; |
| 1791 | 1796 |
| 1792 NSString* title = [self.nativeController title]; | 1797 NSString* title = [self.nativeController title]; |
| 1793 if (title) | 1798 if (title) |
| 1794 [self setNavigationItemTitle:title]; | 1799 [self setNavigationItemTitle:title]; |
| 1795 | 1800 |
| 1796 // If the controller handles title change notification, route those to the | 1801 // If the controller handles title change notification, route those to the |
| 1797 // delegate. | 1802 // delegate. |
| (...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4019 linkClicked:linkActivatedNavigation]; | 4024 linkClicked:linkActivatedNavigation]; |
| 4020 } | 4025 } |
| 4021 | 4026 |
| 4022 - (CGFloat)headerHeight { | 4027 - (CGFloat)headerHeight { |
| 4023 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) | 4028 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) |
| 4024 return 0.0f; | 4029 return 0.0f; |
| 4025 return [_delegate headerHeightForWebController:self]; | 4030 return [_delegate headerHeightForWebController:self]; |
| 4026 } | 4031 } |
| 4027 | 4032 |
| 4028 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { | 4033 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { |
| 4034 _webStateImpl->OnSamePageNavigation(url); | |
| 4029 [_delegate webDidUpdateHistoryStateWithPageURL:url]; | 4035 [_delegate webDidUpdateHistoryStateWithPageURL:url]; |
| 4030 } | 4036 } |
| 4031 | 4037 |
| 4032 - (void)updateSSLStatusForCurrentNavigationItem { | 4038 - (void)updateSSLStatusForCurrentNavigationItem { |
| 4033 if (_isBeingDestroyed) { | 4039 if (_isBeingDestroyed) { |
| 4034 return; | 4040 return; |
| 4035 } | 4041 } |
| 4036 | 4042 |
| 4037 web::NavigationManager* navManager = self.webState->GetNavigationManager(); | 4043 web::NavigationManager* navManager = self.webState->GetNavigationManager(); |
| 4038 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); | 4044 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4886 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED; | 4892 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED; |
| 4887 if (!navigationWasCommitted && | 4893 if (!navigationWasCommitted && |
| 4888 (webViewURL.is_empty() || webViewURL == _documentURL)) { | 4894 (webViewURL.is_empty() || webViewURL == _documentURL)) { |
| 4889 return; | 4895 return; |
| 4890 } | 4896 } |
| 4891 | 4897 |
| 4892 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) { | 4898 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) { |
| 4893 // A fast back/forward within the same origin does not call | 4899 // A fast back/forward within the same origin does not call |
| 4894 // |didCommitNavigation:|, so signal page change explicitly. | 4900 // |didCommitNavigation:|, so signal page change explicitly. |
| 4895 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin()); | 4901 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin()); |
| 4902 BOOL isSameDocumentNavigaiton = | |
|
rohitrao (ping after 24h)
2017/02/24 01:22:48
Typo: navigation
Eugene But (OOO till 7-30)
2017/02/24 01:49:41
Done.
| |
| 4903 [self isKVOChangePotentialSameDocumentNavigationToURL:webViewURL]; | |
| 4896 [self setDocumentURL:webViewURL]; | 4904 [self setDocumentURL:webViewURL]; |
| 4905 if (isSameDocumentNavigaiton) { | |
| 4906 _webStateImpl->OnSamePageNavigation(webViewURL); | |
| 4907 } else { | |
| 4908 _webStateImpl->OnNavigationCommitted(webViewURL); | |
| 4909 } | |
| 4897 [self webPageChanged]; | 4910 [self webPageChanged]; |
| 4898 } | 4911 } |
| 4899 | 4912 |
| 4900 [self updateSSLStatusForCurrentNavigationItem]; | 4913 [self updateSSLStatusForCurrentNavigationItem]; |
| 4901 | 4914 |
| 4902 // Fast back forward navigation may not call |didFinishNavigation:|, so | 4915 // Fast back forward navigation may not call |didFinishNavigation:|, so |
| 4903 // signal did finish navigation explicitly. | 4916 // signal did finish navigation explicitly. |
| 4904 if (_lastRegisteredRequestURL == _documentURL) { | 4917 if (_lastRegisteredRequestURL == _documentURL) { |
| 4905 [self didFinishNavigation]; | 4918 [self didFinishNavigation]; |
| 4906 } | 4919 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4993 if (windowLocationMatchesNewURL && | 5006 if (windowLocationMatchesNewURL && |
| 4994 newURLOriginMatchesDocumentURLOrigin && | 5007 newURLOriginMatchesDocumentURLOrigin && |
| 4995 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) { | 5008 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) { |
| 4996 [self URLDidChangeWithoutDocumentChange:URL]; | 5009 [self URLDidChangeWithoutDocumentChange:URL]; |
| 4997 } | 5010 } |
| 4998 }]; | 5011 }]; |
| 4999 } | 5012 } |
| 5000 } | 5013 } |
| 5001 | 5014 |
| 5002 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { | 5015 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { |
| 5003 DCHECK([_webView isLoading]); | |
| 5004 // If the origin changes, it can't be same-document. | 5016 // If the origin changes, it can't be same-document. |
| 5005 if (_documentURL.GetOrigin().is_empty() || | 5017 if (_documentURL.GetOrigin().is_empty() || |
| 5006 _documentURL.GetOrigin() != newURL.GetOrigin()) { | 5018 _documentURL.GetOrigin() != newURL.GetOrigin()) { |
| 5007 return NO; | 5019 return NO; |
| 5008 } | 5020 } |
| 5009 if (self.loadPhase == web::LOAD_REQUESTED) { | 5021 if (self.loadPhase == web::LOAD_REQUESTED) { |
| 5010 // Normally LOAD_REQUESTED indicates that this is a regular, pending | 5022 // Normally LOAD_REQUESTED indicates that this is a regular, pending |
| 5011 // navigation, but it can also happen during a fast-back navigation across | 5023 // navigation, but it can also happen during a fast-back navigation across |
| 5012 // a hash change, so that case is potentially a same-document navigation. | 5024 // a hash change, so that case is potentially a same-document navigation. |
| 5013 return web::GURLByRemovingRefFromGURL(newURL) == | 5025 return web::GURLByRemovingRefFromGURL(newURL) == |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 5041 // If this wasn't a previously-expected load (e.g., certain back/forward | 5053 // If this wasn't a previously-expected load (e.g., certain back/forward |
| 5042 // navigations), register the load request. | 5054 // navigations), register the load request. |
| 5043 if (![self isLoadRequestPendingForURL:newURL]) | 5055 if (![self isLoadRequestPendingForURL:newURL]) |
| 5044 [self registerLoadRequest:newURL]; | 5056 [self registerLoadRequest:newURL]; |
| 5045 } | 5057 } |
| 5046 | 5058 |
| 5047 [self setDocumentURL:newURL]; | 5059 [self setDocumentURL:newURL]; |
| 5048 | 5060 |
| 5049 if (!_changingHistoryState) { | 5061 if (!_changingHistoryState) { |
| 5050 [self didStartLoadingURL:_documentURL updateHistory:YES]; | 5062 [self didStartLoadingURL:_documentURL updateHistory:YES]; |
| 5063 _webStateImpl->OnSamePageNavigation(newURL); | |
| 5051 [self updateSSLStatusForCurrentNavigationItem]; | 5064 [self updateSSLStatusForCurrentNavigationItem]; |
| 5052 [self didFinishNavigation]; | 5065 [self didFinishNavigation]; |
| 5053 } | 5066 } |
| 5054 } | 5067 } |
| 5055 | 5068 |
| 5056 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { | 5069 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { |
| 5057 if (self.loadPhase != web::LOAD_REQUESTED) | 5070 if (self.loadPhase != web::LOAD_REQUESTED) |
| 5058 return NO; | 5071 return NO; |
| 5059 | 5072 |
| 5060 web::NavigationItem* pendingItem = | 5073 web::NavigationItem* pendingItem = |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5231 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5244 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5232 _lastRegisteredRequestURL = URL; | 5245 _lastRegisteredRequestURL = URL; |
| 5233 _loadPhase = web::LOAD_REQUESTED; | 5246 _loadPhase = web::LOAD_REQUESTED; |
| 5234 } | 5247 } |
| 5235 | 5248 |
| 5236 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5249 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5237 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5250 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5238 } | 5251 } |
| 5239 | 5252 |
| 5240 @end | 5253 @end |
| OLD | NEW |