| Index: content/browser/tab_contents/tab_contents.cc
|
| diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
|
| index d4f871be051cc04c7f71b04de81cd5a5b0e4cc11..20795b902b471e9bcefd7c22c5450b8a013a17e1 100644
|
| --- a/content/browser/tab_contents/tab_contents.cc
|
| +++ b/content/browser/tab_contents/tab_contents.cc
|
| @@ -454,8 +454,10 @@ const string16& TabContents::GetTitle() const {
|
| // that are shown on top of existing pages.
|
| NavigationEntry* entry = controller_.GetTransientEntry();
|
| if (entry) {
|
| + // TODO(evan): use directionality of title.
|
| + // http://code.google.com/p/chromium/issues/detail?id=27094
|
| return entry->GetTitleForDisplay(profile()->GetPrefs()->
|
| - GetString(prefs::kAcceptLanguages));
|
| + GetString(prefs::kAcceptLanguages)).string();
|
| }
|
| WebUI* our_web_ui = render_manager_.pending_web_ui() ?
|
| render_manager_.pending_web_ui() : render_manager_.web_ui();
|
| @@ -464,6 +466,8 @@ const string16& TabContents::GetTitle() const {
|
| entry = controller_.GetActiveEntry();
|
| if (!(entry && entry->IsViewSourceMode())) {
|
| // Give the Web UI the chance to override our title.
|
| + // TODO(evan): use directionality of title.
|
| + // http://code.google.com/p/chromium/issues/detail?id=27094
|
| const string16& title = our_web_ui->overridden_title();
|
| if (!title.empty())
|
| return title;
|
| @@ -476,8 +480,10 @@ const string16& TabContents::GetTitle() const {
|
| // title.
|
| entry = controller_.GetLastCommittedEntry();
|
| if (entry) {
|
| + // TODO(evan): use directionality of title.
|
| + // http://code.google.com/p/chromium/issues/detail?id=27094
|
| return entry->GetTitleForDisplay(profile()->GetPrefs()->
|
| - GetString(prefs::kAcceptLanguages));
|
| + GetString(prefs::kAcceptLanguages)).string();
|
| }
|
| return EmptyString16();
|
| }
|
| @@ -1147,8 +1153,11 @@ void TabContents::UpdateHistoryPageTitle(const NavigationEntry& entry) {
|
| return;
|
|
|
| HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS);
|
| - if (hs)
|
| - hs->SetPageTitle(entry.virtual_url(), entry.title());
|
| + if (hs) {
|
| + // TODO(evan): use directionality of title.
|
| + // http://code.google.com/p/chromium/issues/detail?id=27094
|
| + hs->SetPageTitle(entry.virtual_url(), entry.title().string());
|
| + }
|
| }
|
|
|
| double TabContents::GetZoomLevel() const {
|
| @@ -1668,18 +1677,23 @@ TabContents::CreateHistoryAddPageArgs(
|
| return add_page_args;
|
| }
|
|
|
| -bool TabContents::UpdateTitleForEntry(NavigationEntry* entry,
|
| - const std::wstring& title) {
|
| +bool TabContents::UpdateTitleForEntry(
|
| + NavigationEntry* entry,
|
| + const base::i18n::String16WithDirection& title) {
|
| // 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."
|
| - string16 final_title;
|
| + base::i18n::String16WithDirection final_title;
|
| bool explicit_set;
|
| - if (entry->url().SchemeIsFile() && title.empty()) {
|
| - final_title = UTF8ToUTF16(entry->url().ExtractFileName());
|
| + if (entry->url().SchemeIsFile() && title.is_empty()) {
|
| + final_title = base::i18n::String16WithDirection(
|
| + UTF8ToUTF16(entry->url().ExtractFileName()),
|
| + base::i18n::LEFT_TO_RIGHT);
|
| explicit_set = false; // Don't count synthetic titles toward the set limit.
|
| } else {
|
| - TrimWhitespace(WideToUTF16Hack(title), TRIM_ALL, &final_title);
|
| + string16 trimmed;
|
| + TrimWhitespace(title.string(), TRIM_ALL, &trimmed);
|
| + final_title = base::i18n::String16WithDirection(trimmed, title.direction());
|
| explicit_set = true;
|
| }
|
|
|
| @@ -1694,7 +1708,9 @@ bool TabContents::UpdateTitleForEntry(NavigationEntry* entry,
|
| }
|
|
|
| // Lastly, set the title for the view.
|
| - view_->SetPageTitle(UTF16ToWideHack(final_title));
|
| + // TODO(evan): use directionality of title.
|
| + // http://code.google.com/p/chromium/issues/detail?id=27094
|
| + view_->SetPageTitle(UTF16ToWide(final_title.string()));
|
|
|
| NotificationService::current()->Notify(
|
| NotificationType::TAB_CONTENTS_TITLE_UPDATED,
|
| @@ -2000,9 +2016,7 @@ void TabContents::UpdateTitle(RenderViewHost* rvh,
|
| DCHECK(rvh == render_view_host());
|
| NavigationEntry* entry = controller_.GetEntryWithPageID(rvh->site_instance(),
|
| page_id);
|
| - // TODO(evan): use directionality of title.
|
| - // http://code.google.com/p/chromium/issues/detail?id=27094
|
| - if (!entry || !UpdateTitleForEntry(entry, UTF16ToWide(title.string())))
|
| + if (!entry || !UpdateTitleForEntry(entry, title))
|
| return;
|
|
|
| // Broadcast notifications when the UI should be updated.
|
|
|