Index: ios/web/web_state/ui/crw_web_controller.mm |
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
index c5a56e9e6f4f5fe587f072fceac3353107996e0e..f2168e68d721fb83024820b2f33a920e2d449218 100644 |
--- a/ios/web/web_state/ui/crw_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_web_controller.mm |
@@ -560,10 +560,6 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { |
- (CRWSessionEntry*)currentSessionEntry; |
// Returns the navigation item for the current page. |
- (web::NavigationItem*)currentNavItem; |
-// Returns the URL that the navigation system believes should be currently |
-// active. |
-// TODO(stuartmorgan):Remove this in favor of more specific getters. |
-- (const GURL&)currentNavigationURL; |
// Returns the current transition type. |
- (ui::PageTransition)currentTransition; |
// Returns the referrer for current navigation item. May be empty. |
@@ -1431,7 +1427,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
return [self.nativeController url]; |
} |
} |
- return [self currentNavigationURL]; |
+ web::NavigationItem* item = [self currentNavItem]; |
+ return item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
} |
- (WKWebView*)webView { |
@@ -1458,8 +1455,9 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
if ([referrerString length] == 0) |
return web::Referrer(); |
- NSString* previousURLString = |
- base::SysUTF8ToNSString([self currentNavigationURL].spec()); |
+ web::NavigationItem* item = [self currentNavItem]; |
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
+ NSString* previousURLString = base::SysUTF8ToNSString(navigationURL.spec()); |
// Check if the referrer is equal to the previous URL minus the hash symbol. |
// L'#' is used to convert the char '#' to a unichar. |
if ([previousURLString length] > [referrerString length] && |
@@ -1833,9 +1831,11 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
// Clear the set of URLs opened in external applications. |
_openedApplicationURL.reset([[NSMutableSet alloc] init]); |
+ web::NavigationItem* item = [self currentNavItem]; |
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
Eugene But (OOO till 7-30)
2016/12/16 17:12:48
s/navigationURL/targetURL and drop |targetURL| var
Olivier
2016/12/19 09:51:48
Done.
|
// Load the url. The UIWebView delegate callbacks take care of updating the |
// session history and UI. |
- const GURL targetURL([self currentNavigationURL]); |
+ const GURL targetURL(navigationURL); |
if (!targetURL.is_valid()) { |
[self didFinishWithURL:targetURL loadSuccess:NO]; |
return; |
@@ -1887,7 +1887,9 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
} |
- (NSMutableURLRequest*)requestForCurrentNavigationItem { |
- const GURL currentNavigationURL([self currentNavigationURL]); |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentNavigationURL = |
+ item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
NSMutableURLRequest* request = [NSMutableURLRequest |
requestWithURL:net::NSURLWithGURL(currentNavigationURL)]; |
const web::Referrer referrer([self currentSessionEntryReferrer]); |
@@ -1972,8 +1974,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
- (void)loadErrorInNativeView:(NSError*)error { |
[self removeWebViewAllowingCachedReconstruction:NO]; |
- |
- const GURL currentUrl = [self currentNavigationURL]; |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
if (web::IsWKWebViewSSLCertError(error)) { |
// This could happen only if certificate is absent or could not be parsed. |
@@ -1988,7 +1990,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
} |
BOOL isPost = [self isCurrentNavigationItemPOST]; |
- [self setNativeController:[_nativeProvider controllerForURL:currentUrl |
+ [self setNativeController:[_nativeProvider controllerForURL:currentURL |
withError:error |
isPost:isPost]]; |
[self loadNativeViewWithSuccess:NO]; |
@@ -2000,7 +2002,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
// Free the web view. |
[self removeWebViewAllowingCachedReconstruction:NO]; |
- const GURL targetURL = [self currentNavigationURL]; |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL targetURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
const web::Referrer referrer; |
id<CRWNativeContent> nativeContent = |
[_nativeProvider controllerForURL:targetURL]; |
@@ -2096,7 +2099,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
// Remove the transient content view. |
[self clearTransientContentView]; |
- const GURL currentURL = [self currentNavigationURL]; |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
// If it's a chrome URL, but not a native one, create the WebUI instance. |
if (web::GetWebClient()->IsAppSpecificURL(currentURL) && |
![_nativeProvider hasControllerForURL:currentURL]) { |
@@ -2163,8 +2167,11 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
[_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; |
[_containerView setAccessibilityIdentifier:web::kContainerViewID]; |
// Is |currentUrl| a web scheme or native chrome scheme. |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentNavigationURL = |
+ item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
BOOL isChromeScheme = |
- web::GetWebClient()->IsAppSpecificURL([self currentNavigationURL]); |
+ web::GetWebClient()->IsAppSpecificURL(currentNavigationURL); |
// Don't immediately load the web page if in overlay mode. Always load if |
// native. |
@@ -3402,9 +3409,12 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
if (isPossibleLinkClick || isOpenInNewTabNavigation || |
PageTransitionCoreTypeIs([self currentTransition], |
ui::PAGE_TRANSITION_AUTO_BOOKMARK)) { |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentNavigationURL = |
+ item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
// Check If the URL is handled by a native app. |
if ([self urlTriggersNativeAppLaunch:requestURL |
- sourceURL:[self currentNavigationURL] |
+ sourceURL:currentNavigationURL |
linkActivatedNavigation:isNavigationTypeLinkActivated]) { |
// External app has been launched successfully. Stop the current page |
// load operation (e.g. notifying all observers) and record the URL so |
@@ -3762,7 +3772,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
- (void)openPopupWithInfo:(const web::NewWindowInfo&)windowInfo { |
const GURL url(windowInfo.url); |
- const GURL currentURL([self currentNavigationURL]); |
+ web::NavigationItem* item = [self currentNavItem]; |
+ const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
NSString* windowName = windowInfo.window_name.get(); |
web::Referrer referrer(currentURL, windowInfo.referrer_policy); |
base::WeakNSObject<CRWWebController> weakSelf(self); |
@@ -4048,14 +4059,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
return [[self currentSessionEntry] navigationItem]; |
} |
-- (const GURL&)currentNavigationURL { |
- // TODO(stuartmorgan): Fix the fact that this method doesn't have clear usage |
- // delination that would allow changing to one of the non-deprecated URL |
- // calls. |
- web::NavigationItem* item = [self currentNavItem]; |
- return item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
-} |
- |
- (ui::PageTransition)currentTransition { |
if ([self currentNavItem]) |
return [self currentNavItem]->GetTransitionType(); |
@@ -4819,10 +4822,13 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
[self.UIDelegate cancelDialogsForWebController:self]; |
_webStateImpl->CancelDialogs(); |
- if (allowCache) |
- _expectedReconstructionURL = [self currentNavigationURL]; |
- else |
+ if (allowCache) { |
Eugene But (OOO till 7-30)
2016/12/16 17:12:48
How about this?:
web::NavigationItem* item = [sel
Olivier
2016/12/19 09:51:48
Done.
|
+ web::NavigationItem* item = [self currentNavItem]; |
+ _expectedReconstructionURL = |
+ item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
+ } else { |
_expectedReconstructionURL = GURL(); |
+ } |
[self abortLoad]; |
[_webView removeFromSuperview]; |
@@ -4912,10 +4918,12 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
// observers of the change via |-abortLoad|. |
[[self sessionController] discardNonCommittedEntries]; |
[self abortLoad]; |
+ web::NavigationItem* item = [self currentNavItem]; |
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
// If discarding the non-committed entries results in an app-specific URL, |
// reload it in its native view. |
if (!self.nativeController && |
- [self shouldLoadURLInNativeView:[self currentNavigationURL]]) { |
+ [self shouldLoadURLInNativeView:navigationURL]) { |
[self loadCurrentURLInNativeView]; |
} |
} |
@@ -5653,7 +5661,9 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
[request setHTTPMethod:@"POST"]; |
[request setHTTPBody:POSTData]; |
[request setAllHTTPHeaderFields:[self currentHTTPHeaders]]; |
- [self registerLoadRequest:[self currentNavigationURL] |
+ web::NavigationItem* item = [self currentNavItem]; |
Eugene But (OOO till 7-30)
2016/12/16 17:12:48
Do you need this variable? Can you use use |curren
Olivier
2016/12/19 09:51:48
Done.
|
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
+ [self registerLoadRequest:navigationURL |
referrer:[self currentSessionEntryReferrer] |
transition:[self currentTransition]]; |
[self loadPOSTRequest:request]; |
@@ -5661,7 +5671,9 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
} |
ProceduralBlock defaultNavigationBlock = ^{ |
- [self registerLoadRequest:[self currentNavigationURL] |
+ web::NavigationItem* item = [self currentNavItem]; |
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
+ [self registerLoadRequest:navigationURL |
referrer:[self currentSessionEntryReferrer] |
transition:[self currentTransition]]; |
[self loadRequest:request]; |
@@ -5694,10 +5706,12 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
// page, that means the user requested a reload. |goToBackForwardListItem| |
// will be a no-op when it is passed the current back forward list item, |
// so |reload| must be explicitly called. |
- [self registerLoadRequest:[self currentNavigationURL] |
+ web::NavigationItem* item = [self currentNavItem]; |
+ GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
+ [self registerLoadRequest:navigationURL |
referrer:[self currentSessionEntryReferrer] |
transition:[self currentTransition]]; |
- if ([self currentNavigationURL] == net::GURLWithNSURL([_webView URL])) { |
+ if (navigationURL == net::GURLWithNSURL([_webView URL])) { |
[_webView reload]; |
} else { |
// |didCommitNavigation:| may not be called for fast navigation, so update |