diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 18:03:41 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 18:03:41 +0000 |
commit | bbbc1ef9d160f602aed88ed2eecd6063e5952ca7 (patch) | |
tree | 256e507e11d22bc154edcef45746ee38b8d1a64e | |
parent | a1ff529fcffcded364926b58c1f2c8afc839adeb (diff) | |
download | chromium_src-bbbc1ef9d160f602aed88ed2eecd6063e5952ca7.zip chromium_src-bbbc1ef9d160f602aed88ed2eecd6063e5952ca7.tar.gz chromium_src-bbbc1ef9d160f602aed88ed2eecd6063e5952ca7.tar.bz2 |
Use TabContents::GetDefaultTitle() everywhere we need a title for an untitled tab/page. This will let us remove a couple of duplicate strings.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/604021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38902 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/bookmarks/bookmark_utils.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/hung_renderer_controller.mm | 13 | ||||
-rw-r--r-- | chrome/browser/gtk/hung_renderer_dialog_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 9 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/hung_renderer_view.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.cc | 10 |
9 files changed, 29 insertions, 35 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index c6f82b3..accec3c 100644 --- a/chrome/browser/bookmarks/bookmark_utils.cc +++ b/chrome/browser/bookmarks/bookmark_utils.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -258,7 +258,7 @@ int PerformBookmarkDrop(Profile* profile, // No title, use the host. title = UTF8ToUTF16(data.elements[0].url.host()); if (title.empty()) - title = l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_UNKNOWN_DRAG_TITLE); + title = TabContents::GetDefaultTitle(); } model->AddURL(parent_node, index, title, data.elements[0].url); return DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK; diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 0de4558..aa12efc 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -506,7 +506,7 @@ string16 Browser::GetWindowTitleForCurrentTab() const { FormatTitleForDisplay(&title); } if (title.empty()) - title = l10n_util::GetStringUTF16(IDS_TAB_UNTITLED_TITLE); + title = TabContents::GetDefaultTitle(); #if defined(OS_MACOSX) || defined(OS_CHROMEOS) // On Mac or ChromeOS, we don't want to suffix the page title with diff --git a/chrome/browser/cocoa/hung_renderer_controller.mm b/chrome/browser/cocoa/hung_renderer_controller.mm index 36c9441..74ddff5 100644 --- a/chrome/browser/cocoa/hung_renderer_controller.mm +++ b/chrome/browser/cocoa/hung_renderer_controller.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -137,13 +137,10 @@ HungRendererController* g_instance = NULL; scoped_nsobject<NSMutableArray> favicons([[NSMutableArray alloc] init]); for (TabContentsIterator it; !it.done(); ++it) { if (it->GetRenderProcessHost() == hungContents_->GetRenderProcessHost()) { - const string16 title = (*it)->GetTitle(); - if (title.empty()) { - [titles addObject: - l10n_util::GetNSStringWithFixup(IDS_TAB_UNTITLED_TITLE)]; - } else { - [titles addObject:base::SysUTF16ToNSString(title)]; - } + string16 title = (*it)->GetTitle(); + if (title.empty()) + title = TabContents::GetDefaultTitle(); + [titles addObject:base::SysUTF16ToNSString(title)]; // TabContents can return a null SkBitmap if it has no favicon. If this // happens, use the default favicon. diff --git a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc index 0c0c97b..faf5116 100644 --- a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc +++ b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -154,7 +154,7 @@ void HungRendererDialogGtk::ShowForTabContents(TabContents* hung_contents) { gtk_list_store_append(model_, &tree_iter); std::string title = UTF16ToUTF8(it->GetTitle()); if (title.empty()) - title = l10n_util::GetStringUTF8(IDS_TAB_UNTITLED_TITLE); + title = UTF16ToUTF8(TabContents::GetDefaultTitle()); SkBitmap favicon = it->GetFavIcon(); gtk_list_store_set(model_, &tree_iter, diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 0f44eaf..7de4808 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -774,11 +774,9 @@ void TabRendererGtk::PaintTitle(gfx::Canvas* canvas) { // Paint the Title. string16 title = data_.title; if (title.empty()) { - if (data_.loading) { - title = l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE); - } else { - title = l10n_util::GetStringUTF16(IDS_TAB_UNTITLED_TITLE); - } + title = data_.loading ? + l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : + TabContents::GetDefaultTitle(); } else { Browser::FormatTitleForDisplay(&title); } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 3d66ebf..2f0dcd9 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -505,6 +505,11 @@ const string16& TabContents::GetTitle() const { return EmptyString16(); } +// static +string16 TabContents::GetDefaultTitle() { + return l10n_util::GetStringUTF16(IDS_DEFAULT_TAB_TITLE); +} + int32 TabContents::GetMaxPageID() { if (GetSiteInstance()) return GetSiteInstance()->max_page_id(); @@ -525,10 +530,6 @@ SiteInstance* TabContents::GetSiteInstance() const { return render_manager_.current_host()->site_instance(); } -const std::wstring TabContents::GetDefaultTitle() const { - return l10n_util::GetString(IDS_DEFAULT_TAB_TITLE); -} - bool TabContents::ShouldDisplayURL() { // Don't hide the url in view source mode and with interstitials. NavigationEntry* entry = controller_.GetActiveEntry(); diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 1744f61..2c7e5be 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -200,6 +200,9 @@ class TabContents : public PageNavigator, virtual const GURL& GetURL() const; virtual const string16& GetTitle() const; + // Initial title assigned to NavigationEntries from Navigate. + static string16 GetDefaultTitle(); + // The max PageID of any page that this TabContents has loaded. PageIDs // increase with each new page that is loaded by a tab. If this is a // TabContents, then the max PageID is kept separately on each SiteInstance. @@ -214,9 +217,6 @@ class TabContents : public PageNavigator, // access to its site instance. virtual SiteInstance* GetSiteInstance() const; - // Initial title assigned to NavigationEntries from Navigate. - const std::wstring GetDefaultTitle() const; - // Defines whether this tab's URL should be displayed in the browser's URL // bar. Normally this is true so you can see the URL. This is set to false // for the new tab page and related pages so that the URL bar is empty and diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index 33b497e..523e5cc 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -89,9 +89,9 @@ int HungPagesTableModel::RowCount() { std::wstring HungPagesTableModel::GetText(int row, int column_id) { DCHECK(row >= 0 && row < RowCount()); - std::wstring title = UTF16ToWideHack(tab_contentses_.at(row)->GetTitle()); + std::wstring title = UTF16ToWideHack(tab_contentses_[row]->GetTitle()); if (title.empty()) - title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); + title = UTF16ToWideHack(TabContents::GetDefaultTitle()); // TODO(xji): Consider adding a special case if the title text is a URL, // since those should always have LTR directionality. Please refer to // http://crbug.com/6726 for more information. diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index 169f46d..8a8d61a 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -592,11 +592,9 @@ void TabRenderer::PaintTitle(SkColor title_color, gfx::Canvas* canvas) { // Paint the Title. string16 title = data_.title; if (title.empty()) { - if (data_.loading) { - title = l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE); - } else { - title = l10n_util::GetStringUTF16(IDS_TAB_UNTITLED_TITLE); - } + title = data_.loading ? + l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE) : + TabContents::GetDefaultTitle(); } else { Browser::FormatTitleForDisplay(&title); } |