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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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" | 52 #import "ios/web/net/request_group_util.h" |
|
Eugene But (OOO till 7-30)
2017/01/19 19:05:54
nit: Do we still need this include?
sdefresne
2017/01/20 11:31:27
Removed.
| |
| 53 #include "ios/web/public/browser_state.h" | 53 #include "ios/web/public/browser_state.h" |
| 54 #include "ios/web/public/favicon_url.h" | 54 #include "ios/web/public/favicon_url.h" |
| 55 #import "ios/web/public/java_script_dialog_presenter.h" | 55 #import "ios/web/public/java_script_dialog_presenter.h" |
| 56 #import "ios/web/public/navigation_item.h" | 56 #import "ios/web/public/navigation_item.h" |
| 57 #import "ios/web/public/navigation_manager.h" | 57 #import "ios/web/public/navigation_manager.h" |
| 58 #import "ios/web/public/origin_util.h" | 58 #import "ios/web/public/origin_util.h" |
| 59 #include "ios/web/public/referrer.h" | 59 #include "ios/web/public/referrer.h" |
| 60 #include "ios/web/public/referrer_util.h" | 60 #include "ios/web/public/referrer_util.h" |
| 61 #include "ios/web/public/ssl_status.h" | 61 #include "ios/web/public/ssl_status.h" |
| 62 #import "ios/web/public/url_scheme_util.h" | 62 #import "ios/web/public/url_scheme_util.h" |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 @synthesize webUsageEnabled = _webUsageEnabled; | 987 @synthesize webUsageEnabled = _webUsageEnabled; |
| 988 @synthesize usePlaceholderOverlay = _usePlaceholderOverlay; | 988 @synthesize usePlaceholderOverlay = _usePlaceholderOverlay; |
| 989 @synthesize loadPhase = _loadPhase; | 989 @synthesize loadPhase = _loadPhase; |
| 990 @synthesize shouldSuppressDialogs = _shouldSuppressDialogs; | 990 @synthesize shouldSuppressDialogs = _shouldSuppressDialogs; |
| 991 | 991 |
| 992 - (instancetype)initWithWebState:(WebStateImpl*)webState { | 992 - (instancetype)initWithWebState:(WebStateImpl*)webState { |
| 993 self = [super init]; | 993 self = [super init]; |
| 994 if (self) { | 994 if (self) { |
| 995 _webStateImpl = webState; | 995 _webStateImpl = webState; |
| 996 DCHECK(_webStateImpl); | 996 DCHECK(_webStateImpl); |
| 997 _webStateImpl->InitializeRequestTracker(self); | |
| 998 // Load phase when no WebView present is 'loaded' because this represents | 997 // Load phase when no WebView present is 'loaded' because this represents |
| 999 // the idle state. | 998 // the idle state. |
| 1000 _loadPhase = web::PAGE_LOADED; | 999 _loadPhase = web::PAGE_LOADED; |
| 1001 // Content area is lazily instantiated. | 1000 // Content area is lazily instantiated. |
| 1002 _defaultURL = GURL(url::kAboutBlankURL); | 1001 _defaultURL = GURL(url::kAboutBlankURL); |
| 1003 _jsInjectionReceiver.reset( | 1002 _jsInjectionReceiver.reset( |
| 1004 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); | 1003 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); |
| 1005 _webViewProxy.reset( | 1004 _webViewProxy.reset( |
| 1006 [[CRWWebViewProxyImpl alloc] initWithWebController:self]); | 1005 [[CRWWebViewProxyImpl alloc] initWithWebController:self]); |
| 1007 [[_webViewProxy scrollViewProxy] addObserver:self]; | 1006 [[_webViewProxy scrollViewProxy] addObserver:self]; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 | 1218 |
| 1220 // Stop doing stuff, especially network stuff. Close the request tracker. | 1219 // Stop doing stuff, especially network stuff. Close the request tracker. |
| 1221 - (void)terminateNetworkActivity { | 1220 - (void)terminateNetworkActivity { |
| 1222 DCHECK(!_isHalted); | 1221 DCHECK(!_isHalted); |
| 1223 _isHalted = YES; | 1222 _isHalted = YES; |
| 1224 | 1223 |
| 1225 // Cancel all outstanding perform requests, and clear anything already queued | 1224 // Cancel all outstanding perform requests, and clear anything already queued |
| 1226 // (since this may be called from within the handling loop) to prevent any | 1225 // (since this may be called from within the handling loop) to prevent any |
| 1227 // asynchronous JavaScript invocation handling from continuing. | 1226 // asynchronous JavaScript invocation handling from continuing. |
| 1228 [NSObject cancelPreviousPerformRequestsWithTarget:self]; | 1227 [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
| 1229 _webStateImpl->CloseRequestTracker(); | |
| 1230 } | 1228 } |
| 1231 | 1229 |
| 1232 - (void)dismissModals { | 1230 - (void)dismissModals { |
| 1233 if ([self.nativeController respondsToSelector:@selector(dismissModals)]) | 1231 if ([self.nativeController respondsToSelector:@selector(dismissModals)]) |
| 1234 [self.nativeController dismissModals]; | 1232 [self.nativeController dismissModals]; |
| 1235 } | 1233 } |
| 1236 | 1234 |
| 1237 // Caller must reset the delegate before calling. | 1235 // Caller must reset the delegate before calling. |
| 1238 - (void)close { | 1236 - (void)close { |
| 1239 _webStateImpl->CancelDialogs(); | 1237 _webStateImpl->CancelDialogs(); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2150 _webStateImpl->SetIsLoading(false); | 2148 _webStateImpl->SetIsLoading(false); |
| 2151 } | 2149 } |
| 2152 [_delegate webCancelStartLoadingRequest]; | 2150 [_delegate webCancelStartLoadingRequest]; |
| 2153 break; | 2151 break; |
| 2154 case web::PAGE_LOADING: | 2152 case web::PAGE_LOADING: |
| 2155 // The previous load never fully completed before this page change. The | 2153 // The previous load never fully completed before this page change. The |
| 2156 // loadPhase is changed to PAGE_LOADED to indicate the cycle is complete, | 2154 // loadPhase is changed to PAGE_LOADED to indicate the cycle is complete, |
| 2157 // and the delegate is called. | 2155 // and the delegate is called. |
| 2158 _loadPhase = web::PAGE_LOADED; | 2156 _loadPhase = web::PAGE_LOADED; |
| 2159 if (!_isHalted) { | 2157 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); | 2158 _webStateImpl->SetIsLoading(false); |
| 2165 } | 2159 } |
| 2166 [_delegate webLoadCancelled:_URLOnStartLoading]; | 2160 [_delegate webLoadCancelled:_URLOnStartLoading]; |
| 2167 break; | 2161 break; |
| 2168 case web::PAGE_LOADED: | 2162 case web::PAGE_LOADED: |
| 2169 break; | 2163 break; |
| 2170 } | 2164 } |
| 2171 } | 2165 } |
| 2172 | 2166 |
| 2173 - (void)goToItemAtIndex:(int)index { | 2167 - (void)goToItemAtIndex:(int)index { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2265 | 2259 |
| 2266 // Execute the pending LoadCompleteActions. | 2260 // Execute the pending LoadCompleteActions. |
| 2267 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { | 2261 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { |
| 2268 action(); | 2262 action(); |
| 2269 } | 2263 } |
| 2270 [_pendingLoadCompleteActions removeAllObjects]; | 2264 [_pendingLoadCompleteActions removeAllObjects]; |
| 2271 } | 2265 } |
| 2272 | 2266 |
| 2273 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess { | 2267 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess { |
| 2274 DCHECK(_loadPhase == web::PAGE_LOADED); | 2268 DCHECK(_loadPhase == web::PAGE_LOADED); |
| 2275 _webStateImpl->GetRequestTracker()->FinishPageLoad(currentURL, loadSuccess); | |
| 2276 | |
| 2277 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, | 2269 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, |
| 2278 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem | 2270 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem |
| 2279 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a | 2271 // 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 | 2272 // result, the WebUI's HTML and URL will be loaded when navigating to that |
| 2281 // WKBackForwardListItem, causing a mismatch between the visible content and | 2273 // WKBackForwardListItem, causing a mismatch between the visible content and |
| 2282 // the visible URL (WebUI page will be visible, but URL will be the previous | 2274 // 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 | 2275 // page's URL). To prevent this potential URL spoofing vulnerability, reset |
| 2284 // the previous NavigationItem's WKBackForwardListItem to force loading via | 2276 // the previous NavigationItem's WKBackForwardListItem to force loading via |
| 2285 // NSURLRequest. | 2277 // NSURLRequest. |
| 2286 if (_webUIManager) { | 2278 if (_webUIManager) { |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3150 | 3142 |
| 3151 - (void)didStartLoadingURL:(const GURL&)url updateHistory:(BOOL)updateHistory { | 3143 - (void)didStartLoadingURL:(const GURL&)url updateHistory:(BOOL)updateHistory { |
| 3152 _loadPhase = web::PAGE_LOADING; | 3144 _loadPhase = web::PAGE_LOADING; |
| 3153 _URLOnStartLoading = url; | 3145 _URLOnStartLoading = url; |
| 3154 _displayStateOnStartLoading = self.pageDisplayState; | 3146 _displayStateOnStartLoading = self.pageDisplayState; |
| 3155 | 3147 |
| 3156 self.userInteractionRegistered = NO; | 3148 self.userInteractionRegistered = NO; |
| 3157 _pageHasZoomed = NO; | 3149 _pageHasZoomed = NO; |
| 3158 | 3150 |
| 3159 [[self sessionController] commitPendingEntry]; | 3151 [[self sessionController] commitPendingEntry]; |
| 3160 _webStateImpl->GetRequestTracker()->StartPageLoad( | |
| 3161 url, [[self sessionController] currentEntry]); | |
| 3162 [_delegate webDidStartLoadingURL:url shouldUpdateHistory:updateHistory]; | 3152 [_delegate webDidStartLoadingURL:url shouldUpdateHistory:updateHistory]; |
| 3163 } | 3153 } |
| 3164 | 3154 |
| 3165 - (void)wasShown { | 3155 - (void)wasShown { |
| 3166 if ([self.nativeController respondsToSelector:@selector(wasShown)]) { | 3156 if ([self.nativeController respondsToSelector:@selector(wasShown)]) { |
| 3167 [self.nativeController wasShown]; | 3157 [self.nativeController wasShown]; |
| 3168 } | 3158 } |
| 3169 } | 3159 } |
| 3170 | 3160 |
| 3171 - (void)wasHidden { | 3161 - (void)wasHidden { |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4282 linkClicked:linkActivatedNavigation]; | 4272 linkClicked:linkActivatedNavigation]; |
| 4283 } | 4273 } |
| 4284 | 4274 |
| 4285 - (CGFloat)headerHeight { | 4275 - (CGFloat)headerHeight { |
| 4286 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) | 4276 if (![_delegate respondsToSelector:@selector(headerHeightForWebController:)]) |
| 4287 return 0.0f; | 4277 return 0.0f; |
| 4288 return [_delegate headerHeightForWebController:self]; | 4278 return [_delegate headerHeightForWebController:self]; |
| 4289 } | 4279 } |
| 4290 | 4280 |
| 4291 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { | 4281 - (void)didUpdateHistoryStateWithPageURL:(const GURL&)url { |
| 4292 _webStateImpl->GetRequestTracker()->HistoryStateChange(url); | |
| 4293 [_delegate webDidUpdateHistoryStateWithPageURL:url]; | 4282 [_delegate webDidUpdateHistoryStateWithPageURL:url]; |
| 4294 } | 4283 } |
| 4295 | 4284 |
| 4296 - (void)updateSSLStatusForCurrentNavigationItem { | 4285 - (void)updateSSLStatusForCurrentNavigationItem { |
| 4297 if (_isBeingDestroyed) { | 4286 if (_isBeingDestroyed) { |
| 4298 return; | 4287 return; |
| 4299 } | 4288 } |
| 4300 | 4289 |
| 4301 web::NavigationManager* navManager = self.webState->GetNavigationManager(); | 4290 web::NavigationManager* navManager = self.webState->GetNavigationManager(); |
| 4302 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); | 4291 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5514 } | 5503 } |
| 5515 | 5504 |
| 5516 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5505 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5517 } | 5506 } |
| 5518 | 5507 |
| 5519 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5508 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5520 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5509 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5521 } | 5510 } |
| 5522 | 5511 |
| 5523 @end | 5512 @end |
| OLD | NEW |