Index: extensions/browser/guest_view/guest_view_base.cc |
diff --git a/extensions/browser/guest_view/guest_view_base.cc b/extensions/browser/guest_view/guest_view_base.cc |
index ffb2e021af04aa71d5a56558cec4869ca1121d52..f45b6c810a382631e7cd24fc7f832345946e33e5 100644 |
--- a/extensions/browser/guest_view/guest_view_base.cc |
+++ b/extensions/browser/guest_view/guest_view_base.cc |
@@ -4,6 +4,7 @@ |
#include "extensions/browser/guest_view/guest_view_base.h" |
+#include "base/i18n/rtl.h" |
#include "base/lazy_instance.h" |
#include "base/strings/utf_string_conversions.h" |
#include "content/public/browser/render_frame_host.h" |
@@ -100,6 +101,10 @@ GuestViewBase::GuestViewBase(content::BrowserContext* browser_context, |
weak_ptr_factory_(this) { |
} |
+base::string16 GuestViewBase::GetTaskTitle() const { |
+ return GetTitle(); |
+} |
+ |
void GuestViewBase::Init(const std::string& embedder_extension_id, |
content::WebContents* embedder_web_contents, |
const base::DictionaryValue& create_params, |
@@ -195,6 +200,31 @@ void GuestViewBase::SetAutoSize(bool enabled, |
} |
} |
+base::string16 GuestViewBase::GetTitle() const { |
+ // TODO(fsamuel): This code is essentially a copy-and-paste from |
+ // task_manager_util's GetTitleFromWebContents. We should reuse that code |
+ // once it's available in the extensions module. |
+ base::string16 title = guest_web_contents()->GetTitle(); |
+ if (title.empty()) { |
+ GURL url = guest_web_contents()->GetURL(); |
+ title = base::UTF8ToUTF16(url.spec()); |
+ // Force URL to be LTR. |
+ title = base::i18n::GetDisplayStringInLTRDirectionality(title); |
+ } else { |
+ // Since the tab_title will be concatenated with |
+ // IDS_TASK_MANAGER_TAB_PREFIX, we need to explicitly set the tab_title to |
+ // be LTR format if there is no strong RTL charater in it. Otherwise, if |
+ // IDS_TASK_MANAGER_TAB_PREFIX is an RTL word, the concatenated result |
+ // might be wrong. For example, http://mail.yahoo.com, whose title is |
+ // "Yahoo! Mail: The best web-based Email!", without setting it explicitly |
+ // as LTR format, the concatenated result will be "!Yahoo! Mail: The best |
+ // web-based Email :BAT", in which the capital letters "BAT" stands for |
+ // the Hebrew word for "tab". |
+ base::i18n::AdjustStringForLocaleDirection(&title); |
+ } |
+ return title; |
+} |
+ |
// static |
void GuestViewBase::RegisterGuestViewType( |
const std::string& view_type, |