diff options
Diffstat (limited to 'content/browser/tab_contents')
-rw-r--r-- | content/browser/tab_contents/interstitial_page.cc | 13 | ||||
-rw-r--r-- | content/browser/tab_contents/interstitial_page.h | 10 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_entry.cc | 16 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_entry.h | 20 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_entry_unittest.cc | 38 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager_unittest.cc | 18 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 41 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 10 |
9 files changed, 62 insertions, 106 deletions
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 269336c..da0b968 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -270,7 +270,7 @@ void InterstitialPage::Hide() { // Let's revert to the original title if necessary. NavigationEntry* entry = tab_->controller().GetActiveEntry(); if (!new_navigation_ && should_revert_tab_title_) { - entry->set_title(original_tab_title_); + entry->set_title(WideToUTF16Hack(original_tab_title_)); tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); } delete this; @@ -383,10 +383,9 @@ void InterstitialPage::DidNavigate( tab_->SetIsLoading(false, NULL); } -void InterstitialPage::UpdateTitle( - RenderViewHost* render_view_host, - int32 page_id, - const base::i18n::String16WithDirection& title) { +void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host, + int32 page_id, + const std::wstring& title) { DCHECK(render_view_host == render_view_host_); NavigationEntry* entry = tab_->controller().GetActiveEntry(); if (!entry) { @@ -405,10 +404,10 @@ void InterstitialPage::UpdateTitle( // 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); + entry->set_title(WideToUTF16Hack(title)); tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); } diff --git a/content/browser/tab_contents/interstitial_page.h b/content/browser/tab_contents/interstitial_page.h index 759d8b3..2633519 100644 --- a/content/browser/tab_contents/interstitial_page.h +++ b/content/browser/tab_contents/interstitial_page.h @@ -9,7 +9,6 @@ #include <map> #include <string> -#include "base/i18n/rtl.h" #include "base/memory/scoped_ptr.h" #include "base/process_util.h" #include "content/browser/renderer_host/render_view_host_delegate.h" @@ -129,10 +128,9 @@ class InterstitialPage : public NotificationObserver, int error_code); virtual void DidNavigate(RenderViewHost* render_view_host, const ViewHostMsg_FrameNavigate_Params& params); - virtual void UpdateTitle( - RenderViewHost* render_view_host, - int32 page_id, - const base::i18n::String16WithDirection& title) OVERRIDE; + virtual void UpdateTitle(RenderViewHost* render_view_host, + int32 page_id, + const std::wstring& title); virtual void DomOperationResponse(const std::string& json_string, int automation_id); virtual RendererPreferences GetRendererPrefs(Profile* profile) const; @@ -228,7 +226,7 @@ class InterstitialPage : public NotificationObserver, // The original title of the tab that should be reverted to when the // interstitial is hidden. - base::i18n::String16WithDirection original_tab_title_; + std::wstring original_tab_title_; // Our RenderViewHostViewDelegate, necessary for accelerators to work. scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_; diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 0049d68..310e1cf 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -242,7 +242,7 @@ NavigationEntry* NavigationController::CreateNavigationEntry( -1, loaded_url, referrer, - base::i18n::String16WithDirection(), + string16(), transition); entry->set_virtual_url(url); entry->set_user_typed_url(url); diff --git a/content/browser/tab_contents/navigation_entry.cc b/content/browser/tab_contents/navigation_entry.cc index 099d2e4..dcc5ee8 100644 --- a/content/browser/tab_contents/navigation_entry.cc +++ b/content/browser/tab_contents/navigation_entry.cc @@ -54,7 +54,7 @@ NavigationEntry::NavigationEntry(SiteInstance* instance, int page_id, const GURL& url, const GURL& referrer, - const base::i18n::String16WithDirection& title, + const string16& title, PageTransition::Type transition_type) : unique_id_(GetUniqueID()), site_instance_(instance), @@ -76,16 +76,16 @@ void NavigationEntry::set_site_instance(SiteInstance* site_instance) { site_instance_ = site_instance; } -const base::i18n::String16WithDirection& NavigationEntry::GetTitleForDisplay( +const string16& NavigationEntry::GetTitleForDisplay( const std::string& languages) { // Most pages have real titles. Don't even bother caching anything if this is // the case. - if (!title_.is_empty()) + 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_.is_empty()) + if (!cached_display_title_.empty()) return cached_display_title_; // Use the virtual URL first if any, and fall back on using the real URL. @@ -103,13 +103,7 @@ const base::i18n::String16WithDirection& NavigationEntry::GetTitleForDisplay( title = title.substr(slashpos + 1); } - string16 elided_title; - ui::ElideString(title, content::kMaxTitleChars, &elided_title); - - // The computed title is a URL or a filename; assume it's LTR. - cached_display_title_ = - base::i18n::String16WithDirection(elided_title, - base::i18n::LEFT_TO_RIGHT); + ui::ElideString(title, content::kMaxTitleChars, &cached_display_title_); return cached_display_title_; } diff --git a/content/browser/tab_contents/navigation_entry.h b/content/browser/tab_contents/navigation_entry.h index 28ffa99..671cc5b 100644 --- a/content/browser/tab_contents/navigation_entry.h +++ b/content/browser/tab_contents/navigation_entry.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" -#include "base/i18n/rtl.h" #include "chrome/common/security_style.h" #include "content/common/page_transition_types.h" #include "content/common/page_type.h" @@ -184,7 +183,7 @@ class NavigationEntry { int page_id, const GURL& url, const GURL& referrer, - const base::i18n::String16WithDirection& title, + const string16& title, PageTransition::Type transition_type); ~NavigationEntry(); @@ -227,7 +226,7 @@ class NavigationEntry { // the user. void set_url(const GURL& url) { url_ = url; - cached_display_title_ = base::i18n::String16WithDirection(); + cached_display_title_.clear(); } const GURL& url() const { return url_; @@ -250,7 +249,7 @@ class NavigationEntry { // if there is no overridden display URL, it will return the actual one. void set_virtual_url(const GURL& url) { virtual_url_ = (url == url_) ? GURL() : url; - cached_display_title_ = base::i18n::String16WithDirection(); + cached_display_title_.clear(); } bool has_virtual_url() const { return !virtual_url_.is_empty(); @@ -270,11 +269,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 base::i18n::String16WithDirection& title) { + void set_title(const string16& title) { title_ = title; - cached_display_title_ = base::i18n::String16WithDirection(); + cached_display_title_.clear(); } - const base::i18n::String16WithDirection& title() const { + const string16& title() const { return title_; } @@ -325,8 +324,7 @@ class NavigationEntry { // the page if it is available or the URL. |languages| is the list of // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper // URL formatting isn't needed (e.g., unit tests). - const base::i18n::String16WithDirection& GetTitleForDisplay( - const std::string& languages); + const string16& GetTitleForDisplay(const std::string& languages); // Returns true if the current tab is in view source mode. This will be false // if there is no navigation. @@ -409,7 +407,7 @@ class NavigationEntry { GURL referrer_; GURL virtual_url_; bool update_virtual_url_with_url_; - base::i18n::String16WithDirection title_; + string16 title_; FaviconStatus favicon_; std::string content_state_; int32 page_id_; @@ -423,7 +421,7 @@ class NavigationEntry { // us from having to do URL formatting on the URL evey time the title is // displayed. When the URL, virtual URL, or title is set, this should be // cleared to force a refresh. - base::i18n::String16WithDirection cached_display_title_; + string16 cached_display_title_; // Copy and assignment is explicitly allowed for this class. }; diff --git a/content/browser/tab_contents/navigation_entry_unittest.cc b/content/browser/tab_contents/navigation_entry_unittest.cc index 6fbc98f..ee7d083 100644 --- a/content/browser/tab_contents/navigation_entry_unittest.cc +++ b/content/browser/tab_contents/navigation_entry_unittest.cc @@ -18,13 +18,11 @@ class NavigationEntryTest : public testing::Test { entry1_.reset(new NavigationEntry); instance_ = SiteInstance::CreateSiteInstance(NULL); - entry2_.reset(new NavigationEntry( - instance_, 3, - GURL("test:url"), - GURL("from"), - base::i18n::String16WithDirection(ASCIIToUTF16("title"), - base::i18n::LEFT_TO_RIGHT), - PageTransition::TYPED)); + entry2_.reset(new NavigationEntry(instance_, 3, + GURL("test:url"), + GURL("from"), + ASCIIToUTF16("title"), + PageTransition::TYPED)); } virtual void TearDown() { @@ -55,26 +53,23 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL(), entry1_.get()->url()); EXPECT_EQ(GURL(), entry1_.get()->virtual_url()); - EXPECT_TRUE(entry1_.get()->GetTitleForDisplay("").is_empty()); + EXPECT_TRUE(entry1_.get()->GetTitleForDisplay("").empty()); // Setting URL affects virtual_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()->virtual_url()); EXPECT_EQ(ASCIIToUTF16("www.google.com"), - entry1_.get()->GetTitleForDisplay("").string()); + entry1_.get()->GetTitleForDisplay("")); // file:/// URLs should only show the filename. entry1_.get()->set_url(GURL("file:///foo/bar baz.txt")); EXPECT_EQ(ASCIIToUTF16("bar baz.txt"), - entry1_.get()->GetTitleForDisplay("").string()); + entry1_.get()->GetTitleForDisplay("")); // Title affects GetTitleForDisplay - entry1_.get()->set_title( - base::i18n::String16WithDirection(ASCIIToUTF16("Google"), - base::i18n::LEFT_TO_RIGHT)); - EXPECT_EQ(ASCIIToUTF16("Google"), - entry1_.get()->GetTitleForDisplay("").string()); + entry1_.get()->set_title(ASCIIToUTF16("Google")); + EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay("")); // Setting virtual_url doesn't affect URL entry2_.get()->set_virtual_url(GURL("display:url")); @@ -83,8 +78,7 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL("display:url"), entry2_.get()->virtual_url()); // Having a title set in constructor overrides virtual URL - EXPECT_EQ(ASCIIToUTF16("title"), - entry2_.get()->GetTitleForDisplay("").string()); + EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay("")); // User typed URL is independent of the others EXPECT_EQ(GURL(), entry1_.get()->user_typed_url()); @@ -157,12 +151,10 @@ TEST_F(NavigationEntryTest, NavigationEntryAccessors) { EXPECT_EQ(GURL("from2"), entry2_.get()->referrer()); // Title - EXPECT_EQ(string16(), entry1_.get()->title().string()); - EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->title().string()); - entry2_.get()->set_title( - base::i18n::String16WithDirection(ASCIIToUTF16("title2"), - base::i18n::LEFT_TO_RIGHT)); - EXPECT_EQ(ASCIIToUTF16("title2"), entry2_.get()->title().string()); + EXPECT_EQ(string16(), entry1_.get()->title()); + EXPECT_EQ(ASCIIToUTF16("title"), 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/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc index 7462e03..3ff2092 100644 --- a/content/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc @@ -176,8 +176,7 @@ TEST_F(RenderViewHostManagerTest, Navigate) { // 1) The first navigation. -------------------------- GURL url1("http://www.google.com/"); NavigationEntry entry1(NULL /* instance */, -1 /* page_id */, url1, - GURL() /* referrer */, - base::i18n::String16WithDirection() /* title */, + GURL() /* referrer */, string16() /* title */, PageTransition::TYPED); host = manager.Navigate(entry1); @@ -196,8 +195,7 @@ TEST_F(RenderViewHostManagerTest, Navigate) { // 2) Navigate to next site. ------------------------- GURL url2("http://www.google.com/foo"); NavigationEntry entry2(NULL /* instance */, -1 /* page_id */, url2, - url1 /* referrer */, - base::i18n::String16WithDirection() /* title */, + url1 /* referrer */, string16() /* title */, PageTransition::LINK); host = manager.Navigate(entry2); @@ -214,8 +212,7 @@ TEST_F(RenderViewHostManagerTest, Navigate) { // 3) Cross-site navigate to next site. -------------- GURL url3("http://webkit.org/"); NavigationEntry entry3(NULL /* instance */, -1 /* page_id */, url3, - url2 /* referrer */, - base::i18n::String16WithDirection() /* title */, + url2 /* referrer */, string16() /* title */, PageTransition::LINK); host = manager.Navigate(entry3); @@ -250,8 +247,7 @@ TEST_F(RenderViewHostManagerTest, WebUI) { GURL url(chrome::kChromeUINewTabURL); NavigationEntry entry(NULL /* instance */, -1 /* page_id */, url, - GURL() /* referrer */, - base::i18n::String16WithDirection() /* title */, + GURL() /* referrer */, string16() /* title */, PageTransition::TYPED); RenderViewHost* host = manager.Navigate(entry); @@ -289,8 +285,7 @@ TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { // NTP is a Web UI page. GURL ntp_url(chrome::kChromeUINewTabURL); NavigationEntry ntp_entry(NULL /* instance */, -1 /* page_id */, ntp_url, - GURL() /* referrer */, - base::i18n::String16WithDirection() /* title */, + GURL() /* referrer */, string16() /* title */, PageTransition::TYPED); // about: URLs are not Web UI pages. @@ -300,8 +295,7 @@ TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { BrowserURLHandler::RewriteURLIfNecessary( &about_url, profile_.get(), &reverse_on_redirect); NavigationEntry about_entry(NULL /* instance */, -1 /* page_id */, about_url, - GURL() /* referrer */, - base::i18n::String16WithDirection() /* title */, + GURL() /* referrer */, string16() /* title */, PageTransition::TYPED); EXPECT_TRUE(ShouldSwapProcesses(&manager, &ntp_entry, &about_entry)); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 424549d..7c113a3 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -441,10 +441,8 @@ 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)).string(); + GetString(prefs::kAcceptLanguages)); } WebUI* our_web_ui = render_manager_.pending_web_ui() ? render_manager_.pending_web_ui() : render_manager_.web_ui(); @@ -453,8 +451,6 @@ 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; @@ -467,10 +463,8 @@ 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)).string(); + GetString(prefs::kAcceptLanguages)); } return EmptyString16(); } @@ -1094,11 +1088,8 @@ void TabContents::UpdateHistoryPageTitle(const NavigationEntry& entry) { return; HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); - 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()); - } + if (hs) + hs->SetPageTitle(entry.virtual_url(), entry.title()); } double TabContents::GetZoomLevel() const { @@ -1563,23 +1554,18 @@ TabContents::CreateHistoryAddPageArgs( return add_page_args; } -bool TabContents::UpdateTitleForEntry( - NavigationEntry* entry, - const base::i18n::String16WithDirection& title) { +bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, + const std::wstring& 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." - base::i18n::String16WithDirection final_title; + string16 final_title; bool explicit_set; - if (entry->url().SchemeIsFile() && title.is_empty()) { - final_title = base::i18n::String16WithDirection( - UTF8ToUTF16(entry->url().ExtractFileName()), - base::i18n::LEFT_TO_RIGHT); + if (entry->url().SchemeIsFile() && title.empty()) { + final_title = UTF8ToUTF16(entry->url().ExtractFileName()); explicit_set = false; // Don't count synthetic titles toward the set limit. } else { - string16 trimmed; - TrimWhitespace(title.string(), TRIM_ALL, &trimmed); - final_title = base::i18n::String16WithDirection(trimmed, title.direction()); + TrimWhitespace(WideToUTF16Hack(title), TRIM_ALL, &final_title); explicit_set = true; } @@ -1594,9 +1580,7 @@ bool TabContents::UpdateTitleForEntry( } // Lastly, set the title for the view. - // TODO(evan): use directionality of title. - // http://code.google.com/p/chromium/issues/detail?id=27094 - view_->SetPageTitle(UTF16ToWide(final_title.string())); + view_->SetPageTitle(UTF16ToWideHack(final_title)); NotificationService::current()->Notify( NotificationType::TAB_CONTENTS_TITLE_UPDATED, @@ -1893,8 +1877,7 @@ void TabContents::UpdateState(RenderViewHost* rvh, } void TabContents::UpdateTitle(RenderViewHost* rvh, - int32 page_id, - const base::i18n::String16WithDirection& title) { + int32 page_id, const std::wstring& title) { // If we have a title, that's a pretty good indication that we've started // getting useful data. SetNotWaitingForResponse(); diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 9f78dbb..17992dc 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -745,8 +745,7 @@ class TabContents : public PageNavigator, // This is used as the backend for state updates, which include a new title, // or the dedicated set title message. It returns true if the new title is // different and was therefore updated. - bool UpdateTitleForEntry(NavigationEntry* entry, - const base::i18n::String16WithDirection& title); + bool UpdateTitleForEntry(NavigationEntry* entry, const std::wstring& title); // Causes the TabContents to navigate in the right renderer to |entry|, which // must be already part of the entries in the navigation controller. @@ -787,10 +786,9 @@ class TabContents : public PageNavigator, virtual void UpdateState(RenderViewHost* render_view_host, int32 page_id, const std::string& state); - virtual void UpdateTitle( - RenderViewHost* render_view_host, - int32 page_id, - const base::i18n::String16WithDirection& title) OVERRIDE; + virtual void UpdateTitle(RenderViewHost* render_view_host, + int32 page_id, + const std::wstring& title); virtual void UpdateEncoding(RenderViewHost* render_view_host, const std::string& encoding); virtual void UpdateTargetURL(int32 page_id, const GURL& url); |