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

Side by Side Diff: chrome/browser/search_engines/template_url_table_model.cc

Issue 6044007: Remove wstring from TableModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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/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>
viettrungluu 2010/12/29 23:41:17 These two #includes are presumably unneeded, since
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "app/table_model_observer.h" 12 #include "app/table_model_observer.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/favicon_service.h" 17 #include "chrome/browser/favicon_service.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 if (observer_) 172 if (observer_)
173 observer_->OnModelChanged(); 173 observer_->OnModelChanged();
174 } 174 }
175 175
176 int TemplateURLTableModel::RowCount() { 176 int TemplateURLTableModel::RowCount() {
177 return static_cast<int>(entries_.size()); 177 return static_cast<int>(entries_.size());
178 } 178 }
179 179
180 std::wstring TemplateURLTableModel::GetText(int row, int col_id) { 180 string16 TemplateURLTableModel::GetText(int row, int col_id) {
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 string16 url_short_name = WideToUTF16Hack(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 if (template_url_model_->GetDefaultSearchProvider() == &url) {
192 return UTF16ToWideHack( 192 return l10n_util::GetStringFUTF16(
193 l10n_util::GetStringFUTF16(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, 193 IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE,
194 WideToUTF16Hack(url_short_name))); 194 url_short_name);
195 } 195 }
196 return url_short_name; 196 return url_short_name;
197 } 197 }
198 198
199 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { 199 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: {
200 // Keyword should be domain name. Force it to have LTR directionality. 200 // Keyword should be domain name. Force it to have LTR directionality.
201 string16 keyword = WideToUTF16(url.keyword()); 201 string16 keyword = WideToUTF16(url.keyword());
202 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); 202 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword);
203 return UTF16ToWide(keyword); 203 return keyword;
204 } 204 }
205 205
206 default: 206 default:
207 NOTREACHED(); 207 NOTREACHED();
208 return std::wstring(); 208 return string16();
209 } 209 }
210 } 210 }
211 211
212 SkBitmap TemplateURLTableModel::GetIcon(int row) { 212 SkBitmap TemplateURLTableModel::GetIcon(int row) {
213 DCHECK(row >= 0 && row < RowCount()); 213 DCHECK(row >= 0 && row < RowCount());
214 return entries_[row]->GetIcon(); 214 return entries_[row]->GetIcon();
215 } 215 }
216 216
217 void TemplateURLTableModel::SetObserver(TableModelObserver* observer) { 217 void TemplateURLTableModel::SetObserver(TableModelObserver* observer) {
218 observer_ = observer; 218 observer_ = observer;
219 } 219 }
220 220
221 bool TemplateURLTableModel::HasGroups() { 221 bool TemplateURLTableModel::HasGroups() {
222 return true; 222 return true;
223 } 223 }
224 224
225 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { 225 TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() {
226 Groups groups; 226 Groups groups;
227 227
228 Group search_engine_group; 228 Group search_engine_group;
229 search_engine_group.title = UTF16ToWideHack( 229 search_engine_group.title =
230 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); 230 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR);
231 search_engine_group.id = kMainGroupID; 231 search_engine_group.id = kMainGroupID;
232 groups.push_back(search_engine_group); 232 groups.push_back(search_engine_group);
233 233
234 Group other_group; 234 Group other_group;
235 other_group.title = UTF16ToWideHack( 235 other_group.title =
236 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); 236 l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR);
237 other_group.id = kOtherGroupID; 237 other_group.id = kOtherGroupID;
238 groups.push_back(other_group); 238 groups.push_back(other_group);
239 239
240 return groups; 240 return groups;
241 } 241 }
242 242
243 int TemplateURLTableModel::GetGroupID(int row) { 243 int TemplateURLTableModel::GetGroupID(int row) {
244 DCHECK(row >= 0 && row < RowCount()); 244 DCHECK(row >= 0 && row < RowCount());
245 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; 245 return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID;
246 } 246 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { 376 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) {
377 std::vector<ModelEntry*>::iterator i = 377 std::vector<ModelEntry*>::iterator i =
378 find(entries_.begin(), entries_.end(), entry); 378 find(entries_.begin(), entries_.end(), entry);
379 DCHECK(i != entries_.end()); 379 DCHECK(i != entries_.end());
380 NotifyChanged(static_cast<int>(i - entries_.begin())); 380 NotifyChanged(static_cast<int>(i - entries_.begin()));
381 } 381 }
382 382
383 void TemplateURLTableModel::OnTemplateURLModelChanged() { 383 void TemplateURLTableModel::OnTemplateURLModelChanged() {
384 Reload(); 384 Reload();
385 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698