| 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 if (template_url_model_->GetDefaultSearchProvider() == &url) { | 191 return (template_url_model_->GetDefaultSearchProvider() == &url) ? |
| 192 return UTF16ToWideHack( | 192 l10n_util::GetStringF(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, |
| 193 l10n_util::GetStringFUTF16(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, | 193 url_short_name) : url_short_name; |
| 194 WideToUTF16Hack(url_short_name))); | |
| 195 } | |
| 196 return url_short_name; | |
| 197 } | 194 } |
| 198 | 195 |
| 199 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { | 196 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { |
| 200 // Keyword should be domain name. Force it to have LTR directionality. | 197 // Keyword should be domain name. Force it to have LTR directionality. |
| 201 string16 keyword = WideToUTF16(url.keyword()); | 198 string16 keyword = WideToUTF16(url.keyword()); |
| 202 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); | 199 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); |
| 203 return UTF16ToWide(keyword); | 200 return UTF16ToWide(keyword); |
| 204 } | 201 } |
| 205 | 202 |
| 206 default: | 203 default: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 219 } | 216 } |
| 220 | 217 |
| 221 bool TemplateURLTableModel::HasGroups() { | 218 bool TemplateURLTableModel::HasGroups() { |
| 222 return true; | 219 return true; |
| 223 } | 220 } |
| 224 | 221 |
| 225 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { | 222 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { |
| 226 Groups groups; | 223 Groups groups; |
| 227 | 224 |
| 228 Group search_engine_group; | 225 Group search_engine_group; |
| 229 search_engine_group.title = UTF16ToWideHack( | 226 search_engine_group.title = |
| 230 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); | 227 l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR); |
| 231 search_engine_group.id = kMainGroupID; | 228 search_engine_group.id = kMainGroupID; |
| 232 groups.push_back(search_engine_group); | 229 groups.push_back(search_engine_group); |
| 233 | 230 |
| 234 Group other_group; | 231 Group other_group; |
| 235 other_group.title = UTF16ToWideHack( | 232 other_group.title = |
| 236 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); | 233 l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR); |
| 237 other_group.id = kOtherGroupID; | 234 other_group.id = kOtherGroupID; |
| 238 groups.push_back(other_group); | 235 groups.push_back(other_group); |
| 239 | 236 |
| 240 return groups; | 237 return groups; |
| 241 } | 238 } |
| 242 | 239 |
| 243 int TemplateURLTableModel::GetGroupID(int row) { | 240 int TemplateURLTableModel::GetGroupID(int row) { |
| 244 DCHECK(row >= 0 && row < RowCount()); | 241 DCHECK(row >= 0 && row < RowCount()); |
| 245 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; | 242 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; |
| 246 } | 243 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { | 373 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { |
| 377 std::vector<ModelEntry*>::iterator i = | 374 std::vector<ModelEntry*>::iterator i = |
| 378 find(entries_.begin(), entries_.end(), entry); | 375 find(entries_.begin(), entries_.end(), entry); |
| 379 DCHECK(i != entries_.end()); | 376 DCHECK(i != entries_.end()); |
| 380 NotifyChanged(static_cast<int>(i - entries_.begin())); | 377 NotifyChanged(static_cast<int>(i - entries_.begin())); |
| 381 } | 378 } |
| 382 | 379 |
| 383 void TemplateURLTableModel::OnTemplateURLModelChanged() { | 380 void TemplateURLTableModel::OnTemplateURLModelChanged() { |
| 384 Reload(); | 381 Reload(); |
| 385 } | 382 } |
| OLD | NEW |