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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
13 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
14 #include "components/favicon/core/favicon_service.h" | 15 #include "components/favicon/core/favicon_service.h" |
15 #include "components/favicon_base/favicon_types.h" | 16 #include "components/favicon_base/favicon_types.h" |
16 #include "components/search_engines/template_url.h" | 17 #include "components/search_engines/template_url.h" |
17 #include "components/search_engines/template_url_service.h" | 18 #include "components/search_engines/template_url_service.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/models/table_model_observer.h" | 20 #include "ui/base/models/table_model_observer.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 const base::string16& short_name, | 260 const base::string16& short_name, |
260 const base::string16& keyword, | 261 const base::string16& keyword, |
261 const std::string& url) { | 262 const std::string& url) { |
262 DCHECK(index >= 0 && index <= RowCount()); | 263 DCHECK(index >= 0 && index <= RowCount()); |
263 DCHECK(!url.empty()); | 264 DCHECK(!url.empty()); |
264 template_url_service_->RemoveObserver(this); | 265 template_url_service_->RemoveObserver(this); |
265 TemplateURLData data; | 266 TemplateURLData data; |
266 data.SetShortName(short_name); | 267 data.SetShortName(short_name); |
267 data.SetKeyword(keyword); | 268 data.SetKeyword(keyword); |
268 data.SetURL(url); | 269 data.SetURL(url); |
269 TemplateURL* turl = new TemplateURL(data); | 270 TemplateURL* turl = |
270 template_url_service_->Add(turl); | 271 template_url_service_->Add(base::MakeUnique<TemplateURL>(data)); |
271 std::unique_ptr<ModelEntry> entry(new ModelEntry(this, turl)); | 272 std::unique_ptr<ModelEntry> entry(new ModelEntry(this, turl)); |
272 template_url_service_->AddObserver(this); | 273 template_url_service_->AddObserver(this); |
273 AddEntry(index, std::move(entry)); | 274 AddEntry(index, std::move(entry)); |
274 } | 275 } |
275 | 276 |
276 void TemplateURLTableModel::ModifyTemplateURL(int index, | 277 void TemplateURLTableModel::ModifyTemplateURL(int index, |
277 const base::string16& title, | 278 const base::string16& title, |
278 const base::string16& keyword, | 279 const base::string16& keyword, |
279 const std::string& url) { | 280 const std::string& url) { |
280 DCHECK(index >= 0 && index <= RowCount()); | 281 DCHECK(index >= 0 && index <= RowCount()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 388 } |
388 | 389 |
389 void TemplateURLTableModel::AddEntry(int index, | 390 void TemplateURLTableModel::AddEntry(int index, |
390 std::unique_ptr<ModelEntry> entry) { | 391 std::unique_ptr<ModelEntry> entry) { |
391 entries_.insert(entries_.begin() + index, entry.release()); | 392 entries_.insert(entries_.begin() + index, entry.release()); |
392 if (index <= last_other_engine_index_) | 393 if (index <= last_other_engine_index_) |
393 ++last_other_engine_index_; | 394 ++last_other_engine_index_; |
394 if (observer_) | 395 if (observer_) |
395 observer_->OnItemsAdded(index, 1); | 396 observer_->OnItemsAdded(index, 1); |
396 } | 397 } |
OLD | NEW |