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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 std::vector<ModelEntry*> default_entries, other_entries, extension_entries; | 143 std::vector<ModelEntry*> default_entries, other_entries, extension_entries; |
144 // Keywords that can be made the default first. | 144 // Keywords that can be made the default first. |
145 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); | 145 for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); |
146 i != urls.end(); ++i) { | 146 i != urls.end(); ++i) { |
147 TemplateURL* template_url = *i; | 147 TemplateURL* template_url = *i; |
148 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around | 148 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around |
149 // the lists while editing. | 149 // the lists while editing. |
150 if (template_url->show_in_default_list()) | 150 if (template_url->show_in_default_list()) |
151 default_entries.push_back(new ModelEntry(this, template_url)); | 151 default_entries.push_back(new ModelEntry(this, template_url)); |
152 else if (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION) | 152 else if (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION) |
153 extension_entries.push_back(new ModelEntry(this, template_url)); | 153 extension_entries.push_back(new ModelEntry(this, template_url)); |
154 else | 154 else |
155 other_entries.push_back(new ModelEntry(this, template_url)); | 155 other_entries.push_back(new ModelEntry(this, template_url)); |
156 } | 156 } |
157 | 157 |
158 last_search_engine_index_ = static_cast<int>(default_entries.size()); | 158 last_search_engine_index_ = static_cast<int>(default_entries.size()); |
159 last_other_engine_index_ = last_search_engine_index_ + | 159 last_other_engine_index_ = last_search_engine_index_ + |
160 static_cast<int>(other_entries.size()); | 160 static_cast<int>(other_entries.size()); |
161 | 161 |
162 entries_.insert(entries_.end(), | 162 entries_.insert(entries_.end(), |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 388 } |
389 | 389 |
390 void TemplateURLTableModel::AddEntry(int index, | 390 void TemplateURLTableModel::AddEntry(int index, |
391 std::unique_ptr<ModelEntry> entry) { | 391 std::unique_ptr<ModelEntry> entry) { |
392 entries_.insert(entries_.begin() + index, entry.release()); | 392 entries_.insert(entries_.begin() + index, entry.release()); |
393 if (index <= last_other_engine_index_) | 393 if (index <= last_other_engine_index_) |
394 ++last_other_engine_index_; | 394 ++last_other_engine_index_; |
395 if (observer_) | 395 if (observer_) |
396 observer_->OnItemsAdded(index, 1); | 396 observer_->OnItemsAdded(index, 1); |
397 } | 397 } |
OLD | NEW |