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

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

Issue 10021008: Reland r131019: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/search_engines/template_url_table_model.h" 5 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 template_url_service_->Remove(template_url); 247 template_url_service_->Remove(template_url);
248 template_url_service_->AddObserver(this); 248 template_url_service_->AddObserver(this);
249 } 249 }
250 250
251 void TemplateURLTableModel::Add(int index, 251 void TemplateURLTableModel::Add(int index,
252 const string16& short_name, 252 const string16& short_name,
253 const string16& keyword, 253 const string16& keyword,
254 const std::string& url) { 254 const std::string& url) {
255 DCHECK(index >= 0 && index <= RowCount()); 255 DCHECK(index >= 0 && index <= RowCount());
256 template_url_service_->RemoveObserver(this); 256 template_url_service_->RemoveObserver(this);
257 TemplateURL* turl = new TemplateURL(); 257 TemplateURLData data;
258 turl->set_short_name(short_name); 258 data.short_name = short_name;
259 turl->set_keyword(keyword); 259 data.SetKeyword(keyword);
260 turl->SetURL(url); 260 data.SetURL(url);
261 TemplateURL* turl = new TemplateURL(data);
261 template_url_service_->Add(turl); 262 template_url_service_->Add(turl);
262 ModelEntry* entry = new ModelEntry(this, turl); 263 ModelEntry* entry = new ModelEntry(this, turl);
263 template_url_service_->AddObserver(this); 264 template_url_service_->AddObserver(this);
264 entries_.insert(entries_.begin() + index, entry); 265 entries_.insert(entries_.begin() + index, entry);
265 if (observer_) 266 if (observer_)
266 observer_->OnItemsAdded(index, 1); 267 observer_->OnItemsAdded(index, 1);
267 } 268 }
268 269
269 void TemplateURLTableModel::ModifyTemplateURL(int index, 270 void TemplateURLTableModel::ModifyTemplateURL(int index,
270 const string16& title, 271 const string16& title,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { 363 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) {
363 std::vector<ModelEntry*>::iterator i = 364 std::vector<ModelEntry*>::iterator i =
364 std::find(entries_.begin(), entries_.end(), entry); 365 std::find(entries_.begin(), entries_.end(), entry);
365 DCHECK(i != entries_.end()); 366 DCHECK(i != entries_.end());
366 NotifyChanged(static_cast<int>(i - entries_.begin())); 367 NotifyChanged(static_cast<int>(i - entries_.begin()));
367 } 368 }
368 369
369 void TemplateURLTableModel::OnTemplateURLServiceChanged() { 370 void TemplateURLTableModel::OnTemplateURLServiceChanged() {
370 Reload(); 371 Reload();
371 } 372 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search_engines/search_engine_tab_helper.cc ('k') | chrome/browser/webdata/keyword_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698