Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 13846007: Allow showing pending URL for new tab navigations, but only if safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 8612ef126abb81164f22fdf96cad838f4a05f1db..064d4cb218e44593948411a06affc49dab859164 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -709,7 +709,7 @@ BrowserContext* WebContentsImpl::GetBrowserContext() const {
const GURL& WebContentsImpl::GetURL() const {
// We may not have a navigation entry yet
- NavigationEntry* entry = controller_.GetActiveEntry();
+ NavigationEntry* entry = controller_.GetVisibleEntry();
return entry ? entry->GetVirtualURL() : GURL::EmptyGURL();
}
@@ -855,7 +855,7 @@ const string16& WebContentsImpl::GetTitle() const {
render_manager_.pending_web_ui() : render_manager_.web_ui();
if (our_web_ui) {
// Don't override the title in view source mode.
- entry = controller_.GetActiveEntry();
+ entry = controller_.GetVisibleEntry();
if (!(entry && entry->IsViewSourceMode())) {
// Give the Web UI the chance to override our title.
const string16& title = our_web_ui->GetOverriddenTitle();
@@ -869,6 +869,13 @@ const string16& WebContentsImpl::GetTitle() const {
// keep the old page's title until the new load has committed and we get a new
// title.
entry = controller_.GetLastCommittedEntry();
+
+ // We make an exception for initial navigations, because we can have a
+ // committed entry for an initial navigation when doing a history navigation
+ // in a new tab, such as Ctrl+Back.
+ if (entry && controller_.IsInitialNavigation())
+ entry = controller_.GetVisibleEntry();
+
if (entry) {
return entry->GetTitleForDisplay(accept_languages);
}
@@ -1971,6 +1978,23 @@ void WebContentsImpl::DidStartProvisionalLoadForFrame(
if (is_main_frame)
DidChangeLoadProgress(0);
+ // Create a pending entry for this provisional load (if none exists) using the
+ // current SiteInstance, and ensure the address bar updates accordingly.
+ // We don't know the referrer or extra headers at this point, but the referrer
+ // will be set properly upon commit.
+ if (is_main_frame && !controller_.GetPendingEntry()) {
+ NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
+ controller_.CreateNavigationEntry(validated_url,
+ content::Referrer(),
+ content::PAGE_TRANSITION_LINK,
+ true /* is_renderer_initiated */,
+ std::string(), GetBrowserContext()));
+ entry->set_site_instance(
+ static_cast<SiteInstanceImpl*>(GetSiteInstance()));
+ controller_.SetPendingEntry(entry);
+ NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
+ }
+
// Notify observers about the start of the provisional load.
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidStartProvisionalLoadForFrame(frame_id, parent_frame_id,
@@ -2910,6 +2934,11 @@ void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) {
render_manager_.DidUpdateFrameTree(rvh);
}
+void WebContentsImpl::DidAccessInitialDocument() {
+ // Update the URL display.
+ NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
+}
+
void WebContentsImpl::DocumentAvailableInMainFrame(
RenderViewHost* render_view_host) {
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698