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 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2311 _webStateImpl->GetRequestTracker()->FinishPageLoad(currentURL, loadSuccess); | 2311 _webStateImpl->GetRequestTracker()->FinishPageLoad(currentURL, loadSuccess); |
| 2312 // Reset the navigation type to the default value. | 2312 // Reset the navigation type to the default value. |
| 2313 // Note: it is possible that the web view has already started loading the | 2313 // Note: it is possible that the web view has already started loading the |
| 2314 // next page when this is called. In that case the cache mode can leak to | 2314 // next page when this is called. In that case the cache mode can leak to |
| 2315 // (some of) the requests of the next page. It's expected to be an edge case, | 2315 // (some of) the requests of the next page. It's expected to be an edge case, |
| 2316 // but if it becomes a problem it should be possible to notice it afterwards | 2316 // but if it becomes a problem it should be possible to notice it afterwards |
| 2317 // and react to it (by warning the user or reloading the page for example). | 2317 // and react to it (by warning the user or reloading the page for example). |
| 2318 _webStateImpl->GetRequestTracker()->SetCacheModeFromUIThread( | 2318 _webStateImpl->GetRequestTracker()->SetCacheModeFromUIThread( |
| 2319 net::RequestTracker::CACHE_NORMAL); | 2319 net::RequestTracker::CACHE_NORMAL); |
| 2320 | 2320 |
| 2321 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, | |
| 2322 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem | |
| 2323 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a | |
| 2324 // result, the WebUI's HTML and URL will be loaded when navigating to that | |
| 2325 // WKBackForwardListeItem, causing a mismatch between the visible content and | |
|
Jackie Quinn
2016/08/11 18:42:38
extra e in WKBackForwardListItem.
Also could you
kkhorimoto
2016/08/11 18:47:10
Done.
| |
| 2326 // the visible URL. To prevent this potential URL spoofing vulnerability, | |
| 2327 // reset the previous NavigationItem's WKBackForwardListItem to force loading | |
| 2328 // via NSURLRequest. | |
| 2329 if (_webUIManager) { | |
| 2330 web::NavigationItem* lastNavigationItem = | |
| 2331 self.sessionController.previousEntry.navigationItem; | |
| 2332 if (lastNavigationItem) { | |
| 2333 web::WKBackForwardListItemHolder* holder = | |
| 2334 web::WKBackForwardListItemHolder::FromNavigationItem( | |
| 2335 lastNavigationItem); | |
| 2336 DCHECK(holder); | |
| 2337 holder->set_back_forward_list_item(nil); | |
| 2338 } | |
| 2339 } | |
| 2340 | |
| 2321 [self restoreStateFromHistory]; | 2341 [self restoreStateFromHistory]; |
| 2322 _webStateImpl->OnPageLoaded(currentURL, loadSuccess); | 2342 _webStateImpl->OnPageLoaded(currentURL, loadSuccess); |
| 2323 _webStateImpl->SetIsLoading(false); | 2343 _webStateImpl->SetIsLoading(false); |
| 2324 // Inform the embedder the load completed. | 2344 // Inform the embedder the load completed. |
| 2325 [_delegate webDidFinishWithURL:currentURL loadSuccess:loadSuccess]; | 2345 [_delegate webDidFinishWithURL:currentURL loadSuccess:loadSuccess]; |
| 2326 } | 2346 } |
| 2327 | 2347 |
| 2328 - (void)finishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 2348 - (void)finishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 2329 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; | 2349 [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry]; |
| 2330 | 2350 |
| (...skipping 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5644 } | 5664 } |
| 5645 | 5665 |
| 5646 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5666 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5647 } | 5667 } |
| 5648 | 5668 |
| 5649 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5669 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5650 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5670 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5651 } | 5671 } |
| 5652 | 5672 |
| 5653 @end | 5673 @end |
| OLD | NEW |