OLD | NEW |
---|---|
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/search_engines/template_url_table_model.h" | 5 #include "chrome/browser/search_engines/template_url_table_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 DCHECK(row >= 0 && row < RowCount()); | 181 DCHECK(row >= 0 && row < RowCount()); |
182 const TemplateURL& url = entries_[row]->template_url(); | 182 const TemplateURL& url = entries_[row]->template_url(); |
183 | 183 |
184 switch (col_id) { | 184 switch (col_id) { |
185 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: { | 185 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: { |
186 std::wstring url_short_name = url.short_name(); | 186 std::wstring url_short_name = url.short_name(); |
187 // TODO(xji): Consider adding a special case if the short name is a URL, | 187 // TODO(xji): Consider adding a special case if the short name is a URL, |
188 // since those should always be displayed LTR. Please refer to | 188 // since those should always be displayed LTR. Please refer to |
189 // http://crbug.com/6726 for more information. | 189 // http://crbug.com/6726 for more information. |
190 base::i18n::AdjustStringForLocaleDirection(&url_short_name); | 190 base::i18n::AdjustStringForLocaleDirection(&url_short_name); |
191 return (template_url_model_->GetDefaultSearchProvider() == &url) ? | 191 if (template_url_model_->GetDefaultSearchProvider() == &url) { |
192 l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, | 192 return UTF16ToWideHack( |
193 url_short_name) : url_short_name; | 193 l10n_util::GetStringFUTF16(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, |
194 WideToUTF16Hack(url_short_name))); | |
195 } else { | |
viettrungluu
2010/12/29 19:04:15
Nit: else unnecessary. (Style guide prefers |if {
Avi (use Gerrit)
2010/12/29 19:40:49
Done.
| |
196 return url_short_name; | |
197 } | |
194 } | 198 } |
195 | 199 |
196 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { | 200 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { |
197 // Keyword should be domain name. Force it to have LTR directionality. | 201 // Keyword should be domain name. Force it to have LTR directionality. |
198 string16 keyword = WideToUTF16(url.keyword()); | 202 string16 keyword = WideToUTF16(url.keyword()); |
199 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); | 203 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); |
200 return UTF16ToWide(keyword); | 204 return UTF16ToWide(keyword); |
201 } | 205 } |
202 | 206 |
203 default: | 207 default: |
(...skipping 12 matching lines...) Expand all Loading... | |
216 } | 220 } |
217 | 221 |
218 bool TemplateURLTableModel::HasGroups() { | 222 bool TemplateURLTableModel::HasGroups() { |
219 return true; | 223 return true; |
220 } | 224 } |
221 | 225 |
222 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { | 226 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { |
223 Groups groups; | 227 Groups groups; |
224 | 228 |
225 Group search_engine_group; | 229 Group search_engine_group; |
226 search_engine_group.title = | 230 search_engine_group.title = UTF16ToWideHack( |
227 l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR); | 231 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); |
228 search_engine_group.id = kMainGroupID; | 232 search_engine_group.id = kMainGroupID; |
229 groups.push_back(search_engine_group); | 233 groups.push_back(search_engine_group); |
230 | 234 |
231 Group other_group; | 235 Group other_group; |
232 other_group.title = | 236 other_group.title = UTF16ToWideHack( |
233 l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR); | 237 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); |
234 other_group.id = kOtherGroupID; | 238 other_group.id = kOtherGroupID; |
235 groups.push_back(other_group); | 239 groups.push_back(other_group); |
236 | 240 |
237 return groups; | 241 return groups; |
238 } | 242 } |
239 | 243 |
240 int TemplateURLTableModel::GetGroupID(int row) { | 244 int TemplateURLTableModel::GetGroupID(int row) { |
241 DCHECK(row >= 0 && row < RowCount()); | 245 DCHECK(row >= 0 && row < RowCount()); |
242 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; | 246 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; |
243 } | 247 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { | 377 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { |
374 std::vector<ModelEntry*>::iterator i = | 378 std::vector<ModelEntry*>::iterator i = |
375 find(entries_.begin(), entries_.end(), entry); | 379 find(entries_.begin(), entries_.end(), entry); |
376 DCHECK(i != entries_.end()); | 380 DCHECK(i != entries_.end()); |
377 NotifyChanged(static_cast<int>(i - entries_.begin())); | 381 NotifyChanged(static_cast<int>(i - entries_.begin())); |
378 } | 382 } |
379 | 383 |
380 void TemplateURLTableModel::OnTemplateURLModelChanged() { | 384 void TemplateURLTableModel::OnTemplateURLModelChanged() { |
381 Reload(); | 385 Reload(); |
382 } | 386 } |
OLD | NEW |