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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 void TemplateURLTableModel::Reload() { | 136 void TemplateURLTableModel::Reload() { |
137 entries_.clear(); | 137 entries_.clear(); |
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<std::unique_ptr<ModelEntry>> default_entries, other_entries, | 142 std::vector<std::unique_ptr<ModelEntry>> default_entries, other_entries, |
143 extension_entries; | 143 extension_entries; |
144 // Keywords that can be made the default first. | 144 // Keywords that can be made the default first. |
145 for (auto* template_url : urls) { | 145 for (auto* template_url : urls) { |
146 // NOTE: we don't use ShowInDefaultList here to avoid items bouncing around | 146 if (template_url_service_->ShowInDefaultList(template_url)) |
Peter Kasting
2016/11/10 06:41:06
Nit: While here: This code is out of compliance wi
ltian
2016/11/11 03:52:13
Done.
| |
147 // the lists while editing. | |
148 if (template_url->show_in_default_list()) | |
149 default_entries.push_back( | 147 default_entries.push_back( |
150 base::MakeUnique<ModelEntry>(this, template_url)); | 148 base::MakeUnique<ModelEntry>(this, template_url)); |
151 else if (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION) | 149 else if (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION) |
152 extension_entries.push_back( | 150 extension_entries.push_back( |
153 base::MakeUnique<ModelEntry>(this, template_url)); | 151 base::MakeUnique<ModelEntry>(this, template_url)); |
154 else | 152 else |
155 other_entries.push_back(base::MakeUnique<ModelEntry>(this, template_url)); | 153 other_entries.push_back(base::MakeUnique<ModelEntry>(this, template_url)); |
156 } | 154 } |
157 | 155 |
158 last_search_engine_index_ = static_cast<int>(default_entries.size()); | 156 last_search_engine_index_ = static_cast<int>(default_entries.size()); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 } | 384 } |
387 | 385 |
388 void TemplateURLTableModel::AddEntry(int index, | 386 void TemplateURLTableModel::AddEntry(int index, |
389 std::unique_ptr<ModelEntry> entry) { | 387 std::unique_ptr<ModelEntry> entry) { |
390 entries_.insert(entries_.begin() + index, std::move(entry)); | 388 entries_.insert(entries_.begin() + index, std::move(entry)); |
391 if (index <= last_other_engine_index_) | 389 if (index <= last_other_engine_index_) |
392 ++last_other_engine_index_; | 390 ++last_other_engine_index_; |
393 if (observer_) | 391 if (observer_) |
394 observer_->OnItemsAdded(index, 1); | 392 observer_->OnItemsAdded(index, 1); |
395 } | 393 } |
OLD | NEW |