Commit 6c31de9d authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

Fix DCHECK in WebStateImpl::GetCurrentURL

When navigating to a placeholder URL that replace a
navigation with a virtualURL,
|CRWWebController currentURLWithTrustLevel:| returns
the VirtualURL and not the URL.
Fix the DCHECK.

Bug: 929492
Change-Id: Ib845efc97793ddb9fc665e18f87b243f083a288e
Reviewed-on: https://chromium-review.googlesource.com/c/1489731
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636393}
parent 23ccc9ca
...@@ -687,13 +687,16 @@ const GURL& WebStateImpl::GetLastCommittedURL() const { ...@@ -687,13 +687,16 @@ const GURL& WebStateImpl::GetLastCommittedURL() const {
GURL WebStateImpl::GetCurrentURL(URLVerificationTrustLevel* trust_level) const { GURL WebStateImpl::GetCurrentURL(URLVerificationTrustLevel* trust_level) const {
GURL result = [web_controller_ currentURLWithTrustLevel:trust_level]; GURL result = [web_controller_ currentURLWithTrustLevel:trust_level];
web::NavigationItem* item = navigation_manager_->GetLastCommittedItem(); web::NavigationItemImpl* item =
navigation_manager_->GetLastCommittedItemImpl();
GURL lastCommittedURL; GURL lastCommittedURL;
if (item) { if (item) {
if ([web_controller_.nativeController if ([web_controller_.nativeController
respondsToSelector:@selector(virtualURL)]) { respondsToSelector:@selector(virtualURL)] ||
// For native content |currentURLWithTrustLevel:| returns virtual URL if item->error_retry_state_machine().state() ==
// one is available. ErrorRetryState::kReadyToDisplayErrorForFailedNavigation) {
// For native content, or when webView.URL is a placeholder URL,
// |currentURLWithTrustLevel:| returns virtual URL if one is available.
lastCommittedURL = item->GetVirtualURL(); lastCommittedURL = item->GetVirtualURL();
} else { } else {
// Otherwise document URL is returned. // Otherwise document URL is returned.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment