Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2698413004: Implemented WebStateObserver::DidFinishNavigation(NavigationHandle*). (Closed)
Patch Set: Self review Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 // back/forward navigation, for instance, because the callback that would 1808 // back/forward navigation, for instance, because the callback that would
1809 // populate it is not called in that flow. 1809 // populate it is not called in that flow.
1810 if ([_pendingNavigationInfo MIMEType]) 1810 if ([_pendingNavigationInfo MIMEType])
1811 holder->set_mime_type([_pendingNavigationInfo MIMEType]); 1811 holder->set_mime_type([_pendingNavigationInfo MIMEType]);
1812 } 1812 }
1813 1813
1814 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess { 1814 - (void)loadNativeViewWithSuccess:(BOOL)loadSuccess {
1815 const GURL currentURL([self currentURL]); 1815 const GURL currentURL([self currentURL]);
1816 [self didStartLoadingURL:currentURL updateHistory:loadSuccess]; 1816 [self didStartLoadingURL:currentURL updateHistory:loadSuccess];
1817 _loadPhase = web::PAGE_LOADED; 1817 _loadPhase = web::PAGE_LOADED;
1818 if (!loadSuccess) {
1819 _webStateImpl->OnErrorPageNavigation(currentURL);
1820 } else {
1821 _webStateImpl->OnNavigationCommitted(currentURL);
1822 }
1818 1823
1819 // Perform post-load-finished updates. 1824 // Perform post-load-finished updates.
1820 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; 1825 [self didFinishWithURL:currentURL loadSuccess:loadSuccess];
1821 1826
1822 NSString* title = [self.nativeController title]; 1827 NSString* title = [self.nativeController title];
1823 if (title) 1828 if (title)
1824 [self setNavigationItemTitle:title]; 1829 [self setNavigationItemTitle:title];
1825 1830
1826 // If the controller handles title change notification, route those to the 1831 // If the controller handles title change notification, route those to the
1827 // delegate. 1832 // delegate.
(...skipping 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 linkClicked:linkActivatedNavigation]; 4106 linkClicked:linkActivatedNavigation];
4102 } 4107 }
4103 4108
4104 - (CGFloat)headerHeight { 4109 - (CGFloat)headerHeight {
4105 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) 4110 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)])
4106 return 0.0f; 4111 return 0.0f;
4107 return [_delegate headerHeightForWebController:self]; 4112 return [_delegate headerHeightForWebController:self];
4108 } 4113 }
4109 4114
4110 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { 4115 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url {
4116 _webStateImpl->OnSamePageNavigation(url);
4111 [_delegate webDidUpdateHistoryStateWithPageURL:url]; 4117 [_delegate webDidUpdateHistoryStateWithPageURL:url];
4112 } 4118 }
4113 4119
4114 - (void)updateSSLStatusForCurrentNavigationItem { 4120 - (void)updateSSLStatusForCurrentNavigationItem {
4115 if (_isBeingDestroyed) { 4121 if (_isBeingDestroyed) {
4116 return; 4122 return;
4117 } 4123 }
4118 4124
4119 web::NavigationManager* navManager = self.webState->GetNavigationManager(); 4125 web::NavigationManager* navManager = self.webState->GetNavigationManager();
4120 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); 4126 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem();
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
4973 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED; 4979 BOOL navigationWasCommitted = _loadPhase != web::LOAD_REQUESTED;
4974 if (!navigationWasCommitted && 4980 if (!navigationWasCommitted &&
4975 (webViewURL.is_empty() || webViewURL == _documentURL)) { 4981 (webViewURL.is_empty() || webViewURL == _documentURL)) {
4976 return; 4982 return;
4977 } 4983 }
4978 4984
4979 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) { 4985 if (!navigationWasCommitted && ![_pendingNavigationInfo cancelled]) {
4980 // A fast back/forward within the same origin does not call 4986 // A fast back/forward within the same origin does not call
4981 // |didCommitNavigation:|, so signal page change explicitly. 4987 // |didCommitNavigation:|, so signal page change explicitly.
4982 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin()); 4988 DCHECK_EQ(_documentURL.GetOrigin(), webViewURL.GetOrigin());
4989 BOOL isSameDocumentNavigaiton =
4990 [self isKVOChangePotentialSameDocumentNavigationToURL:webViewURL];
4983 [self setDocumentURL:webViewURL]; 4991 [self setDocumentURL:webViewURL];
4992 if (!isSameDocumentNavigaiton) {
kkhorimoto 2017/02/22 01:42:38 Let's reverse the ordering of these conditions so
Eugene But (OOO till 7-30) 2017/02/22 17:54:33 Done.
4993 _webStateImpl->OnNavigationCommitted(webViewURL);
4994 } else {
4995 _webStateImpl->OnSamePageNavigation(webViewURL);
4996 }
4984 [self webPageChanged]; 4997 [self webPageChanged];
4985 } 4998 }
4986 4999
4987 [self updateSSLStatusForCurrentNavigationItem]; 5000 [self updateSSLStatusForCurrentNavigationItem];
4988 5001
4989 // Fast back forward navigation may not call |didFinishNavigation:|, so 5002 // Fast back forward navigation may not call |didFinishNavigation:|, so
4990 // signal did finish navigation explicitly. 5003 // signal did finish navigation explicitly.
4991 if (_lastRegisteredRequestURL == _documentURL) { 5004 if (_lastRegisteredRequestURL == _documentURL) {
4992 [self didFinishNavigation]; 5005 [self didFinishNavigation];
4993 } 5006 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
5080 if (windowLocationMatchesNewURL && 5093 if (windowLocationMatchesNewURL &&
5081 newURLOriginMatchesDocumentURLOrigin && 5094 newURLOriginMatchesDocumentURLOrigin &&
5082 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) { 5095 webViewURLMatchesNewURL && URLDidChangeFromDocumentURL) {
5083 [self URLDidChangeWithoutDocumentChange:URL]; 5096 [self URLDidChangeWithoutDocumentChange:URL];
5084 } 5097 }
5085 }]; 5098 }];
5086 } 5099 }
5087 } 5100 }
5088 5101
5089 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { 5102 - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL {
5090 DCHECK([_webView isLoading]);
5091 // If the origin changes, it can't be same-document. 5103 // If the origin changes, it can't be same-document.
5092 if (_documentURL.GetOrigin().is_empty() || 5104 if (_documentURL.GetOrigin().is_empty() ||
5093 _documentURL.GetOrigin() != newURL.GetOrigin()) { 5105 _documentURL.GetOrigin() != newURL.GetOrigin()) {
5094 return NO; 5106 return NO;
5095 } 5107 }
5096 if (self.loadPhase == web::LOAD_REQUESTED) { 5108 if (self.loadPhase == web::LOAD_REQUESTED) {
5097 // Normally LOAD_REQUESTED indicates that this is a regular, pending 5109 // Normally LOAD_REQUESTED indicates that this is a regular, pending
5098 // navigation, but it can also happen during a fast-back navigation across 5110 // navigation, but it can also happen during a fast-back navigation across
5099 // a hash change, so that case is potentially a same-document navigation. 5111 // a hash change, so that case is potentially a same-document navigation.
5100 return web::GURLByRemovingRefFromGURL(newURL) == 5112 return web::GURLByRemovingRefFromGURL(newURL) ==
(...skipping 27 matching lines...) Expand all
5128 // If this wasn't a previously-expected load (e.g., certain back/forward 5140 // If this wasn't a previously-expected load (e.g., certain back/forward
5129 // navigations), register the load request. 5141 // navigations), register the load request.
5130 if (![self isLoadRequestPendingForURL:newURL]) 5142 if (![self isLoadRequestPendingForURL:newURL])
5131 [self registerLoadRequest:newURL]; 5143 [self registerLoadRequest:newURL];
5132 } 5144 }
5133 5145
5134 [self setDocumentURL:newURL]; 5146 [self setDocumentURL:newURL];
5135 5147
5136 if (!_changingHistoryState) { 5148 if (!_changingHistoryState) {
5137 [self didStartLoadingURL:_documentURL updateHistory:YES]; 5149 [self didStartLoadingURL:_documentURL updateHistory:YES];
5150 _webStateImpl->OnSamePageNavigation(newURL);
5138 [self updateSSLStatusForCurrentNavigationItem]; 5151 [self updateSSLStatusForCurrentNavigationItem];
5139 [self didFinishNavigation]; 5152 [self didFinishNavigation];
5140 } 5153 }
5141 } 5154 }
5142 5155
5143 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { 5156 - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL {
5144 if (self.loadPhase != web::LOAD_REQUESTED) 5157 if (self.loadPhase != web::LOAD_REQUESTED)
5145 return NO; 5158 return NO;
5146 5159
5147 web::NavigationItem* pendingItem = 5160 web::NavigationItem* pendingItem =
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
5318 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5331 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5319 _lastRegisteredRequestURL = URL; 5332 _lastRegisteredRequestURL = URL;
5320 _loadPhase = web::LOAD_REQUESTED; 5333 _loadPhase = web::LOAD_REQUESTED;
5321 } 5334 }
5322 5335
5323 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5336 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5324 return [action.request valueForHTTPHeaderField:@"Referer"]; 5337 return [action.request valueForHTTPHeaderField:@"Referer"];
5325 } 5338 }
5326 5339
5327 @end 5340 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698