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

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

Issue 2644103004: Remove RequestTracker from WebStateImpl. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 | ios/web/web_state/web_state_impl.h » ('j') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "ios/web/history_state_util.h" 42 #include "ios/web/history_state_util.h"
43 #import "ios/web/interstitials/web_interstitial_impl.h" 43 #import "ios/web/interstitials/web_interstitial_impl.h"
44 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" 44 #import "ios/web/navigation/crw_session_certificate_policy_manager.h"
45 #import "ios/web/navigation/crw_session_controller.h" 45 #import "ios/web/navigation/crw_session_controller.h"
46 #import "ios/web/navigation/crw_session_entry.h" 46 #import "ios/web/navigation/crw_session_entry.h"
47 #import "ios/web/navigation/navigation_item_impl.h" 47 #import "ios/web/navigation/navigation_item_impl.h"
48 #import "ios/web/navigation/navigation_manager_impl.h" 48 #import "ios/web/navigation/navigation_manager_impl.h"
49 #include "ios/web/net/cert_host_pair.h" 49 #include "ios/web/net/cert_host_pair.h"
50 #import "ios/web/net/crw_cert_verification_controller.h" 50 #import "ios/web/net/crw_cert_verification_controller.h"
51 #import "ios/web/net/crw_ssl_status_updater.h" 51 #import "ios/web/net/crw_ssl_status_updater.h"
52 #import "ios/web/net/request_group_util.h"
53 #include "ios/web/public/browser_state.h" 52 #include "ios/web/public/browser_state.h"
54 #include "ios/web/public/favicon_url.h" 53 #include "ios/web/public/favicon_url.h"
55 #import "ios/web/public/java_script_dialog_presenter.h" 54 #import "ios/web/public/java_script_dialog_presenter.h"
56 #import "ios/web/public/navigation_item.h" 55 #import "ios/web/public/navigation_item.h"
57 #import "ios/web/public/navigation_manager.h" 56 #import "ios/web/public/navigation_manager.h"
58 #import "ios/web/public/origin_util.h" 57 #import "ios/web/public/origin_util.h"
59 #include "ios/web/public/referrer.h" 58 #include "ios/web/public/referrer.h"
60 #include "ios/web/public/referrer_util.h" 59 #include "ios/web/public/referrer_util.h"
61 #include "ios/web/public/ssl_status.h" 60 #include "ios/web/public/ssl_status.h"
62 #import "ios/web/public/url_scheme_util.h" 61 #import "ios/web/public/url_scheme_util.h"
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 @synthesize webUsageEnabled = _webUsageEnabled; 986 @synthesize webUsageEnabled = _webUsageEnabled;
988 @synthesize usePlaceholderOverlay = _usePlaceholderOverlay; 987 @synthesize usePlaceholderOverlay = _usePlaceholderOverlay;
989 @synthesize loadPhase = _loadPhase; 988 @synthesize loadPhase = _loadPhase;
990 @synthesize shouldSuppressDialogs = _shouldSuppressDialogs; 989 @synthesize shouldSuppressDialogs = _shouldSuppressDialogs;
991 990
992 - (instancetype)initWithWebState:(WebStateImpl*)webState { 991 - (instancetype)initWithWebState:(WebStateImpl*)webState {
993 self = [super init]; 992 self = [super init];
994 if (self) { 993 if (self) {
995 _webStateImpl = webState; 994 _webStateImpl = webState;
996 DCHECK(_webStateImpl); 995 DCHECK(_webStateImpl);
997 _webStateImpl->InitializeRequestTracker(self);
998 // Load phase when no WebView present is 'loaded' because this represents 996 // Load phase when no WebView present is 'loaded' because this represents
999 // the idle state. 997 // the idle state.
1000 _loadPhase = web::PAGE_LOADED; 998 _loadPhase = web::PAGE_LOADED;
1001 // Content area is lazily instantiated. 999 // Content area is lazily instantiated.
1002 _defaultURL = GURL(url::kAboutBlankURL); 1000 _defaultURL = GURL(url::kAboutBlankURL);
1003 _jsInjectionReceiver.reset( 1001 _jsInjectionReceiver.reset(
1004 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); 1002 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]);
1005 _webViewProxy.reset( 1003 _webViewProxy.reset(
1006 [[CRWWebViewProxyImpl alloc] initWithWebController:self]); 1004 [[CRWWebViewProxyImpl alloc] initWithWebController:self]);
1007 [[_webViewProxy scrollViewProxy] addObserver:self]; 1005 [[_webViewProxy scrollViewProxy] addObserver:self];
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1217
1220 // Stop doing stuff, especially network stuff. Close the request tracker. 1218 // Stop doing stuff, especially network stuff. Close the request tracker.
1221 - (void)terminateNetworkActivity { 1219 - (void)terminateNetworkActivity {
1222 DCHECK(!_isHalted); 1220 DCHECK(!_isHalted);
1223 _isHalted = YES; 1221 _isHalted = YES;
1224 1222
1225 // Cancel all outstanding perform requests, and clear anything already queued 1223 // Cancel all outstanding perform requests, and clear anything already queued
1226 // (since this may be called from within the handling loop) to prevent any 1224 // (since this may be called from within the handling loop) to prevent any
1227 // asynchronous JavaScript invocation handling from continuing. 1225 // asynchronous JavaScript invocation handling from continuing.
1228 [NSObject cancelPreviousPerformRequestsWithTarget:self]; 1226 [NSObject cancelPreviousPerformRequestsWithTarget:self];
1229 _webStateImpl->CloseRequestTracker();
1230 } 1227 }
1231 1228
1232 - (void)dismissModals { 1229 - (void)dismissModals {
1233 if ([self.nativeController respondsToSelector:@selector(dismissModals)]) 1230 if ([self.nativeController respondsToSelector:@selector(dismissModals)])
1234 [self.nativeController dismissModals]; 1231 [self.nativeController dismissModals];
1235 } 1232 }
1236 1233
1237 // Caller must reset the delegate before calling. 1234 // Caller must reset the delegate before calling.
1238 - (void)close { 1235 - (void)close {
1239 _webStateImpl->CancelDialogs(); 1236 _webStateImpl->CancelDialogs();
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 _webStateImpl->SetIsLoading(false); 2147 _webStateImpl->SetIsLoading(false);
2151 } 2148 }
2152 [_delegate webCancelStartLoadingRequest]; 2149 [_delegate webCancelStartLoadingRequest];
2153 break; 2150 break;
2154 case web::PAGE_LOADING: 2151 case web::PAGE_LOADING:
2155 // The previous load never fully completed before this page change. The 2152 // The previous load never fully completed before this page change. The
2156 // loadPhase is changed to PAGE_LOADED to indicate the cycle is complete, 2153 // loadPhase is changed to PAGE_LOADED to indicate the cycle is complete,
2157 // and the delegate is called. 2154 // and the delegate is called.
2158 _loadPhase = web::PAGE_LOADED; 2155 _loadPhase = web::PAGE_LOADED;
2159 if (!_isHalted) { 2156 if (!_isHalted) {
2160 // RequestTracker expects StartPageLoad to be followed by
2161 // FinishPageLoad, passing the exact same URL.
2162 self.webStateImpl->GetRequestTracker()->FinishPageLoad(
2163 _URLOnStartLoading, false);
2164 _webStateImpl->SetIsLoading(false); 2157 _webStateImpl->SetIsLoading(false);
2165 } 2158 }
2166 [_delegate webLoadCancelled:_URLOnStartLoading]; 2159 [_delegate webLoadCancelled:_URLOnStartLoading];
2167 break; 2160 break;
2168 case web::PAGE_LOADED: 2161 case web::PAGE_LOADED:
2169 break; 2162 break;
2170 } 2163 }
2171 } 2164 }
2172 2165
2173 - (void)goToItemAtIndex:(int)index { 2166 - (void)goToItemAtIndex:(int)index {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 2258
2266 // Execute the pending LoadCompleteActions. 2259 // Execute the pending LoadCompleteActions.
2267 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { 2260 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) {
2268 action(); 2261 action();
2269 } 2262 }
2270 [_pendingLoadCompleteActions removeAllObjects]; 2263 [_pendingLoadCompleteActions removeAllObjects];
2271 } 2264 }
2272 2265
2273 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess { 2266 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess {
2274 DCHECK(_loadPhase == web::PAGE_LOADED); 2267 DCHECK(_loadPhase == web::PAGE_LOADED);
2275 _webStateImpl->GetRequestTracker()->FinishPageLoad(currentURL, loadSuccess);
2276
2277 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, 2268 // Rather than creating a new WKBackForwardListItem when loading WebUI pages,
2278 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem 2269 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem
2279 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a 2270 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a
2280 // result, the WebUI's HTML and URL will be loaded when navigating to that 2271 // result, the WebUI's HTML and URL will be loaded when navigating to that
2281 // WKBackForwardListItem, causing a mismatch between the visible content and 2272 // WKBackForwardListItem, causing a mismatch between the visible content and
2282 // the visible URL (WebUI page will be visible, but URL will be the previous 2273 // the visible URL (WebUI page will be visible, but URL will be the previous
2283 // page's URL). To prevent this potential URL spoofing vulnerability, reset 2274 // page's URL). To prevent this potential URL spoofing vulnerability, reset
2284 // the previous NavigationItem's WKBackForwardListItem to force loading via 2275 // the previous NavigationItem's WKBackForwardListItem to force loading via
2285 // NSURLRequest. 2276 // NSURLRequest.
2286 if (_webUIManager) { 2277 if (_webUIManager) {
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 3141
3151 - (void)didStartLoadingURL:(const GURL&)url updateHistory:(BOOL)updateHistory { 3142 - (void)didStartLoadingURL:(const GURL&)url updateHistory:(BOOL)updateHistory {
3152 _loadPhase = web::PAGE_LOADING; 3143 _loadPhase = web::PAGE_LOADING;
3153 _URLOnStartLoading = url; 3144 _URLOnStartLoading = url;
3154 _displayStateOnStartLoading = self.pageDisplayState; 3145 _displayStateOnStartLoading = self.pageDisplayState;
3155 3146
3156 self.userInteractionRegistered = NO; 3147 self.userInteractionRegistered = NO;
3157 _pageHasZoomed = NO; 3148 _pageHasZoomed = NO;
3158 3149
3159 [[self sessionController] commitPendingEntry]; 3150 [[self sessionController] commitPendingEntry];
3160 _webStateImpl->GetRequestTracker()->StartPageLoad(
3161 url, [[self sessionController] currentEntry]);
3162 [_delegate webDidStartLoadingURL:url shouldUpdateHistory:updateHistory]; 3151 [_delegate webDidStartLoadingURL:url shouldUpdateHistory:updateHistory];
3163 } 3152 }
3164 3153
3165 - (void)wasShown { 3154 - (void)wasShown {
3166 if ([self.nativeController respondsToSelector:@selector(wasShown)]) { 3155 if ([self.nativeController respondsToSelector:@selector(wasShown)]) {
3167 [self.nativeController wasShown]; 3156 [self.nativeController wasShown];
3168 } 3157 }
3169 } 3158 }
3170 3159
3171 - (void)wasHidden { 3160 - (void)wasHidden {
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4270 linkClicked:linkActivatedNavigation]; 4259 linkClicked:linkActivatedNavigation];
4271 } 4260 }
4272 4261
4273 - (CGFloat)headerHeight { 4262 - (CGFloat)headerHeight {
4274 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) 4263 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)])
4275 return 0.0f; 4264 return 0.0f;
4276 return [_delegate headerHeightForWebController:self]; 4265 return [_delegate headerHeightForWebController:self];
4277 } 4266 }
4278 4267
4279 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { 4268 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url {
4280 _webStateImpl->GetRequestTracker()->HistoryStateChange(url);
4281 [_delegate webDidUpdateHistoryStateWithPageURL:url]; 4269 [_delegate webDidUpdateHistoryStateWithPageURL:url];
4282 } 4270 }
4283 4271
4284 - (void)updateSSLStatusForCurrentNavigationItem { 4272 - (void)updateSSLStatusForCurrentNavigationItem {
4285 if (_isBeingDestroyed) { 4273 if (_isBeingDestroyed) {
4286 return; 4274 return;
4287 } 4275 }
4288 4276
4289 web::NavigationManager* navManager = self.webState->GetNavigationManager(); 4277 web::NavigationManager* navManager = self.webState->GetNavigationManager();
4290 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); 4278 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem();
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 } 5488 }
5501 5489
5502 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5490 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5503 } 5491 }
5504 5492
5505 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5493 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5506 return [action.request valueForHTTPHeaderField:@"Referer"]; 5494 return [action.request valueForHTTPHeaderField:@"Referer"];
5507 } 5495 }
5508 5496
5509 @end 5497 @end
OLDNEW
« no previous file with comments | « no previous file | ios/web/web_state/web_state_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698