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

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

Issue 2582373002: Call registerLoadRequest with URL instead of VirtualURL. (Closed)
Patch Set: fix virtual Created 4 years 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 | no next file » | 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 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 [self loadNativeViewWithSuccess:NO]; 1982 [self loadNativeViewWithSuccess:NO];
1983 } 1983 }
1984 1984
1985 // Load the current URL in a native controller, retrieved from the native 1985 // Load the current URL in a native controller, retrieved from the native
1986 // provider. Call |loadNativeViewWithSuccess:YES| to load the native controller. 1986 // provider. Call |loadNativeViewWithSuccess:YES| to load the native controller.
1987 - (void)loadCurrentURLInNativeView { 1987 - (void)loadCurrentURLInNativeView {
1988 // Free the web view. 1988 // Free the web view.
1989 [self removeWebViewAllowingCachedReconstruction:NO]; 1989 [self removeWebViewAllowingCachedReconstruction:NO];
1990 1990
1991 web::NavigationItem* item = [self currentNavItem]; 1991 web::NavigationItem* item = [self currentNavItem];
1992 const GURL targetURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); 1992 const GURL targetURL = item ? item->GetURL() : GURL::EmptyGURL();
1993 const web::Referrer referrer; 1993 const web::Referrer referrer;
1994 id<CRWNativeContent> nativeContent = 1994 id<CRWNativeContent> nativeContent =
1995 [_nativeProvider controllerForURL:targetURL]; 1995 [_nativeProvider controllerForURL:targetURL];
1996 // Unlike the WebView case, always create a new controller and view. 1996 // Unlike the WebView case, always create a new controller and view.
1997 // TODO(pinkerton): What to do if this does return nil? 1997 // TODO(pinkerton): What to do if this does return nil?
1998 [self setNativeController:nativeContent]; 1998 [self setNativeController:nativeContent];
1999 if ([nativeContent respondsToSelector:@selector(virtualURL)]) { 1999 if ([nativeContent respondsToSelector:@selector(virtualURL)]) {
2000 item->SetVirtualURL([nativeContent virtualURL]); 2000 item->SetVirtualURL([nativeContent virtualURL]);
2001 } 2001 }
2002 [self registerLoadRequest:targetURL 2002 const GURL virtualURL = item ? item->GetVirtualURL() : GURL::EmptyGURL();
2003 [self registerLoadRequest:virtualURL
Olivier 2016/12/19 12:18:59 All other calls to this method take the virtualURL
Olivier 2016/12/19 13:00:04 Obsolete. I add to change this everywhere as regis
2003 referrer:referrer 2004 referrer:referrer
2004 transition:[self currentTransition]]; 2005 transition:[self currentTransition]];
2005 [self loadNativeViewWithSuccess:YES]; 2006 [self loadNativeViewWithSuccess:YES];
2006 } 2007 }
2007 2008
2008 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { 2009 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams {
2009 // Make a copy of |params|, as some of the delegate methods may modify it. 2010 // Make a copy of |params|, as some of the delegate methods may modify it.
2010 NavigationManager::WebLoadParams params(originalParams); 2011 NavigationManager::WebLoadParams params(originalParams);
2011 2012
2012 // Initiating a navigation from the UI, record the current page state before 2013 // Initiating a navigation from the UI, record the current page state before
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 // Abort any outstanding page load. This ensures the delegate gets informed 2080 // Abort any outstanding page load. This ensures the delegate gets informed
2080 // about the outgoing page, and further messages from the page are suppressed. 2081 // about the outgoing page, and further messages from the page are suppressed.
2081 if (_loadPhase != web::PAGE_LOADED) 2082 if (_loadPhase != web::PAGE_LOADED)
2082 [self abortLoad]; 2083 [self abortLoad];
2083 2084
2084 DCHECK(!_isHalted); 2085 DCHECK(!_isHalted);
2085 // Remove the transient content view. 2086 // Remove the transient content view.
2086 [self clearTransientContentView]; 2087 [self clearTransientContentView];
2087 2088
2088 web::NavigationItem* item = [self currentNavItem]; 2089 web::NavigationItem* item = [self currentNavItem];
2089 const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); 2090 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL();
2090 // If it's a chrome URL, but not a native one, create the WebUI instance. 2091 // If it's a chrome URL, but not a native one, create the WebUI instance.
2091 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && 2092 if (web::GetWebClient()->IsAppSpecificURL(currentURL) &&
2092 ![_nativeProvider hasControllerForURL:currentURL]) { 2093 ![_nativeProvider hasControllerForURL:currentURL]) {
2093 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || 2094 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED ||
2094 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && 2095 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) &&
2095 self.sessionController.openedByDOM) { 2096 self.sessionController.openedByDOM) {
2096 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as 2097 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as
2097 // they have increased power. WebUI URLs may only be opened when the user 2098 // they have increased power. WebUI URLs may only be opened when the user
2098 // types in the URL or use bookmarks. 2099 // types in the URL or use bookmarks.
2099 [[self sessionController] discardNonCommittedEntries]; 2100 [[self sessionController] discardNonCommittedEntries];
2100 return; 2101 return;
2101 } else { 2102 } else {
2102 [self createWebUIForURL:currentURL]; 2103 [self createWebUIForURL:currentURL];
Olivier 2016/12/19 12:18:59 I think it is OK to build webUI based on URL.
2103 } 2104 }
2104 } 2105 }
2105 2106
2106 // Loading a new url, must check here if it's a native chrome URL and 2107 // Loading a new url, must check here if it's a native chrome URL and
2107 // replace the appropriate view if so, or transition back to a web view from 2108 // replace the appropriate view if so, or transition back to a web view from
2108 // a native view. 2109 // a native view.
2109 if ([self shouldLoadURLInNativeView:currentURL]) { 2110 if ([self shouldLoadURLInNativeView:currentURL]) {
2110 [self loadCurrentURLInNativeView]; 2111 [self loadCurrentURLInNativeView];
2111 } else { 2112 } else {
2112 [self loadCurrentURLInWebView]; 2113 [self loadCurrentURLInWebView];
(...skipping 3670 matching lines...) Expand 10 before | Expand all | Expand 10 after
5783 } 5784 }
5784 5785
5785 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 5786 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
5786 } 5787 }
5787 5788
5788 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { 5789 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action {
5789 return [action.request valueForHTTPHeaderField:@"Referer"]; 5790 return [action.request valueForHTTPHeaderField:@"Referer"];
5790 } 5791 }
5791 5792
5792 @end 5793 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698