Chromium Code Reviews| Index: chrome/browser/ui/webui/options/search_engine_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc |
| index 0ba7a3bd4c6a65d992ab72ac0d4dc78b5a6e5ab1..c5e79c3c3e7bafc91bcc21f9367347a3006c8f5d 100644 |
| --- a/chrome/browser/ui/webui/options/search_engine_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/search_engine_manager_handler.cc |
| @@ -8,11 +8,13 @@ |
| #include "base/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/template_url.h" |
| #include "chrome/browser/search_engines/template_url_service.h" |
| #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| #include "chrome/browser/ui/search_engines/template_url_table_model.h" |
| +#include "chrome/common/extensions/extension.h" |
| #include "chrome/common/url_constants.h" |
| #include "grit/generated_resources.h" |
| #include "grit/locale_settings.h" |
| @@ -54,6 +56,11 @@ void SearchEngineManagerHandler::GetLocalizedValues( |
| l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); |
| localized_strings->SetString("otherSearchEngineListTitle", |
| l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); |
| + localized_strings->SetString("extensionKeywordsListTitle", |
| + l10n_util::GetStringUTF16( |
| + IDS_SEARCH_ENGINES_EDITOR_EXTENSIONS_SEPARATOR)); |
| + localized_strings->SetString("manageExtensionsLinkText", |
| + l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS)); |
| localized_strings->SetString("searchEngineTableNameHeader", |
| l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)); |
| localized_strings->SetString("searchEngineTableKeywordHeader", |
| @@ -125,8 +132,21 @@ void SearchEngineManagerHandler::OnModelChanged() { |
| others_list.Append(CreateDictionaryForEngine(i, i == default_index)); |
| } |
| + // Build the extension keywords list. |
| + ListValue keyword_list; |
| + ExtensionService* extension_service = |
| + web_ui_->GetProfile()->GetExtensionService(); |
| + if (extension_service != NULL) { |
|
Evan Stade
2011/07/11 20:12:01
just if (extension_service)
Greg Billock
2011/07/11 21:24:25
Done.
|
| + const ExtensionList* extensions = extension_service->extensions(); |
| + for (ExtensionList::const_iterator it = extensions->begin(); |
| + it != extensions->end(); ++it) { |
| + if ((*it)->omnibox_keyword().size() > 0) |
| + keyword_list.Append(CreateDictionaryForExtension(*(*it))); |
|
James Hawkins
2011/07/11 04:04:33
Do you need the extra parens around *it?
Greg Billock
2011/07/11 21:24:25
I could try without, but it's already pretty hard
|
| + } |
| + } |
| + |
| web_ui_->CallJavascriptFunction("SearchEngineManager.updateSearchEngineList", |
| - defaults_list, others_list); |
| + defaults_list, others_list, keyword_list); |
| } |
| void SearchEngineManagerHandler::OnItemsChanged(int start, int length) { |
| @@ -141,6 +161,18 @@ void SearchEngineManagerHandler::OnItemsRemoved(int start, int length) { |
| OnModelChanged(); |
| } |
| +DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForExtension( |
| + const Extension& extension) { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + dict->SetString("name", extension.name()); |
| + dict->SetString("displayName", extension.name()); |
| + dict->SetString("keyword", extension.omnibox_keyword()); |
| + GURL icon = extension.GetIconURL(16, ExtensionIconSet::MATCH_BIGGER); |
| + dict->SetString("iconURL", icon.spec()); |
| + dict->SetString("url", ""); |
|
James Hawkins
2011/07/11 04:04:33
s/""/string16()/
Greg Billock
2011/07/11 21:24:25
Done.
|
| + return dict; |
| +} |
| + |
| DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( |
| int index, bool is_default) { |
| TemplateURLTableModel* table_model = list_controller_->table_model(); |
| @@ -165,6 +197,7 @@ DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( |
| dict->SetString("canBeDefault", "1"); |
| if (is_default) |
| dict->SetString("default", "1"); |
| + dict->SetString("canBeEdited", "1"); |
| return dict; |
| } |