OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |