| 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 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 - (BOOL)atTop { | 1259 - (BOOL)atTop { |
| 1260 if (!_webView) | 1260 if (!_webView) |
| 1261 return YES; | 1261 return YES; |
| 1262 UIScrollView* scrollView = self.webScrollView; | 1262 UIScrollView* scrollView = self.webScrollView; |
| 1263 return scrollView.contentOffset.y == -scrollView.contentInset.top; | 1263 return scrollView.contentOffset.y == -scrollView.contentInset.top; |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 - (GURL)currentURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel { | 1266 - (GURL)currentURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel { |
| 1267 DCHECK(trustLevel) << "Verification of the trustLevel state is mandatory"; | 1267 DCHECK(trustLevel) << "Verification of the trustLevel state is mandatory"; |
| 1268 if (_webView) { | 1268 if (_webView) { |
| 1269 GURL url([self webURLWithTrustLevel:trustLevel]); | 1269 return [self webURLWithTrustLevel:trustLevel]; |
| 1270 // Web views treat all about: URLs as the same origin, which makes it | |
| 1271 // possible for pages to document.write into about:<foo> pages, where <foo> | |
| 1272 // can be something misleading. Report any about: URL as about:blank to | |
| 1273 // prevent that. See crbug.com/326118 | |
| 1274 if (url.scheme() == url::kAboutScheme) | |
| 1275 return GURL(url::kAboutBlankURL); | |
| 1276 return url; | |
| 1277 } | 1270 } |
| 1278 // Any non-web URL source is trusted. | 1271 // Any non-web URL source is trusted. |
| 1279 *trustLevel = web::URLVerificationTrustLevel::kAbsolute; | 1272 *trustLevel = web::URLVerificationTrustLevel::kAbsolute; |
| 1280 if (self.nativeController) { | 1273 if (self.nativeController) { |
| 1281 if ([self.nativeController respondsToSelector:@selector(virtualURL)]) { | 1274 if ([self.nativeController respondsToSelector:@selector(virtualURL)]) { |
| 1282 return [self.nativeController virtualURL]; | 1275 return [self.nativeController virtualURL]; |
| 1283 } else { | 1276 } else { |
| 1284 return [self.nativeController url]; | 1277 return [self.nativeController url]; |
| 1285 } | 1278 } |
| 1286 } | 1279 } |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 | 2127 |
| 2135 _loadPhase = web::PAGE_LOADED; | 2128 _loadPhase = web::PAGE_LOADED; |
| 2136 | 2129 |
| 2137 [self optOutScrollsToTopForSubviews]; | 2130 [self optOutScrollsToTopForSubviews]; |
| 2138 | 2131 |
| 2139 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation | 2132 DCHECK((currentURL == _lastRegisteredRequestURL) || // latest navigation |
| 2140 // previous navigation | 2133 // previous navigation |
| 2141 ![[_navigationStates lastAddedNavigation] isEqual:navigation] || | 2134 ![[_navigationStates lastAddedNavigation] isEqual:navigation] || |
| 2142 // invalid URL load | 2135 // invalid URL load |
| 2143 (!_lastRegisteredRequestURL.is_valid() && | 2136 (!_lastRegisteredRequestURL.is_valid() && |
| 2144 _documentURL.spec() == url::kAboutBlankURL)) | 2137 _documentURL.spec() == url::kAboutBlankURL) || |
| 2138 // about URL was changed by WebKit (e.g. about:newtab -> about:blank) |
| 2139 (_lastRegisteredRequestURL.scheme() == url::kAboutScheme && |
| 2140 currentURL.spec() == url::kAboutBlankURL)) |
| 2145 << std::endl | 2141 << std::endl |
| 2146 << "currentURL = [" << currentURL << "]" << std::endl | 2142 << "currentURL = [" << currentURL << "]" << std::endl |
| 2147 << "_lastRegisteredRequestURL = [" << _lastRegisteredRequestURL << "]"; | 2143 << "_lastRegisteredRequestURL = [" << _lastRegisteredRequestURL << "]"; |
| 2148 | 2144 |
| 2149 // Perform post-load-finished updates. | 2145 // Perform post-load-finished updates. |
| 2150 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; | 2146 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; |
| 2151 | 2147 |
| 2152 // Execute the pending LoadCompleteActions. | 2148 // Execute the pending LoadCompleteActions. |
| 2153 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { | 2149 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { |
| 2154 action(); | 2150 action(); |
| (...skipping 3077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5232 - (NSUInteger)observerCount { | 5228 - (NSUInteger)observerCount { |
| 5233 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5229 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
| 5234 return [_observers count]; | 5230 return [_observers count]; |
| 5235 } | 5231 } |
| 5236 | 5232 |
| 5237 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5233 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5238 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5234 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5239 } | 5235 } |
| 5240 | 5236 |
| 5241 @end | 5237 @end |
| OLD | NEW |