summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/navigation_controller.cc2
-rw-r--r--chrome/browser/navigation_entry.cc6
-rw-r--r--chrome/browser/navigation_entry.h6
-rw-r--r--chrome/browser/tab_contents.cc6
4 files changed, 16 insertions, 4 deletions
diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc
index 7bd683b..c3b4304 100644
--- a/chrome/browser/navigation_controller.cc
+++ b/chrome/browser/navigation_controller.cc
@@ -542,7 +542,7 @@ bool NavigationController::LoadingURLLazily() {
const std::wstring& NavigationController::GetLazyTitle() const {
if (pending_entry_)
- return pending_entry_->title();
+ return pending_entry_->GetTitleForDisplay();
else
return EmptyWString();
}
diff --git a/chrome/browser/navigation_entry.cc b/chrome/browser/navigation_entry.cc
index 2cb98f2..8a24a3d 100644
--- a/chrome/browser/navigation_entry.cc
+++ b/chrome/browser/navigation_entry.cc
@@ -54,3 +54,9 @@ NavigationEntry::NavigationEntry(TabContentsType type,
has_post_data_(false),
restored_(false) {
}
+
+const std::wstring& NavigationEntry::GetTitleForDisplay() {
+ if (title_.empty())
+ return url_as_string_;
+ return title_;
+} \ No newline at end of file
diff --git a/chrome/browser/navigation_entry.h b/chrome/browser/navigation_entry.h
index f7aa143..1dcbe19 100644
--- a/chrome/browser/navigation_entry.h
+++ b/chrome/browser/navigation_entry.h
@@ -219,6 +219,7 @@ class NavigationEntry {
// the user.
void set_url(const GURL& url) {
url_ = url;
+ url_as_string_ = UTF8ToWide(url_.spec());
}
const GURL& url() const {
return url_;
@@ -344,6 +345,10 @@ class NavigationEntry {
return restored_;
}
+ // Returns the title to be displayed on the tab. This could be the title of
+ // the page if it is available or the URL.
+ const std::wstring& GetTitleForDisplay();
+
private:
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
// Session/Tab restore save portions of this class so that it can be recreated
@@ -357,6 +362,7 @@ class NavigationEntry {
scoped_refptr<SiteInstance> site_instance_;
PageType page_type_;
GURL url_;
+ std::wstring url_as_string_;
GURL display_url_;
std::wstring title_;
FaviconStatus favicon_;
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index f97c04c..1a80995 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -131,12 +131,12 @@ const std::wstring& TabContents::GetTitle() const {
// The exception is with transient pages, for which we really want to use
// their title, as they are not committed.
NavigationEntry* entry = controller_->GetTransientEntry();
- if (entry && !entry->title().empty())
- return entry->title();
+ if (entry)
+ return entry->GetTitleForDisplay();
entry = controller_->GetLastCommittedEntry();
if (entry)
- return entry->title();
+ return entry->GetTitleForDisplay();
else if (controller_->LoadingURLLazily())
return controller_->GetLazyTitle();
return EmptyWString();