summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-23 20:49:07 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-23 20:49:07 +0000
commit3d627bbc21bb7a960cec7db390d0e19c98c65f0e (patch)
treecea7296968cf3f3ddf30e5110441e15cf5ea49e2
parent89ce0d09ef9f8c021a9ce441b1ffdf442d203d35 (diff)
downloadchromium_src-3d627bbc21bb7a960cec7db390d0e19c98c65f0e.zip
chromium_src-3d627bbc21bb7a960cec7db390d0e19c98c65f0e.tar.gz
chromium_src-3d627bbc21bb7a960cec7db390d0e19c98c65f0e.tar.bz2
This fixes http://code.google.com/p/chromium/issues/detail?id=2529, which is
tabs displaying Loading/Untitled in Chrome. We should display the page URL if the title of the page is blank. Fix on these lines. R=beng Review URL: http://codereview.chromium.org/7905 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3852 0039d316-1c4b-4281-b951-d872f2087c98
-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();