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" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 template_url_service_(template_url_service), | 123 template_url_service_(template_url_service), |
124 favicon_service_(favicon_service) { | 124 favicon_service_(favicon_service) { |
125 DCHECK(template_url_service); | 125 DCHECK(template_url_service); |
126 template_url_service_->Load(); | 126 template_url_service_->Load(); |
127 template_url_service_->AddObserver(this); | 127 template_url_service_->AddObserver(this); |
128 Reload(); | 128 Reload(); |
129 } | 129 } |
130 | 130 |
131 TemplateURLTableModel::~TemplateURLTableModel() { | 131 TemplateURLTableModel::~TemplateURLTableModel() { |
132 template_url_service_->RemoveObserver(this); | 132 template_url_service_->RemoveObserver(this); |
133 STLDeleteElements(&entries_); | 133 base::STLDeleteElements(&entries_); |
134 } | 134 } |
135 | 135 |
136 void TemplateURLTableModel::Reload() { | 136 void TemplateURLTableModel::Reload() { |
137 STLDeleteElements(&entries_); | 137 base::STLDeleteElements(&entries_); |
138 | 138 |
139 TemplateURLService::TemplateURLVector urls = | 139 TemplateURLService::TemplateURLVector urls = |
140 template_url_service_->GetTemplateURLs(); | 140 template_url_service_->GetTemplateURLs(); |
141 | 141 |
142 std::vector<ModelEntry*> default_entries, other_entries, extension_entries; | 142 std::vector<ModelEntry*> default_entries, other_entries, extension_entries; |
143 // Keywords that can be made the default first. | 143 // Keywords that can be made the default first. |
144 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); | 144 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); |
145 i != urls.end(); ++i) { | 145 i != urls.end(); ++i) { |
146 TemplateURL* template_url = *i; | 146 TemplateURL* template_url = *i; |
147 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around | 147 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 387 } |
388 | 388 |
389 void TemplateURLTableModel::AddEntry(int index, | 389 void TemplateURLTableModel::AddEntry(int index, |
390 std::unique_ptr<ModelEntry> entry) { | 390 std::unique_ptr<ModelEntry> entry) { |
391 entries_.insert(entries_.begin() + index, entry.release()); | 391 entries_.insert(entries_.begin() + index, entry.release()); |
392 if (index <= last_other_engine_index_) | 392 if (index <= last_other_engine_index_) |
393 ++last_other_engine_index_; | 393 ++last_other_engine_index_; |
394 if (observer_) | 394 if (observer_) |
395 observer_->OnItemsAdded(index, 1); | 395 observer_->OnItemsAdded(index, 1); |
396 } | 396 } |
OLD | NEW |