OLD | NEW |
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 Loading... |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { | 367 void TemplateURLTableModel::FaviconAvailable(ModelEntry* entry) { |
367 std::vector<ModelEntry*>::iterator i = | 368 std::vector<ModelEntry*>::iterator i = |
368 std::find(entries_.begin(), entries_.end(), entry); | 369 std::find(entries_.begin(), entries_.end(), entry); |
369 DCHECK(i != entries_.end()); | 370 DCHECK(i != entries_.end()); |
370 NotifyChanged(static_cast<int>(i - entries_.begin())); | 371 NotifyChanged(static_cast<int>(i - entries_.begin())); |
371 } | 372 } |
372 | 373 |
373 void TemplateURLTableModel::OnTemplateURLServiceChanged() { | 374 void TemplateURLTableModel::OnTemplateURLServiceChanged() { |
374 Reload(); | 375 Reload(); |
375 } | 376 } |
OLD | NEW |