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..8bbc2b08f738e1308f8a57efceaaa4b982a741fc 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) { |
+ 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_) |
Peter Kasting
2013/05/30 21:22:50
Nit: You could use ?: on this last pair
Aaron Jacobs
2013/05/31 03:07:24
Done.
|
+ return kOtherGroupID; |
+ return kExtensionGroupID; |
} |
void TemplateURLTableModel::Remove(int index) { |
@@ -239,7 +264,9 @@ void TemplateURLTableModel::Remove(int index) { |
scoped_ptr<ModelEntry> entry(entries_[index]); |
entries_.erase(entries_.begin() + index); |
if (index < last_search_engine_index_) |
- last_search_engine_index_--; |
+ --last_search_engine_index_; |
+ if (index < last_other_engine_index_) |
+ --last_other_engine_index_; |
if (observer_) |
observer_->OnItemsRemoved(index, 1); |