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

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

Issue 2919473004: Remove _URLOnStartLoading from crw_web_controller (Closed)
Patch Set: move description to other cl Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // YES if the user has interacted with the content area since the last URL 295 // YES if the user has interacted with the content area since the last URL
296 // change. 296 // change.
297 BOOL _interactionRegisteredSinceLastURLChange; 297 BOOL _interactionRegisteredSinceLastURLChange;
298 // The actual URL of the document object (i.e., the last committed URL). 298 // The actual URL of the document object (i.e., the last committed URL).
299 // TODO(crbug.com/549616): Remove this in favor of just updating the 299 // TODO(crbug.com/549616): Remove this in favor of just updating the
300 // navigation manager and treating that as authoritative. 300 // navigation manager and treating that as authoritative.
301 GURL _documentURL; 301 GURL _documentURL;
302 // Last URL change reported to webWill/DidStartLoadingURL. Used to detect page 302 // Last URL change reported to webWill/DidStartLoadingURL. Used to detect page
303 // location changes (client redirects) in practice. 303 // location changes (client redirects) in practice.
304 GURL _lastRegisteredRequestURL; 304 GURL _lastRegisteredRequestURL;
305 // Last URL change reported to webDidStartLoadingURL. Used to detect page
306 // location changes in practice.
307 GURL _URLOnStartLoading;
308 // Page loading phase. 305 // Page loading phase.
309 web::LoadPhase _loadPhase; 306 web::LoadPhase _loadPhase;
310 // The web::PageDisplayState recorded when the page starts loading. 307 // The web::PageDisplayState recorded when the page starts loading.
311 web::PageDisplayState _displayStateOnStartLoading; 308 web::PageDisplayState _displayStateOnStartLoading;
312 // Whether or not the page has zoomed since the current navigation has been 309 // Whether or not the page has zoomed since the current navigation has been
313 // committed, either by user interaction or via |-restoreStateFromHistory|. 310 // committed, either by user interaction or via |-restoreStateFromHistory|.
314 BOOL _pageHasZoomed; 311 BOOL _pageHasZoomed;
315 // Whether a PageDisplayState is currently being applied. 312 // Whether a PageDisplayState is currently being applied.
316 BOOL _applyingPageState; 313 BOOL _applyingPageState;
317 // Actions to execute once the page load is complete. 314 // Actions to execute once the page load is complete.
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 const GURL oldURL = previousItem ? previousItem->GetURL() : GURL(); 1626 const GURL oldURL = previousItem ? previousItem->GetURL() : GURL();
1630 [script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL 1627 [script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL
1631 newURL:URL]]; 1628 newURL:URL]];
1632 } 1629 }
1633 base::WeakNSObject<CRWWebController> weakSelf(self); 1630 base::WeakNSObject<CRWWebController> weakSelf(self);
1634 [self executeJavaScript:script 1631 [self executeJavaScript:script
1635 completionHandler:^(id, NSError*) { 1632 completionHandler:^(id, NSError*) {
1636 if (!weakSelf || weakSelf.get()->_isBeingDestroyed) 1633 if (!weakSelf || weakSelf.get()->_isBeingDestroyed)
1637 return; 1634 return;
1638 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); 1635 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]);
1639 strongSelf.get()->_URLOnStartLoading = URL;
1640 strongSelf.get()->_lastRegisteredRequestURL = URL; 1636 strongSelf.get()->_lastRegisteredRequestURL = URL;
1641 }]; 1637 }];
1642 } 1638 }
1643 1639
1644 // Load the current URL in a web view, first ensuring the web view is visible. 1640 // Load the current URL in a web view, first ensuring the web view is visible.
1645 - (void)loadCurrentURLInWebView { 1641 - (void)loadCurrentURLInWebView {
1646 // Clear the set of URLs opened in external applications. 1642 // Clear the set of URLs opened in external applications.
1647 _openedApplicationURL.reset([[NSMutableSet alloc] init]); 1643 _openedApplicationURL.reset([[NSMutableSet alloc] init]);
1648 1644
1649 web::NavigationItem* item = self.currentNavItem; 1645 web::NavigationItem* item = self.currentNavItem;
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 // origin, ignore the pushState. This can happen if a new URL is loaded 2731 // origin, ignore the pushState. This can happen if a new URL is loaded
2736 // just before the pushState. 2732 // just before the pushState.
2737 return YES; 2733 return YES;
2738 } 2734 }
2739 std::string stateObjectJSON; 2735 std::string stateObjectJSON;
2740 if (!message->GetString("stateObject", &stateObjectJSON)) { 2736 if (!message->GetString("stateObject", &stateObjectJSON)) {
2741 DLOG(WARNING) << "JS message parameter not found: stateObject"; 2737 DLOG(WARNING) << "JS message parameter not found: stateObject";
2742 return NO; 2738 return NO;
2743 } 2739 }
2744 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); 2740 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON);
2745 _URLOnStartLoading = pushURL;
2746 _lastRegisteredRequestURL = pushURL; 2741 _lastRegisteredRequestURL = pushURL;
2747 2742
2748 // If the user interacted with the page, categorize it as a link navigation. 2743 // If the user interacted with the page, categorize it as a link navigation.
2749 // If not, categorize it is a client redirect as it occurred without user 2744 // If not, categorize it is a client redirect as it occurred without user
2750 // input and should not be added to the history stack. 2745 // input and should not be added to the history stack.
2751 // TODO(crbug.com/549301): Improve transition detection. 2746 // TODO(crbug.com/549301): Improve transition detection.
2752 ui::PageTransition transition = self.userInteractionRegistered 2747 ui::PageTransition transition = self.userInteractionRegistered
2753 ? ui::PAGE_TRANSITION_LINK 2748 ? ui::PAGE_TRANSITION_LINK
2754 : ui::PAGE_TRANSITION_CLIENT_REDIRECT; 2749 : ui::PAGE_TRANSITION_CLIENT_REDIRECT;
2755 [self pushStateWithPageURL:pushURL 2750 [self pushStateWithPageURL:pushURL
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 // replaceURL's origin, ignore the replaceState. This can happen if a 2797 // replaceURL's origin, ignore the replaceState. This can happen if a
2803 // new URL is loaded just before the replaceState. 2798 // new URL is loaded just before the replaceState.
2804 return YES; 2799 return YES;
2805 } 2800 }
2806 std::string stateObjectJSON; 2801 std::string stateObjectJSON;
2807 if (!message->GetString("stateObject", &stateObjectJSON)) { 2802 if (!message->GetString("stateObject", &stateObjectJSON)) {
2808 DLOG(WARNING) << "JS message parameter not found: stateObject"; 2803 DLOG(WARNING) << "JS message parameter not found: stateObject";
2809 return NO; 2804 return NO;
2810 } 2805 }
2811 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); 2806 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON);
2812 _URLOnStartLoading = replaceURL;
2813 _lastRegisteredRequestURL = replaceURL; 2807 _lastRegisteredRequestURL = replaceURL;
2814 [self replaceStateWithPageURL:replaceURL stateObject:stateObject]; 2808 [self replaceStateWithPageURL:replaceURL stateObject:stateObject];
2815 NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL 2809 NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL
2816 stateObjectJSON:stateObject]; 2810 stateObjectJSON:stateObject];
2817 base::WeakNSObject<CRWWebController> weakSelf(self); 2811 base::WeakNSObject<CRWWebController> weakSelf(self);
2818 [self executeJavaScript:replaceStateJS completionHandler:^(id, NSError*) { 2812 [self executeJavaScript:replaceStateJS completionHandler:^(id, NSError*) {
2819 if (!weakSelf || weakSelf.get()->_isBeingDestroyed) 2813 if (!weakSelf || weakSelf.get()->_isBeingDestroyed)
2820 return; 2814 return;
2821 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); 2815 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]);
2822 [strongSelf didFinishNavigation:nil]; 2816 [strongSelf didFinishNavigation:nil];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2865 [self didStartLoadingURL:currentURL]; 2859 [self didStartLoadingURL:currentURL];
2866 } 2860 }
2867 2861
2868 - (void)resetDocumentSpecificState { 2862 - (void)resetDocumentSpecificState {
2869 _lastUserInteraction.reset(); 2863 _lastUserInteraction.reset();
2870 _clickInProgress = NO; 2864 _clickInProgress = NO;
2871 } 2865 }
2872 2866
2873 - (void)didStartLoadingURL:(const GURL&)URL { 2867 - (void)didStartLoadingURL:(const GURL&)URL {
2874 _loadPhase = web::PAGE_LOADING; 2868 _loadPhase = web::PAGE_LOADING;
2875 _URLOnStartLoading = URL;
2876 _displayStateOnStartLoading = self.pageDisplayState; 2869 _displayStateOnStartLoading = self.pageDisplayState;
2877 2870
2878 self.userInteractionRegistered = NO; 2871 self.userInteractionRegistered = NO;
2879 _pageHasZoomed = NO; 2872 _pageHasZoomed = NO;
2880 2873
2881 [[self sessionController] commitPendingItem]; 2874 [[self sessionController] commitPendingItem];
2882 } 2875 }
2883 2876
2884 - (void)wasShown { 2877 - (void)wasShown {
2885 if ([self.nativeController respondsToSelector:@selector(wasShown)]) { 2878 if ([self.nativeController respondsToSelector:@selector(wasShown)]) {
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4012 _contextMenuController.reset([[CRWContextMenuController alloc] 4005 _contextMenuController.reset([[CRWContextMenuController alloc]
4013 initWithWebView:_webView 4006 initWithWebView:_webView
4014 injectionEvaluator:self 4007 injectionEvaluator:self
4015 delegate:self]); 4008 delegate:self]);
4016 4009
4017 // Add all additional gesture recognizers to the web view. 4010 // Add all additional gesture recognizers to the web view.
4018 for (UIGestureRecognizer* recognizer in _gestureRecognizers.get()) { 4011 for (UIGestureRecognizer* recognizer in _gestureRecognizers.get()) {
4019 [_webView addGestureRecognizer:recognizer]; 4012 [_webView addGestureRecognizer:recognizer];
4020 } 4013 }
4021 4014
4022 _URLOnStartLoading = _defaultURL;
4023
4024 // WKWebViews with invalid or empty frames have exhibited rendering bugs, so 4015 // WKWebViews with invalid or empty frames have exhibited rendering bugs, so
4025 // resize the view to match the container view upon creation. 4016 // resize the view to match the container view upon creation.
4026 [_webView setFrame:[_containerView bounds]]; 4017 [_webView setFrame:[_containerView bounds]];
4027 4018
4028 // If the visible NavigationItem should be loaded in this web view, display 4019 // If the visible NavigationItem should be loaded in this web view, display
4029 // it immediately. Otherwise, it will be displayed when the pending load is 4020 // it immediately. Otherwise, it will be displayed when the pending load is
4030 // committed. 4021 // committed.
4031 web::NavigationItem* visibleItem = 4022 web::NavigationItem* visibleItem =
4032 self.navigationManagerImpl->GetVisibleItem(); 4023 self.navigationManagerImpl->GetVisibleItem();
4033 const GURL& visibleURL = 4024 const GURL& visibleURL =
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
5232 - (NSUInteger)observerCount { 5223 - (NSUInteger)observerCount {
5233 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5224 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5234 return [_observers count]; 5225 return [_observers count];
5235 } 5226 }
5236 5227
5237 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5228 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5238 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5229 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5239 } 5230 }
5240 5231
5241 @end 5232 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698