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

Side by Side Diff: chrome/browser/views/bookmark_bar_view.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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/views/bookmark_bar_view.h" 5 #include "chrome/browser/views/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "app/gfx/canvas.h" 12 #include "app/gfx/canvas.h"
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "app/os_exchange_data.h" 14 #include "app/os_exchange_data.h"
15 #include "app/resource_bundle.h" 15 #include "app/resource_bundle.h"
16 #include "app/text_elider.h" 16 #include "app/text_elider.h"
17 #include "base/i18n/rtl.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "chrome/browser/bookmarks/bookmark_model.h" 19 #include "chrome/browser/bookmarks/bookmark_model.h"
19 #include "chrome/browser/bookmarks/bookmark_utils.h" 20 #include "chrome/browser/bookmarks/bookmark_utils.h"
20 #include "chrome/browser/browser.h" 21 #include "chrome/browser/browser.h"
21 #include "chrome/browser/browser_theme_provider.h" 22 #include "chrome/browser/browser_theme_provider.h"
22 #include "chrome/browser/metrics/user_metrics.h" 23 #include "chrome/browser/metrics/user_metrics.h"
23 #include "chrome/browser/pref_service.h" 24 #include "chrome/browser/pref_service.h"
24 #include "chrome/browser/profile.h" 25 #include "chrome/browser/profile.h"
25 #include "chrome/browser/renderer_host/render_view_host.h" 26 #include "chrome/browser/renderer_host/render_view_host.h"
26 #include "chrome/browser/renderer_host/render_widget_host_view.h" 27 #include "chrome/browser/renderer_host/render_widget_host_view.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const std::wstring& title, 134 const std::wstring& title,
134 const std::wstring& languages) { 135 const std::wstring& languages) {
135 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(), 136 int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(),
136 screen_loc.y()); 137 screen_loc.y());
137 gfx::Font tt_font = views::TooltipManager::GetDefaultFont(); 138 gfx::Font tt_font = views::TooltipManager::GetDefaultFont();
138 std::wstring result; 139 std::wstring result;
139 140
140 // First the title. 141 // First the title.
141 if (!title.empty()) { 142 if (!title.empty()) {
142 std::wstring localized_title; 143 std::wstring localized_title;
143 if (l10n_util::AdjustStringForLocaleDirection(title, &localized_title)) 144 if (base::i18n::AdjustStringForLocaleDirection(title, &localized_title))
144 result.append(gfx::ElideText(localized_title, tt_font, max_width)); 145 result.append(gfx::ElideText(localized_title, tt_font, max_width));
145 else 146 else
146 result.append(gfx::ElideText(title, tt_font, max_width)); 147 result.append(gfx::ElideText(title, tt_font, max_width));
147 } 148 }
148 149
149 // Only show the URL if the url and title differ. 150 // Only show the URL if the url and title differ.
150 if (title != UTF8ToWide(url.spec())) { 151 if (title != UTF8ToWide(url.spec())) {
151 if (!result.empty()) 152 if (!result.empty())
152 result.append(views::TooltipManager::GetLineSeparator()); 153 result.append(views::TooltipManager::GetLineSeparator());
153 154
154 // We need to explicitly specify the directionality of the URL's text to 155 // We need to explicitly specify the directionality of the URL's text to
155 // make sure it is treated as an LTR string when the context is RTL. For 156 // make sure it is treated as an LTR string when the context is RTL. For
156 // example, the URL "http://www.yahoo.com/" appears as 157 // example, the URL "http://www.yahoo.com/" appears as
157 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since 158 // "/http://www.yahoo.com" when rendered, as is, in an RTL context since
158 // the Unicode BiDi algorithm puts certain characters on the left by 159 // the Unicode BiDi algorithm puts certain characters on the left by
159 // default. 160 // default.
160 std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages)); 161 std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages));
161 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) 162 if (base::i18n::IsRTL())
162 l10n_util::WrapStringWithLTRFormatting(&elided_url); 163 base::i18n::WrapStringWithLTRFormatting(&elided_url);
163 result.append(elided_url); 164 result.append(elided_url);
164 } 165 }
165 return result; 166 return result;
166 } 167 }
167 168
168 // BookmarkButton ------------------------------------------------------------- 169 // BookmarkButton -------------------------------------------------------------
169 170
170 // Buttons used for the bookmarks on the bookmark bar. 171 // Buttons used for the bookmarks on the bookmark bar.
171 172
172 class BookmarkButton : public views::TextButton { 173 class BookmarkButton : public views::TextButton {
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 // The tooltip is the only way we have to display text explaining the error 1716 // The tooltip is the only way we have to display text explaining the error
1716 // to the user. 1717 // to the user.
1717 sync_error_button->SetTooltipText( 1718 sync_error_button->SetTooltipText(
1718 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); 1719 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC));
1719 sync_error_button->SetAccessibleName( 1720 sync_error_button->SetAccessibleName(
1720 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON)); 1721 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON));
1721 sync_error_button->SetIcon( 1722 sync_error_button->SetIcon(
1722 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); 1723 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING));
1723 return sync_error_button; 1724 return sync_error_button;
1724 } 1725 }
OLDNEW
« no previous file with comments | « chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc ('k') | chrome/browser/views/bookmark_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698