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 targetURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1992 const GURL targetURL = item ? item->GetURL() : GURL::EmptyGURL(); |
Eugene But (OOO till 7-30)
2016/12/19 17:49:55
This looks right to me and I tested that Native Co
| |
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 [self registerLoadRequest:targetURL |
Olivier
2016/12/19 20:09:55
I can split the CL, but please note that because o
kkhorimoto
2016/12/19 21:11:54
You can upload dependent CLs by using 'git-new-bra
Olivier
2016/12/19 21:19:09
OK.
Splitting the CL will also mean adapt the unit
| |
2003 referrer:referrer | 2003 referrer:referrer |
2004 transition:[self currentTransition]]; | 2004 transition:[self currentTransition]]; |
2005 [self loadNativeViewWithSuccess:YES]; | 2005 [self loadNativeViewWithSuccess:YES]; |
2006 } | 2006 } |
2007 | 2007 |
2008 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { | 2008 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams { |
2009 // Make a copy of |params|, as some of the delegate methods may modify it. | 2009 // Make a copy of |params|, as some of the delegate methods may modify it. |
2010 NavigationManager::WebLoadParams params(originalParams); | 2010 NavigationManager::WebLoadParams params(originalParams); |
2011 | 2011 |
2012 // Initiating a navigation from the UI, record the current page state before | 2012 // Initiating a navigation from the UI, record the current page state before |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2079 // Abort any outstanding page load. This ensures the delegate gets informed | 2079 // Abort any outstanding page load. This ensures the delegate gets informed |
2080 // about the outgoing page, and further messages from the page are suppressed. | 2080 // about the outgoing page, and further messages from the page are suppressed. |
2081 if (_loadPhase != web::PAGE_LOADED) | 2081 if (_loadPhase != web::PAGE_LOADED) |
2082 [self abortLoad]; | 2082 [self abortLoad]; |
2083 | 2083 |
2084 DCHECK(!_isHalted); | 2084 DCHECK(!_isHalted); |
2085 // Remove the transient content view. | 2085 // Remove the transient content view. |
2086 [self clearTransientContentView]; | 2086 [self clearTransientContentView]; |
2087 | 2087 |
2088 web::NavigationItem* item = [self currentNavItem]; | 2088 web::NavigationItem* item = [self currentNavItem]; |
2089 const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 2089 const GURL currentURL = item ? item->GetURL() : GURL::EmptyGURL(); |
Eugene But (OOO till 7-30)
2016/12/19 17:49:55
This looks right to me and I tested that WebUI wor
| |
2090 // If it's a chrome URL, but not a native one, create the WebUI instance. | 2090 // If it's a chrome URL, but not a native one, create the WebUI instance. |
2091 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && | 2091 if (web::GetWebClient()->IsAppSpecificURL(currentURL) && |
2092 ![_nativeProvider hasControllerForURL:currentURL]) { | 2092 ![_nativeProvider hasControllerForURL:currentURL]) { |
2093 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || | 2093 if (!(item->GetTransitionType() & ui::PAGE_TRANSITION_TYPED || |
2094 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && | 2094 item->GetTransitionType() & ui::PAGE_TRANSITION_AUTO_BOOKMARK) && |
2095 self.sessionController.openedByDOM) { | 2095 self.sessionController.openedByDOM) { |
2096 // WebUI URLs can not be opened by DOM to prevent cross-site scripting as | 2096 // 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 | 2097 // they have increased power. WebUI URLs may only be opened when the user |
2098 // types in the URL or use bookmarks. | 2098 // types in the URL or use bookmarks. |
2099 [[self sessionController] discardNonCommittedEntries]; | 2099 [[self sessionController] discardNonCommittedEntries]; |
(...skipping 3522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5622 NSData* POSTData = currentItem->GetPostData(); | 5622 NSData* POSTData = currentItem->GetPostData(); |
5623 NSMutableURLRequest* request = [self requestForCurrentNavigationItem]; | 5623 NSMutableURLRequest* request = [self requestForCurrentNavigationItem]; |
5624 | 5624 |
5625 // If the request has POST data and is not a form resubmission, configure and | 5625 // If the request has POST data and is not a form resubmission, configure and |
5626 // run the POST request. | 5626 // run the POST request. |
5627 if (POSTData.length && !isFormPOSTResubmission) { | 5627 if (POSTData.length && !isFormPOSTResubmission) { |
5628 [request setHTTPMethod:@"POST"]; | 5628 [request setHTTPMethod:@"POST"]; |
5629 [request setHTTPBody:POSTData]; | 5629 [request setHTTPBody:POSTData]; |
5630 [request setAllHTTPHeaderFields:[self currentHTTPHeaders]]; | 5630 [request setAllHTTPHeaderFields:[self currentHTTPHeaders]]; |
5631 GURL navigationURL = | 5631 GURL navigationURL = |
5632 currentItem ? currentItem->GetVirtualURL() : GURL::EmptyGURL(); | 5632 currentItem ? currentItem->GetURL() : GURL::EmptyGURL(); |
Eugene But (OOO till 7-30)
2016/12/19 17:49:55
Changing |loadRequestForCurrentNavigationItem| loo
| |
5633 [self registerLoadRequest:navigationURL | 5633 [self registerLoadRequest:navigationURL |
5634 referrer:[self currentSessionEntryReferrer] | 5634 referrer:[self currentSessionEntryReferrer] |
5635 transition:[self currentTransition]]; | 5635 transition:[self currentTransition]]; |
5636 [self loadPOSTRequest:request]; | 5636 [self loadPOSTRequest:request]; |
5637 return; | 5637 return; |
5638 } | 5638 } |
5639 | 5639 |
5640 ProceduralBlock defaultNavigationBlock = ^{ | 5640 ProceduralBlock defaultNavigationBlock = ^{ |
5641 web::NavigationItem* item = [self currentNavItem]; | 5641 web::NavigationItem* item = [self currentNavItem]; |
5642 GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 5642 GURL navigationURL = item ? item->GetURL() : GURL::EmptyGURL(); |
5643 [self registerLoadRequest:navigationURL | 5643 [self registerLoadRequest:navigationURL |
5644 referrer:[self currentSessionEntryReferrer] | 5644 referrer:[self currentSessionEntryReferrer] |
5645 transition:[self currentTransition]]; | 5645 transition:[self currentTransition]]; |
5646 [self loadRequest:request]; | 5646 [self loadRequest:request]; |
5647 }; | 5647 }; |
5648 | 5648 |
5649 // When navigating via WKBackForwardListItem to pages created or updated by | 5649 // When navigating via WKBackForwardListItem to pages created or updated by |
5650 // calls to pushState() and replaceState(), sometimes core.js is not injected | 5650 // calls to pushState() and replaceState(), sometimes core.js is not injected |
5651 // correctly. This means that calling window.history navigation functions | 5651 // correctly. This means that calling window.history navigation functions |
5652 // will invoke WKWebView's non-overridden implementations, causing a mismatch | 5652 // will invoke WKWebView's non-overridden implementations, causing a mismatch |
(...skipping 14 matching lines...) Expand all Loading... | |
5667 defaultNavigationBlock(); | 5667 defaultNavigationBlock(); |
5668 return; | 5668 return; |
5669 } | 5669 } |
5670 | 5670 |
5671 ProceduralBlock webViewNavigationBlock = ^{ | 5671 ProceduralBlock webViewNavigationBlock = ^{ |
5672 // If the current navigation URL is the same as the URL of the visible | 5672 // If the current navigation URL is the same as the URL of the visible |
5673 // page, that means the user requested a reload. |goToBackForwardListItem| | 5673 // page, that means the user requested a reload. |goToBackForwardListItem| |
5674 // will be a no-op when it is passed the current back forward list item, | 5674 // will be a no-op when it is passed the current back forward list item, |
5675 // so |reload| must be explicitly called. | 5675 // so |reload| must be explicitly called. |
5676 web::NavigationItem* item = [self currentNavItem]; | 5676 web::NavigationItem* item = [self currentNavItem]; |
5677 GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 5677 GURL navigationURL = item ? item->GetURL() : GURL::EmptyGURL(); |
5678 [self registerLoadRequest:navigationURL | 5678 [self registerLoadRequest:navigationURL |
5679 referrer:[self currentSessionEntryReferrer] | 5679 referrer:[self currentSessionEntryReferrer] |
5680 transition:[self currentTransition]]; | 5680 transition:[self currentTransition]]; |
5681 if (navigationURL == net::GURLWithNSURL([_webView URL])) { | 5681 if (navigationURL == net::GURLWithNSURL([_webView URL])) { |
5682 [_webView reload]; | 5682 [_webView reload]; |
5683 } else { | 5683 } else { |
5684 // |didCommitNavigation:| may not be called for fast navigation, so update | 5684 // |didCommitNavigation:| may not be called for fast navigation, so update |
5685 // the navigation type now as it is already known. | 5685 // the navigation type now as it is already known. |
5686 holder->set_navigation_type(WKNavigationTypeBackForward); | 5686 holder->set_navigation_type(WKNavigationTypeBackForward); |
5687 [_webView goToBackForwardListItem:holder->back_forward_list_item()]; | 5687 [_webView goToBackForwardListItem:holder->back_forward_list_item()]; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5783 } | 5783 } |
5784 | 5784 |
5785 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5785 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
5786 } | 5786 } |
5787 | 5787 |
5788 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5788 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
5789 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5789 return [action.request valueForHTTPHeaderField:@"Referer"]; |
5790 } | 5790 } |
5791 | 5791 |
5792 @end | 5792 @end |
OLD | NEW |