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 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtualURL = 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:virtualURL]; | 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 const GURL targetURL = item ? item->GetURL() : GURL::EmptyGURL(); | 2002 |
2003 [self registerLoadRequest:targetURL | 2003 [self registerLoadRequest:targetURL |
2004 referrer:referrer | 2004 referrer:referrer |
2005 transition:[self currentTransition]]; | 2005 transition:[self currentTransition]]; |
2006 [self loadNativeViewWithSuccess:YES]; | 2006 [self loadNativeViewWithSuccess:YES]; |
2007 } | 2007 } |
2008 | 2008 |
2009 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { | 2009 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { |
2010 // 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. |
2011 NavigationManager::WebLoadParams params(originalParams); | 2011 NavigationManager::WebLoadParams params(originalParams); |
2012 | 2012 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 // Abort any outstanding page load. This ensures the delegate gets informed | 2080 // Abort any outstanding page load. This ensures the delegate gets informed |
2081 // 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. |
2082 if (_loadPhase != web::PAGE_LOADED) | 2082 if (_loadPhase != web::PAGE_LOADED) |
2083 [self abortLoad]; | 2083 [self abortLoad]; |
2084 | 2084 |
2085 DCHECK(!_isHalted); | 2085 DCHECK(!_isHalted); |
2086 // Remove the transient content view. | 2086 // Remove the transient content view. |
2087 [self clearTransientContentView]; | 2087 [self clearTransientContentView]; |
2088 | 2088 |
2089 web::NavigationItem* item = [self currentNavItem]; | 2089 web::NavigationItem* item = [self currentNavItem]; |
2090 const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 2090 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); |
2091 // 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. |
2092 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && | 2092 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && |
2093 ![_nativeProvider hasControllerForURL:currentURL]) { | 2093 ![_nativeProvider hasControllerForURL:currentURL]) { |
2094 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || | 2094 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || |
2095 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && | 2095 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && |
2096 self.sessionController.openedByDOM) { | 2096 self.sessionController.openedByDOM) { |
2097 // 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 |
2098 // 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 |
2099 // types in the URL or use bookmarks. | 2099 // types in the URL or use bookmarks. |
2100 [[self sessionController] discardNonCommittedEntries]; | 2100 [[self sessionController] discardNonCommittedEntries]; |
(...skipping 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5784 } | 5784 } |
5785 | 5785 |
5786 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5786 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5787 } | 5787 } |
5788 | 5788 |
5789 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5789 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5790 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5790 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5791 } | 5791 } |
5792 | 5792 |
5793 @end | 5793 @end |
OLD | NEW |