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 4802886938a4dc9816d57cf2cbdd3b68a40deca7..f0fb76831d2eb9f8561ab5d87f67dbf267c221df 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -712,21 +712,15 @@ BrowserContext* WebContentsImpl::GetBrowserContext() const { |
} |
const GURL& WebContentsImpl::GetURL() const { |
- // We may not have a navigation entry yet. |
- NavigationEntry* entry = controller_.GetVisibleEntry(); |
- return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
+ return controller_.GetVisibleEntry()->GetVirtualURL(); |
} |
const GURL& WebContentsImpl::GetVisibleURL() const { |
- // We may not have a navigation entry yet. |
- NavigationEntry* entry = controller_.GetVisibleEntry(); |
- return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
+ return controller_.GetVisibleEntry()->GetVirtualURL(); |
} |
const GURL& WebContentsImpl::GetLastCommittedURL() const { |
- // We may not have a navigation entry yet. |
- NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
- return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
+ return controller_.GetLastCommittedEntry()->GetVirtualURL(); |
} |
WebContentsDelegate* WebContentsImpl::GetDelegate() { |
@@ -955,19 +949,17 @@ const base::string16& WebContentsImpl::GetTitle() const { |
// Otherwise, we want to stick with the last committed entry's title during |
// new navigations, which have pending entries at index -1 with no title. |
if (controller_.IsInitialNavigation() && |
- ((controller_.GetVisibleEntry() && |
- !controller_.GetVisibleEntry()->GetTitle().empty()) || |
+ (!controller_.GetVisibleEntry()->GetTitle().empty() || |
controller_.GetPendingEntryIndex() != -1)) { |
entry = controller_.GetVisibleEntry(); |
} |
- if (entry) { |
- return entry->GetTitleForDisplay(accept_languages); |
- } |
+ // Return the empty string (not about:blank) for the initial blank page. |
+ if (controller_.IsInitialNavigation() && |
+ entry == controller_.GetLastCommittedEntry()) |
+ return entry->GetTitle(); |
- // |page_title_when_no_navigation_entry_| is finally used |
- // if no title cannot be retrieved. |
- return page_title_when_no_navigation_entry_; |
+ return entry->GetTitleForDisplay(accept_languages); |
} |
int32 WebContentsImpl::GetMaxPageID() { |
@@ -1352,6 +1344,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
params.routing_id, params.main_frame_routing_id, |
MSG_ROUTING_NONE); |
frame_tree_.root()->SetFrameName(params.main_frame_name); |
+ controller_.Init(params.site_instance); |
WebContentsViewDelegate* delegate = |
GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
@@ -3520,6 +3513,8 @@ void WebContentsImpl::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) { |
bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry, |
const base::string16& title) { |
+ DCHECK(entry); |
+ |
// For file URLs without a title, use the pathname instead. In the case of a |
// synthesized title, we don't want the update to count toward the "one set |
// per page of the title to history." |
@@ -3533,20 +3528,10 @@ bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry, |
explicit_set = true; |
} |
- // If a page is created via window.open and never navigated, |
- // there will be no navigation entry. In this situation, |
- // |page_title_when_no_navigation_entry_| will be used for page title. |
- if (entry) { |
- if (final_title == entry->GetTitle()) |
- return false; // Nothing changed, don't bother. |
- |
- entry->SetTitle(final_title); |
- } else { |
- if (page_title_when_no_navigation_entry_ == final_title) |
- return false; // Nothing changed, don't bother. |
+ if (final_title == entry->GetTitle()) |
+ return false; // Nothing changed, don't bother. |
- page_title_when_no_navigation_entry_ = final_title; |
- } |
+ entry->SetTitle(final_title); |
// Lastly, set the title for the view. |
view_->SetPageTitle(final_title); |