| 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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 4824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4835 // lastRegisteredRequestURL may be the same as the webViewURL on a new tab | 4835 // lastRegisteredRequestURL may be the same as the webViewURL on a new tab |
| 4836 // created by window.open (default is about::blank). | 4836 // created by window.open (default is about::blank). |
| 4837 if (self.lastRegisteredRequestURL != webViewURL || | 4837 if (self.lastRegisteredRequestURL != webViewURL || |
| 4838 self.loadPhase != web::LOAD_REQUESTED) { | 4838 self.loadPhase != web::LOAD_REQUESTED) { |
| 4839 // Reset current WebUI if one exists. | 4839 // Reset current WebUI if one exists. |
| 4840 [self clearWebUI]; | 4840 [self clearWebUI]; |
| 4841 // Restart app specific URL loads to properly capture state. | 4841 // Restart app specific URL loads to properly capture state. |
| 4842 // TODO(crbug.com/546347): Extract necessary tasks for app specific URL | 4842 // TODO(crbug.com/546347): Extract necessary tasks for app specific URL |
| 4843 // navigation rather than restarting the load. | 4843 // navigation rather than restarting the load. |
| 4844 if (web::GetWebClient()->IsAppSpecificURL(webViewURL)) { | 4844 if (web::GetWebClient()->IsAppSpecificURL(webViewURL)) { |
| 4845 [self abortWebLoad]; | 4845 // Renderer-initiated loads of WebUI can be done only from other WebUI |
| 4846 NavigationManager::WebLoadParams params(webViewURL); | 4846 // pages. WebUI pages may have increased power and using the same web |
| 4847 [self loadWithParams:params]; | 4847 // process (which may potentially be controller by an attacker) is |
| 4848 // dangerous. |
| 4849 if (web::GetWebClient()->IsAppSpecificURL(_documentURL)) { |
| 4850 [self abortWebLoad]; |
| 4851 NavigationManager::WebLoadParams params(webViewURL); |
| 4852 [self loadWithParams:params]; |
| 4853 } |
| 4848 return; | 4854 return; |
| 4849 } else { | 4855 } else { |
| 4850 [self registerLoadRequest:webViewURL]; | 4856 [self registerLoadRequest:webViewURL]; |
| 4851 } | 4857 } |
| 4852 } | 4858 } |
| 4853 // Ensure the URL is registered and loadPhase is as expected. | 4859 // Ensure the URL is registered and loadPhase is as expected. |
| 4854 DCHECK(self.lastRegisteredRequestURL == webViewURL); | 4860 DCHECK(self.lastRegisteredRequestURL == webViewURL); |
| 4855 DCHECK(self.loadPhase == web::LOAD_REQUESTED); | 4861 DCHECK(self.loadPhase == web::LOAD_REQUESTED); |
| 4856 _latestWKNavigation.reset([navigation retain]); | 4862 _latestWKNavigation.reset([navigation retain]); |
| 4857 } | 4863 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5436 } | 5442 } |
| 5437 | 5443 |
| 5438 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5444 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5439 } | 5445 } |
| 5440 | 5446 |
| 5441 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5447 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5442 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5448 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5443 } | 5449 } |
| 5444 | 5450 |
| 5445 @end | 5451 @end |
| OLD | NEW |