Chromium Code Reviews| Index: chrome/browser/ui/search_engines/template_url_table_model.cc |
| diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc |
| index 4e610da5e97e22e8c2e92f44e8fd80bb48cbac8a..32f26a50f2197f1bbf821f18518c562417ca36cb 100644 |
| --- a/chrome/browser/ui/search_engines/template_url_table_model.cc |
| +++ b/chrome/browser/ui/search_engines/template_url_table_model.cc |
| @@ -28,6 +28,7 @@ |
| // Group IDs used by TemplateURLTableModel. |
| static const int kMainGroupID = 0; |
| static const int kOtherGroupID = 1; |
| +static const int kExtensionGroupID = 2; |
| // ModelEntry ---------------------------------------------------- |
| @@ -155,7 +156,7 @@ void TemplateURLTableModel::Reload() { |
| last_search_engine_index_ = static_cast<int>(entries_.size()); |
| - // Then the rest. |
| + // Then the non extension keywords. |
| for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); |
| i != urls.end(); ++i) { |
| TemplateURL* template_url = *i; |
| @@ -167,6 +168,20 @@ void TemplateURLTableModel::Reload() { |
| } |
| } |
| + last_other_engine_index_ = static_cast<int>(entries_.size()); |
| + |
| + // Finally, the extensions. |
| + for (TemplateURLService::TemplateURLVector::iterator i = urls.begin(); |
| + i != urls.end(); ++i) { |
|
Devlin
2013/05/24 02:42:54
This code is now duplicated in three places... may
Aaron Jacobs
2013/05/24 03:06:14
The condition within the loop is different for eac
|
| + TemplateURL* template_url = *i; |
| + // NOTE: we don't use ShowInDefaultList here to avoid things bouncing |
| + // the lists while editing. |
| + if (!template_url->show_in_default_list() && |
| + template_url->IsExtensionKeyword()) { |
| + entries_.push_back(new ModelEntry(this, template_url)); |
| + } |
| + } |
| + |
| if (observer_) |
| observer_->OnModelChanged(); |
| } |
| @@ -222,12 +237,22 @@ TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { |
| other_group.id = kOtherGroupID; |
| groups.push_back(other_group); |
| + Group extension_group; |
| + extension_group.title = |
| + l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_EXTENSIONS_SEPARATOR); |
| + extension_group.id = kExtensionGroupID; |
| + groups.push_back(extension_group); |
| + |
| return groups; |
| } |
| int TemplateURLTableModel::GetGroupID(int row) { |
| DCHECK(row >= 0 && row < RowCount()); |
| - return row < last_search_engine_index_ ? kMainGroupID : kOtherGroupID; |
| + if (row < last_search_engine_index_) |
| + return kMainGroupID; |
| + if (row < last_other_engine_index_) |
| + return kOtherGroupID; |
| + return kExtensionGroupID; |
| } |
| void TemplateURLTableModel::Remove(int index) { |
| @@ -240,6 +265,8 @@ void TemplateURLTableModel::Remove(int index) { |
| entries_.erase(entries_.begin() + index); |
| if (index < last_search_engine_index_) |
| last_search_engine_index_--; |
| + if (index < last_other_engine_index_) |
| + last_other_engine_index_--; |
|
Devlin
2013/05/24 02:42:54
nit: prefer pre-decrement unless there's a good re
Aaron Jacobs
2013/05/24 03:06:14
Done.
|
| if (observer_) |
| observer_->OnItemsRemoved(index, 1); |