Clarify that WebContents::GetLastCommittedURL returns the virtual URL.
NavigationHandle::GetURL is not necessarily consistent with
WebContents::GetLastCommittedURL, as the URL being navigated to may be
changed for display in the URL bar. For example, when viewing the page
source, NavigationHandle::GetURL returns the page's URL, but
WebContents::GetLastCommittedURL returns the URL prefixed with
"view-source:". This CL notes the difference in the header comments for
both methods.
BUG=618553
Review-Url: https://codereview.chromium.org/2076063002
Cr-Commit-Position: refs/heads/master@{#400857}
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 90b647e..9ccb6fe 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -203,16 +203,20 @@
// |GetLastCommittedURL| as appropriate.
virtual const GURL& GetURL() const = 0;
- // Gets the URL currently being displayed in the URL bar, if there is one.
- // This URL might be a pending navigation that hasn't committed yet, so it is
- // not guaranteed to match the current page in this WebContents. A typical
- // example of this is interstitials, which show the URL of the new/loading
- // page (active) but the security context is of the old page (last committed).
+ // Gets the virtual URL currently being displayed in the URL bar, if there is
+ // one. This URL might be a pending navigation that hasn't committed yet, so
+ // it is not guaranteed to match the current page in this WebContents. A
+ // typical example of this is interstitials, which show the URL of the
+ // new/loading page (active) but the security context is of the old page (last
+ // committed).
virtual const GURL& GetVisibleURL() const = 0;
- // Gets the last committed URL. It represents the current page that is
- // displayed in this WebContents. It represents the current security
- // context.
+ // Gets the virtual URL of the last committed page in this WebContents.
+ // Virtual URLs are meant to be displayed to the user (e.g., they include the
+ // "view-source:" prefix for view source URLs, unlike NavigationEntry::GetURL
+ // and NavigationHandle::GetURL). The last committed page is the current
+ // security context and the content that is actually displayed within the tab.
+ // See also GetVisibleURL above, which may differ from this URL.
virtual const GURL& GetLastCommittedURL() const = 0;
// Return the currently active RenderProcessHost and RenderViewHost. Each of