Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/dom_ui.cc ('k') | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/dom_ui/new_tab_ui.h" 7 #include "chrome/browser/dom_ui/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/histogram.h" 14 #include "base/histogram.h"
15 #include "base/i18n/rtl.h"
15 #include "base/singleton.h" 16 #include "base/singleton.h"
16 #include "base/thread.h" 17 #include "base/thread.h"
17 #include "chrome/browser/browser.h" 18 #include "chrome/browser/browser.h"
18 #include "chrome/browser/chrome_thread.h" 19 #include "chrome/browser/chrome_thread.h"
19 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" 20 #include "chrome/browser/dom_ui/dom_ui_theme_source.h"
20 #include "chrome/browser/dom_ui/most_visited_handler.h" 21 #include "chrome/browser/dom_ui/most_visited_handler.h"
21 #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h" 22 #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h"
22 #include "chrome/browser/dom_ui/ntp_resource_cache.h" 23 #include "chrome/browser/dom_ui/ntp_resource_cache.h"
23 #include "chrome/browser/dom_ui/shown_sections_handler.h" 24 #include "chrome/browser/dom_ui/shown_sections_handler.h"
24 #include "chrome/browser/dom_ui/tips_handler.h" 25 #include "chrome/browser/dom_ui/tips_handler.h"
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // 637 //
637 // Since the title can contain BiDi text, we need to mark the text as either 638 // Since the title can contain BiDi text, we need to mark the text as either
638 // RTL or LTR, depending on the characters in the string. If we use the URL 639 // RTL or LTR, depending on the characters in the string. If we use the URL
639 // as the title, we mark the title as LTR since URLs are always treated as 640 // as the title, we mark the title as LTR since URLs are always treated as
640 // left to right strings. Simply setting the title's "dir" attribute works 641 // left to right strings. Simply setting the title's "dir" attribute works
641 // fine for rendering and truncating the title. However, it does not work for 642 // fine for rendering and truncating the title. However, it does not work for
642 // entire title within a tooltip when the mouse is over the title link.. For 643 // entire title within a tooltip when the mouse is over the title link.. For
643 // example, without LRE-PDF pair, the title "Yahoo!" will be rendered as 644 // example, without LRE-PDF pair, the title "Yahoo!" will be rendered as
644 // "!Yahoo" within the tooltip when the mouse is over the title link. 645 // "!Yahoo" within the tooltip when the mouse is over the title link.
645 std::wstring direction = kDefaultHtmlTextDirection; 646 std::wstring direction = kDefaultHtmlTextDirection;
646 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 647 if (base::i18n::IsRTL()) {
647 if (using_url_as_the_title) { 648 if (using_url_as_the_title) {
648 l10n_util::WrapStringWithLTRFormatting(&title_to_set); 649 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
649 } else { 650 } else {
650 if (l10n_util::StringContainsStrongRTLChars(wstring_title)) { 651 if (base::i18n::StringContainsStrongRTLChars(wstring_title)) {
651 l10n_util::WrapStringWithRTLFormatting(&title_to_set); 652 base::i18n::WrapStringWithRTLFormatting(&title_to_set);
652 direction = kRTLHtmlTextDirection; 653 direction = kRTLHtmlTextDirection;
653 } else { 654 } else {
654 l10n_util::WrapStringWithLTRFormatting(&title_to_set); 655 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
655 } 656 }
656 } 657 }
657 } 658 }
658 dictionary->SetString(L"title", title_to_set); 659 dictionary->SetString(L"title", title_to_set);
659 dictionary->SetString(L"direction", direction); 660 dictionary->SetString(L"direction", direction);
660 } 661 }
661 662
662 /////////////////////////////////////////////////////////////////////////////// 663 ///////////////////////////////////////////////////////////////////////////////
663 // NewTabHTMLSource 664 // NewTabHTMLSource
664 665
(...skipping 12 matching lines...) Expand all
677 // URL from the new tab page, but in any case it's an error. 678 // URL from the new tab page, but in any case it's an error.
678 NOTREACHED(); 679 NOTREACHED();
679 return; 680 return;
680 } 681 }
681 682
682 scoped_refptr<RefCountedBytes> html_bytes = 683 scoped_refptr<RefCountedBytes> html_bytes =
683 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record); 684 profile_->GetNTPResourceCache()->GetNewTabHTML(is_off_the_record);
684 685
685 SendResponse(request_id, html_bytes); 686 SendResponse(request_id, html_bytes);
686 } 687 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui.cc ('k') | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698