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

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

Issue 6291003: Revert 71485 - Remove wstring from TemplateURL and friends.... (Closed) Base URL: svn://svn.chromium.org/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) 2011 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int TemplateURLTableModel::RowCount() { 173 int TemplateURLTableModel::RowCount() {
174 return static_cast<int>(entries_.size()); 174 return static_cast<int>(entries_.size());
175 } 175 }
176 176
177 string16 TemplateURLTableModel::GetText(int row, int col_id) { 177 string16 TemplateURLTableModel::GetText(int row, int col_id) {
178 DCHECK(row >= 0 && row < RowCount()); 178 DCHECK(row >= 0 && row < RowCount());
179 const TemplateURL& url = entries_[row]->template_url(); 179 const TemplateURL& url = entries_[row]->template_url();
180 180
181 switch (col_id) { 181 switch (col_id) {
182 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: { 182 case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: {
183 string16 url_short_name = url.short_name(); 183 string16 url_short_name = WideToUTF16Hack(url.short_name());
184 // TODO(xji): Consider adding a special case if the short name is a URL, 184 // TODO(xji): Consider adding a special case if the short name is a URL,
185 // since those should always be displayed LTR. Please refer to 185 // since those should always be displayed LTR. Please refer to
186 // http://crbug.com/6726 for more information. 186 // http://crbug.com/6726 for more information.
187 base::i18n::AdjustStringForLocaleDirection(&url_short_name); 187 base::i18n::AdjustStringForLocaleDirection(&url_short_name);
188 if (template_url_model_->GetDefaultSearchProvider() == &url) { 188 if (template_url_model_->GetDefaultSearchProvider() == &url) {
189 return l10n_util::GetStringFUTF16( 189 return l10n_util::GetStringFUTF16(
190 IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, 190 IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE,
191 url_short_name); 191 url_short_name);
192 } 192 }
193 return url_short_name; 193 return url_short_name;
194 } 194 }
195 195
196 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: { 196 case IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN: {
197 // Keyword should be domain name. Force it to have LTR directionality. 197 // Keyword should be domain name. Force it to have LTR directionality.
198 string16 keyword = url.keyword(); 198 string16 keyword = WideToUTF16(url.keyword());
199 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); 199 keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword);
200 return keyword; 200 return keyword;
201 } 201 }
202 202
203 default: 203 default:
204 NOTREACHED(); 204 NOTREACHED();
205 return string16(); 205 return string16();
206 } 206 }
207 } 207 }
208 208
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 template_url_model_->AddObserver(this); 272 template_url_model_->AddObserver(this);
273 } 273 }
274 274
275 void TemplateURLTableModel::ModifyTemplateURL(int index, 275 void TemplateURLTableModel::ModifyTemplateURL(int index,
276 const string16& title, 276 const string16& title,
277 const string16& keyword, 277 const string16& keyword,
278 const std::string& url) { 278 const std::string& url) {
279 DCHECK(index >= 0 && index <= RowCount()); 279 DCHECK(index >= 0 && index <= RowCount());
280 const TemplateURL* template_url = &GetTemplateURL(index); 280 const TemplateURL* template_url = &GetTemplateURL(index);
281 template_url_model_->RemoveObserver(this); 281 template_url_model_->RemoveObserver(this);
282 template_url_model_->ResetTemplateURL(template_url, title, keyword, url); 282 template_url_model_->ResetTemplateURL(template_url, UTF16ToWideHack(title),
283 UTF16ToWideHack(keyword), url);
283 if (template_url_model_->GetDefaultSearchProvider() == template_url && 284 if (template_url_model_->GetDefaultSearchProvider() == template_url &&
284 !TemplateURL::SupportsReplacement(template_url)) { 285 !TemplateURL::SupportsReplacement(template_url)) {
285 // The entry was the default search provider, but the url has been modified 286 // The entry was the default search provider, but the url has been modified
286 // so that it no longer supports replacement. Reset the default search 287 // so that it no longer supports replacement. Reset the default search
287 // provider so that it doesn't point to a bogus entry. 288 // provider so that it doesn't point to a bogus entry.
288 template_url_model_->SetDefaultSearchProvider(NULL); 289 template_url_model_->SetDefaultSearchProvider(NULL);
289 } 290 }
290 template_url_model_->AddObserver(this); 291 template_url_model_->AddObserver(this);
291 ReloadIcon(index); // Also calls NotifyChanged(). 292 ReloadIcon(index); // Also calls NotifyChanged().
292 } 293 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) { 373 void TemplateURLTableModel::FavIconAvailable(ModelEntry* entry) {
373 std::vector<ModelEntry*>::iterator i = 374 std::vector<ModelEntry*>::iterator i =
374 find(entries_.begin(), entries_.end(), entry); 375 find(entries_.begin(), entries_.end(), entry);
375 DCHECK(i != entries_.end()); 376 DCHECK(i != entries_.end());
376 NotifyChanged(static_cast<int>(i - entries_.begin())); 377 NotifyChanged(static_cast<int>(i - entries_.begin()));
377 } 378 }
378 379
379 void TemplateURLTableModel::OnTemplateURLModelChanged() { 380 void TemplateURLTableModel::OnTemplateURLModelChanged() {
380 Reload(); 381 Reload();
381 } 382 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698