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

Side by Side Diff: chrome/browser/search_engines/template_url_table_model.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/search_engines/template_url.cc ('k') | chrome/browser/ssl/ssl_blocking_page.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/search_engines/template_url_table_model.h" 5 #include "chrome/browser/search_engines/template_url_table_model.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "app/table_model_observer.h" 11 #include "app/table_model_observer.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/i18n/rtl.h"
13 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/favicon_service.h" 16 #include "chrome/browser/favicon_service.h"
16 #include "chrome/browser/profile.h" 17 #include "chrome/browser/profile.h"
17 #include "gfx/codec/png_codec.h" 18 #include "gfx/codec/png_codec.h"
18 #include "grit/app_resources.h" 19 #include "grit/app_resources.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
20 21
21 // Group IDs used by TemplateURLTableModel. 22 // Group IDs used by TemplateURLTableModel.
22 static const int kMainGroupID = 0; 23 static const int kMainGroupID = 0;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 std::wstring TemplateURLTableModel::GetText(int row, int col_id) { 174 std::wstring TemplateURLTableModel::GetText(int row, int col_id) {
174 DCHECK(row >= 0 && row < RowCount()); 175 DCHECK(row >= 0 && row < RowCount());
175 const TemplateURL& url = entries_[row]->template_url(); 176 const TemplateURL& url = entries_[row]->template_url();
176 177
177 switch (col_id) { 178 switch (col_id) {
178 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: { 179 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: {
179 std::wstring url_short_name = url.short_name(); 180 std::wstring url_short_name = url.short_name();
180 // TODO(xji): Consider adding a special case if the short name is a URL, 181 // TODO(xji): Consider adding a special case if the short name is a URL,
181 // since those should always be displayed LTR. Please refer to 182 // since those should always be displayed LTR. Please refer to
182 // http://crbug.com/6726 for more information. 183 // http://crbug.com/6726 for more information.
183 l10n_util::AdjustStringForLocaleDirection(url_short_name, 184 base::i18n::AdjustStringForLocaleDirection(url_short_name,
184 &url_short_name); 185 &url_short_name);
185 return (template_url_model_->GetDefaultSearchProvider() == &url) ? 186 return (template_url_model_->GetDefaultSearchProvider() == &url) ?
186 l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, 187 l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE,
187 url_short_name) : url_short_name; 188 url_short_name) : url_short_name;
188 } 189 }
189 190
190 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { 191 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: {
191 const std::wstring& keyword = url.keyword(); 192 const std::wstring& keyword = url.keyword();
192 // Keyword should be domain name. Force it to have LTR directionality. 193 // Keyword should be domain name. Force it to have LTR directionality.
193 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 194 if (base::i18n::IsRTL()) {
194 std::wstring localized_keyword = keyword; 195 std::wstring localized_keyword = keyword;
195 l10n_util::WrapStringWithLTRFormatting(&localized_keyword); 196 base::i18n::WrapStringWithLTRFormatting(&localized_keyword);
196 return localized_keyword; 197 return localized_keyword;
197 } 198 }
198 return keyword; 199 return keyword;
199 break; 200 break;
200 } 201 }
201 202
202 default: 203 default:
203 NOTREACHED(); 204 NOTREACHED();
204 return std::wstring(); 205 return std::wstring();
205 } 206 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { 365 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) {
365 std::vector<ModelEntry*>::iterator i = 366 std::vector<ModelEntry*>::iterator i =
366 find(entries_.begin(), entries_.end(), entry); 367 find(entries_.begin(), entries_.end(), entry);
367 DCHECK(i != entries_.end()); 368 DCHECK(i != entries_.end());
368 NotifyChanged(static_cast<int>(i - entries_.begin())); 369 NotifyChanged(static_cast<int>(i - entries_.begin()));
369 } 370 }
370 371
371 void TemplateURLTableModel::OnTemplateURLModelChanged() { 372 void TemplateURLTableModel::OnTemplateURLModelChanged() {
372 Reload(); 373 Reload();
373 } 374 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | chrome/browser/ssl/ssl_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698