diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 05:29:27 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 05:29:27 +0000 |
commit | 4c4d8d2b8aa8ae394d0f933700ddd9e682b141af (patch) | |
tree | 6e3e10e71c29bb9cc8d221d4de38d9dc603e32cd /chrome/browser | |
parent | 39d74d8b3c05faf98935927b68eaebb9a23a76a4 (diff) | |
download | chromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.zip chromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.tar.gz chromium_src-4c4d8d2b8aa8ae394d0f933700ddd9e682b141af.tar.bz2 |
Convert NavigationEntry title to string16. TabContents::GetTitle no longer needs
to be virtual, either.
This also changes how the display URL is computed. Instead of doing it
preemptively, we now do so lazily. This allows us to do the URL formatting
correctly using the elider so that we can do IDN and unescaping.
I changed string_util's singleton functions. I was worried that other code
might make a singleton of string, which would give you this same value as a
non-const string. This would mean our empty strings might no longer be empty.
Review URL: http://codereview.chromium.org/39022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
28 files changed, 113 insertions, 77 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index ce23441..72767c5 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -6,6 +6,7 @@ #include "base/message_loop.h" #include "base/path_service.h" +#include "base/string_util.h" #include "base/thread.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/automation/automation_provider_list.h" @@ -1608,7 +1609,7 @@ void AutomationProvider::GetTabTitle(int handle, int* title_string_size, *title_string_size = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - *title = tab->GetActiveEntry()->title(); + *title = UTF16ToWideHack(tab->GetActiveEntry()->title()); *title_string_size = static_cast<int>(title->size()); } } diff --git a/chrome/browser/back_forward_menu_model.cc b/chrome/browser/back_forward_menu_model.cc index d0e4ab3..f969364 100644 --- a/chrome/browser/back_forward_menu_model.cc +++ b/chrome/browser/back_forward_menu_model.cc @@ -222,7 +222,7 @@ std::wstring BackForwardMenuModel::GetItemLabel(int menu_id) const { return L""; NavigationEntry* entry = GetNavigationEntry(menu_id); - return entry->title(); + return UTF16ToWideHack(entry->title()); } const SkBitmap& BackForwardMenuModel::GetItemIcon(int menu_id) const { diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 3b3851e..36aa430 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -398,7 +398,7 @@ std::wstring Browser::GetCurrentPageTitle() const { // |contents| can be NULL because GetCurrentPageTitle is called by the window // during the window's creation (before tabs have been added). if (contents) { - title = contents->GetTitle(); + title = UTF16ToWideHack(contents->GetTitle()); FormatTitleForDisplay(&title); } if (title.empty()) @@ -738,7 +738,7 @@ void Browser::BookmarkCurrentPage() { return; bool was_bookmarked = model->IsBookmarked(url); - model->SetURLStarred(url, entry->title(), true); + model->SetURLStarred(url, UTF16ToWideHack(entry->title()), true); if (window_->IsActive()) { // Only show the bubble if the window is active, otherwise we may get into // weird situations were the bubble is deleted as soon as it is shown. diff --git a/chrome/browser/debugger/debugger_host_impl.cpp b/chrome/browser/debugger/debugger_host_impl.cpp index 04eba09..beeb398 100644 --- a/chrome/browser/debugger/debugger_host_impl.cpp +++ b/chrome/browser/debugger/debugger_host_impl.cpp @@ -65,7 +65,7 @@ class TabContentsReference : public NotificationObserver { }; -DebuggerHostImpl::DebuggerHostImpl(DebuggerInputOutput* io) +DebuggerHostImpl::DebuggerHostImpl(DebuggerInputOutput* io) : io_(io), debugger_ready_(true) { } @@ -98,7 +98,7 @@ void DebuggerHostImpl::OnDebugAttach() { std::wstring title; const TabContents* t = GetTabContentsBeingDebugged(); if (t) { - title = t->GetTitle(); + title = UTF16ToWideHack(t->GetTitle()); } ListValue* argv = new ListValue; @@ -178,7 +178,7 @@ void DebuggerHostImpl::OnDebuggerHostMsg(const ListValue* args) { return; } io_->SetDebuggerBreak(brk == L"true"); - } + } } TabContents* DebuggerHostImpl::GetTabContentsBeingDebugged() const { diff --git a/chrome/browser/debugger/debugger_node.cc b/chrome/browser/debugger/debugger_node.cc index 4bfec06..31374c6 100644 --- a/chrome/browser/debugger/debugger_node.cc +++ b/chrome/browser/debugger/debugger_node.cc @@ -201,7 +201,7 @@ v8::Handle<v8::Value> BrowserNode::PropGetter(v8::Handle<v8::String> prop, if (b != NULL) { if (prop->Equals(v8::String::New("title"))) { const TabContents *t = b->GetSelectedTabContents(); - std::wstring title = t->GetTitle(); + std::wstring title = UTF16ToWideHack(t->GetTitle()); std::string title2 = WideToUTF8(title); return v8::String::New(title2.c_str()); } else if (prop->Equals(v8::String::New("tab"))) { @@ -359,7 +359,7 @@ v8::Handle<v8::Value> TabNode::PropGetter(v8::Handle<v8::String> prop, if (t != NULL) { WebContents* web = t->AsWebContents(); if (prop->Equals(v8::String::New("title"))) { - std::wstring title = t->GetTitle(); + std::wstring title = UTF16ToWideHack(t->GetTitle()); std::string title2 = WideToUTF8(title); return v8::String::New(title2.c_str()); } else if (web) { diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 79c6a07..b60a16c 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -6,6 +6,7 @@ #include <psapi.h> #include "base/file_version_info.h" +#include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -212,7 +213,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { contents = host->delegate()->GetAsWebContents(); if (!contents) continue; - std::wstring title = contents->GetTitle(); + std::wstring title = UTF16ToWideHack(contents->GetTitle()); if (!title.length()) title = L"Untitled"; process.titles.push_back(title); diff --git a/chrome/browser/navigation_entry_unittest.cc b/chrome/browser/navigation_entry_unittest.cc index a8c98d8..ebeeae8 100644 --- a/chrome/browser/navigation_entry_unittest.cc +++ b/chrome/browser/navigation_entry_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/string16.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "testing/gtest/include/gtest/gtest.h" @@ -17,7 +18,7 @@ class NavigationEntryTest : public testing::Test { entry2_.reset(new NavigationEntry(TAB_CONTENTS_DOM_UI, instance_, 3, GURL("test:url"), GURL("from"), - L"title", + ASCIIToUTF16("title"), PageTransition::TYPED)); } @@ -49,17 +50,18 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL(), entry1_.get()->url()); EXPECT_EQ(GURL(), entry1_.get()->display_url()); - EXPECT_EQ(L"", entry1_.get()->GetTitleForDisplay()); + EXPECT_TRUE(entry1_.get()->GetTitleForDisplay(NULL).empty()); // Setting URL affects display_url and GetTitleForDisplay entry1_.get()->set_url(GURL("http://www.google.com")); EXPECT_EQ(GURL("http://www.google.com"), entry1_.get()->url()); EXPECT_EQ(GURL("http://www.google.com/"), entry1_.get()->display_url()); - EXPECT_EQ(L"http://www.google.com/", entry1_.get()->GetTitleForDisplay()); + EXPECT_EQ(ASCIIToUTF16("http://www.google.com/"), + entry1_.get()->GetTitleForDisplay(NULL)); // Title affects GetTitleForDisplay - entry1_.get()->set_title(L"Google"); - EXPECT_EQ(L"Google", entry1_.get()->GetTitleForDisplay()); + entry1_.get()->set_title(ASCIIToWide("Google")); + EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay(NULL)); // Setting display_url doesn't affect URL entry2_.get()->set_display_url(GURL("display:url")); @@ -68,7 +70,7 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL("display:url"), entry2_.get()->display_url()); // Having a title set in constructor overrides display URL - EXPECT_EQ(L"title", entry2_.get()->GetTitleForDisplay()); + EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay(NULL)); // User typed URL is independent of the others EXPECT_EQ(GURL(), entry1_.get()->user_typed_url()); @@ -146,8 +148,8 @@ TEST_F(NavigationEntryTest, NavigationEntryAccessors) { // Title EXPECT_EQ(std::wstring(), entry1_.get()->title()); EXPECT_EQ(L"title", entry2_.get()->title()); - entry2_.get()->set_title(L"title2"); - EXPECT_EQ(L"title2", entry2_.get()->title()); + entry2_.get()->set_title(ASCIIToUTF16("title2")); + EXPECT_EQ(ASCIIToUTF16("title2"), entry2_.get()->title()); // State EXPECT_EQ(std::string(), entry1_.get()->content_state()); diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index c448dbb..1491bf0 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -118,7 +118,7 @@ void PrintViewManager::DidPrintPage( } std::wstring PrintViewManager::RenderSourceName() { - std::wstring name(owner_.GetTitle()); + std::wstring name(UTF16ToWideHack(owner_.GetTitle())); if (name.empty()) name = l10n_util::GetString(IDS_DEFAULT_PRINT_DOCUMENT_TITLE); return name; diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc index 33db25d..29bbf7b 100644 --- a/chrome/browser/sessions/base_session_service.cc +++ b/chrome/browser/sessions/base_session_service.cc @@ -158,7 +158,7 @@ SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( entry.display_url().spec()); WriteWStringToPickle(pickle, &bytes_written, max_state_size, - entry.title()); + UTF16ToWideHack(entry.title())); WriteStringToPickle(pickle, &bytes_written, max_state_size, entry.content_state()); diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 8f6b186..cbe50dd 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/string16.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -79,7 +80,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, GURL(), - std::wstring(), + string16(), PageTransition::LINK); // Redundantly setting e1's SiteInstance shouldn't affect the ref count. diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 688c6f1..fad7d21 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -392,7 +392,7 @@ void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host, // If this interstitial is shown on an existing navigation entry, we'll need // to remember its title so we can revert to it when hidden. if (!new_navigation_ && !should_revert_tab_title_) { - original_tab_title_ = entry->title(); + original_tab_title_ = UTF16ToWideHack(entry->title()); should_revert_tab_title_ = true; } entry->set_title(title); diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index eb7b613..374b1804 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -476,12 +476,12 @@ NavigationEntry* NavigationController::CreateNavigationEntry( NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url, referrer, - std::wstring(), transition); + string16(), transition); entry->set_display_url(url); entry->set_user_typed_url(url); if (url.SchemeIsFile()) { - entry->set_title(file_util::GetFilenameFromPath(UTF8ToWide(url.host() + - url.path()))); + entry->set_title(WideToUTF16Hack( + file_util::GetFilenameFromPath(UTF8ToWide(url.host() + url.path())))); } return entry; } @@ -514,7 +514,7 @@ void NavigationController::LoadURLLazily(const GURL& url, const std::wstring& title, SkBitmap* icon) { NavigationEntry* entry = CreateNavigationEntry(url, referrer, type); - entry->set_title(title); + entry->set_title(WideToUTF16Hack(title)); if (icon) entry->favicon().set_bitmap(*icon); @@ -527,11 +527,11 @@ bool NavigationController::LoadingURLLazily() { return load_pending_entry_when_active_; } -const std::wstring& NavigationController::GetLazyTitle() const { +const string16& NavigationController::GetLazyTitle() const { if (pending_entry_) - return pending_entry_->GetTitleForDisplay(); + return pending_entry_->GetTitleForDisplay(this); else - return EmptyWString(); + return EmptyString16(); } const SkBitmap& NavigationController::GetLazyFavIcon() const { diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index 00b6b0f..3de03e5 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -11,6 +11,7 @@ #include "base/linked_ptr.h" #include "base/ref_counted.h" +#include "base/string16.h" #include "googleurl/src/gurl.h" #include "chrome/browser/sessions/session_id.h" #include "chrome/browser/ssl/ssl_manager.h" @@ -360,7 +361,7 @@ class NavigationController { // titles and favicons. Since no request was made, this is the only info // we have about this page. This feature is used by web application clusters. bool LoadingURLLazily(); - const std::wstring& GetLazyTitle() const; + const string16& GetLazyTitle() const; const SkBitmap& GetLazyFavIcon() const; // Returns the identifier used by session restore. diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc index e243f8a..010c94a 100644 --- a/chrome/browser/tab_contents/navigation_entry.cc +++ b/chrome/browser/tab_contents/navigation_entry.cc @@ -4,6 +4,10 @@ #include "chrome/browser/tab_contents/navigation_entry.h" +#include "chrome/browser/tab_contents/navigation_controller.h" +#include "chrome/common/gfx/text_elider.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" #include "chrome/common/url_constants.h" #include "chrome/common/resource_bundle.h" @@ -43,7 +47,7 @@ NavigationEntry::NavigationEntry(TabContentsType type, int page_id, const GURL& url, const GURL& referrer, - const std::wstring& title, + const string16& title, PageTransition::Type transition_type) : unique_id_(GetUniqueID()), tab_type_(type), @@ -58,10 +62,32 @@ NavigationEntry::NavigationEntry(TabContentsType type, restored_(false) { } -const std::wstring& NavigationEntry::GetTitleForDisplay() { - if (title_.empty()) - return display_url_as_string_; - return title_; +const string16& NavigationEntry::GetTitleForDisplay( + const NavigationController* navigation_controller) { + // Most pages have real titles. Don't even bother caching anything if this is + // the case. + if (!title_.empty()) + return title_; + + // More complicated cases will use the URLs as the title. This result we will + // cache since it's more complicated to compute. + if (!cached_display_title_.empty()) + return cached_display_title_; + + // Use the display URL first if any, and fall back on using the real URL. + std::wstring languages; + if (navigation_controller) { + languages = navigation_controller->profile()->GetPrefs()->GetString( + prefs::kAcceptLanguages); + } + if (!display_url_.is_empty()) { + cached_display_title_ = WideToUTF16Hack(gfx::GetCleanStringFromUrl( + display_url_, languages, NULL, NULL)); + } else if (!url_.is_empty()) { + cached_display_title_ = WideToUTF16Hack(gfx::GetCleanStringFromUrl( + display_url_, languages, NULL, NULL)); + } + return cached_display_title_; } bool NavigationEntry::IsViewSourceMode() const { diff --git a/chrome/browser/tab_contents/navigation_entry.h b/chrome/browser/tab_contents/navigation_entry.h index 20d3fd4..9cad672 100644 --- a/chrome/browser/tab_contents/navigation_entry.h +++ b/chrome/browser/tab_contents/navigation_entry.h @@ -16,6 +16,8 @@ #include "grit/theme_resources.h" #include "skia/include/SkBitmap.h" +class NavigationController; + //////////////////////////////////////////////////////////////////////////////// // // NavigationEntry class @@ -169,7 +171,7 @@ class NavigationEntry { int page_id, const GURL& url, const GURL& referrer, - const std::wstring& title, + const string16& title, PageTransition::Type transition_type); ~NavigationEntry() { } @@ -221,10 +223,7 @@ class NavigationEntry { // the user. void set_url(const GURL& url) { url_ = url; - if (display_url_.is_empty()) { - // If there is no explicit display URL, then we'll display this URL. - display_url_as_string_ = UTF8ToWide(url_.spec()); - } + cached_display_title_.clear(); } const GURL& url() const { return url_; @@ -247,7 +246,7 @@ class NavigationEntry { // if there is no overridden display URL, it will return the actual one. void set_display_url(const GURL& url) { display_url_ = (url == url_) ? GURL() : url; - display_url_as_string_ = UTF8ToWide(url.spec()); + cached_display_title_.clear(); } bool has_display_url() const { return !display_url_.is_empty(); @@ -260,10 +259,11 @@ class NavigationEntry { // The caller is responsible for detecting when there is no title and // displaying the appropriate "Untitled" label if this is being displayed to // the user. - void set_title(const std::wstring& title) { + void set_title(const string16& title) { title_ = title; + cached_display_title_.clear(); } - const std::wstring& title() const { + const string16& title() const { return title_; } @@ -313,7 +313,11 @@ class NavigationEntry { // 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(); + // + // The NavigationController corresponding to this entry must be given so we + // can get the preferences so we can optionally format a URL for display. It + // may be NULL if you don't need proper URL formatting (e.g. unit tests). + const string16& GetTitleForDisplay(const NavigationController* controller); // Returns true if the current tab is in view source mode. This will be false // if there is no navigation. @@ -383,14 +387,8 @@ class NavigationEntry { PageType page_type_; GURL url_; GURL referrer_; - GURL display_url_; - - // We cache a copy of the display URL as a string so we don't have to - // convert the display URL to a wide string every time we paint. - std::wstring display_url_as_string_; - - std::wstring title_; + string16 title_; FaviconStatus favicon_; std::string content_state_; int32 page_id_; @@ -400,6 +398,12 @@ class NavigationEntry { bool has_post_data_; bool restored_; + // This is a cached version of the result of GetTitleForDisplay. It prevents + // us from having to do URL formatting on the URL evey time the title is + // displayed. When the URL, display URL, or title is set, this should be + // cleared to force a refresh. + string16 cached_display_title_; + // Copy and assignment is explicitly allowed for this class. }; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 39ea878..7905364 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -149,7 +149,7 @@ const GURL& TabContents::GetURL() const { return entry ? entry->display_url() : GURL::EmptyGURL(); } -const std::wstring& TabContents::GetTitle() const { +const string16& TabContents::GetTitle() const { // We use the title for the last committed entry rather than a pending // navigation entry. For example, when the user types in a URL, we want to // keep the old page's title until the new load has committed and we get a new @@ -158,14 +158,14 @@ const std::wstring& TabContents::GetTitle() const { // their title, as they are not committed. NavigationEntry* entry = controller_->GetTransientEntry(); if (entry) - return entry->GetTitleForDisplay(); + return entry->GetTitleForDisplay(controller_); entry = controller_->GetLastCommittedEntry(); if (entry) - return entry->GetTitleForDisplay(); + return entry->GetTitleForDisplay(controller_); else if (controller_->LoadingURLLazily()) return controller_->GetLazyTitle(); - return EmptyWString(); + return EmptyString16(); } int32 TabContents::GetMaxPageID() { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 41b47bf..e0ea375 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -180,7 +180,7 @@ class TabContents : public PageNavigator, // pending may be provisional (e.g., the navigation could result in a // download, in which case the URL would revert to what it was previously). const GURL& GetURL() const; - virtual const std::wstring& GetTitle() const; + virtual const string16& GetTitle() const; // Overridden by DOMUIContents. // 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 diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index 1337b51..15b55e4 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -523,7 +523,7 @@ void WebContents::CreateShortcut() { // effectively cancel the pending install request. pending_install_.page_id = entry->page_id(); pending_install_.icon = GetFavIcon(); - pending_install_.title = GetTitle(); + pending_install_.title = UTF16ToWideHack(GetTitle()); pending_install_.url = GetURL(); if (pending_install_.callback_functor) { pending_install_.callback_functor->Cancel(); diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 47ff2b4..1b68194 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -46,7 +46,7 @@ std::wstring TaskManagerWebContentsResource::GetTitle() const { return std::wstring(); // Fall back on the URL if there's no title. - std::wstring tab_title(web_contents_->GetTitle()); + std::wstring tab_title(UTF16ToWideHack(web_contents_->GetTitle())); if (tab_title.empty()) { tab_title = UTF8ToWide(web_contents_->GetURL().spec()); // Force URL to be LTR. diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index 8dc96d6..8edf71e 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -298,10 +298,10 @@ int BlockedPopupContainer::GetTabContentsCount() const { std::wstring BlockedPopupContainer::GetDisplayStringForItem(int index) { const GURL& url = blocked_popups_[index].first->GetURL().GetOrigin(); - std::wstring label = - l10n_util::GetStringF(IDS_POPUP_TITLE_FORMAT, - UTF8ToWide(url.possibly_invalid_spec()), - blocked_popups_[index].first->GetTitle()); + std::wstring label = l10n_util::GetStringF( + IDS_POPUP_TITLE_FORMAT, + UTF8ToWide(url.possibly_invalid_spec()), + UTF16ToWideHack(blocked_popups_[index].first->GetTitle())); return label; } diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index 4b3a5fa..e1375f9 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -154,7 +154,7 @@ void BugReportView::SetupControl() { page_title_label_ = new views::Label( l10n_util::GetString(IDS_BUGREPORT_REPORT_PAGE_TITLE)); - page_title_text_ = new views::Label(tab_->GetTitle()); + page_title_text_ = new views::Label(UTF16ToWideHack(tab_->GetTitle())); page_url_label_ = new views::Label( l10n_util::GetString(IDS_BUGREPORT_REPORT_URL_LABEL)); // page_url_text_'s text (if any) is filled in after dialog creation diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index da026f9..590e8a8 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -82,7 +82,7 @@ int HungPagesTableModel::RowCount() { std::wstring HungPagesTableModel::GetText(int row, int column_id) { DCHECK(row >= 0 && row < RowCount()); - std::wstring title = webcontentses_.at(row)->GetTitle(); + std::wstring title = UTF16ToWideHack(webcontentses_.at(row)->GetTitle()); if (title.empty()) title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); // TODO(xji): Consider adding a special case if the title text is a URL, diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 8290b01..e12f4e2 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -322,7 +322,7 @@ SkBitmap LocationBarView::GetFavIcon() const { std::wstring LocationBarView::GetTitle() const { DCHECK(delegate_); DCHECK(delegate_->GetTabContents()); - return delegate_->GetTabContents()->GetTitle(); + return UTF16ToWideHack(delegate_->GetTabContents()->GetTitle()); } void LocationBarView::DoLayout(const bool force_layout) { diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h index 15e7afe..be33df1 100644 --- a/chrome/browser/views/sad_tab_view.h +++ b/chrome/browser/views/sad_tab_view.h @@ -54,4 +54,5 @@ class SadTabView : public views::View { DISALLOW_EVIL_CONSTRUCTORS(SadTabView); }; -#endif // #ifndef CHROME_BROWSER_VIEWS_SAD_TAB_H_ +#endif // CHROME_BROWSER_VIEWS_SAD_TAB_H__ + diff --git a/chrome/browser/views/star_toggle.h b/chrome/browser/views/star_toggle.h index 95f64db..1475ab4 100644 --- a/chrome/browser/views/star_toggle.h +++ b/chrome/browser/views/star_toggle.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_STAR_TOGGLE_H__ -#define CHROME_BROWSER_VIEWS_STAR_TOGGLE_H__ +#ifndef CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_ +#define CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_ #include "chrome/views/view.h" #include "chrome/views/event.h" @@ -66,5 +66,4 @@ class StarToggle : public views::View { DISALLOW_EVIL_CONSTRUCTORS(StarToggle); }; -#endif // CHROME_BROWSER_VIEWS_STAR_TOGGLE_H__ - +#endif // CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_ diff --git a/chrome/browser/views/tab_icon_view.h b/chrome/browser/views/tab_icon_view.h index 3a731fc..d210ba4 100644 --- a/chrome/browser/views/tab_icon_view.h +++ b/chrome/browser/views/tab_icon_view.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H__ -#define CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H__ +#ifndef CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H_ +#define CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H_ #include "chrome/views/view.h" @@ -66,8 +66,7 @@ class TabIconView : public views::View { // throbber_running_ is true. int throbber_frame_; - DISALLOW_EVIL_CONSTRUCTORS(TabIconView); + DISALLOW_COPY_AND_ASSIGN(TabIconView); }; -#endif // CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H__ - +#endif // CHROME_BROWSER_VIEW_TAB_ICON_VIEW_H_ diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index 1580d05..ede0848 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -281,7 +281,7 @@ TabRenderer::~TabRenderer() { void TabRenderer::UpdateData(TabContents* contents) { DCHECK(contents); data_.favicon = contents->GetFavIcon(); - data_.title = contents->GetTitle(); + data_.title = UTF16ToWideHack(contents->GetTitle()); data_.loading = contents->is_loading(); data_.off_the_record = contents->profile()->IsOffTheRecord(); data_.show_icon = contents->ShouldDisplayFavIcon(); diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 25c7161..f060135 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -770,7 +770,8 @@ void BrowserToolbarView::WriteDragData(views::View* sender, } } - drag_utils::SetURLAndDragImage(tab_->GetURL(), tab_->GetTitle(), + drag_utils::SetURLAndDragImage(tab_->GetURL(), + UTF16ToWideHack(tab_->GetTitle()), tab_->GetFavIcon(), data); } |