| 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/webui/options/search_engine_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/search_engine_manager_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search_engines/template_url.h" | 13 #include "chrome/browser/search_engines/template_url.h" |
| 14 #include "chrome/browser/search_engines/template_url_service.h" | 14 #include "chrome/browser/search_engines/template_url_service.h" |
| 15 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 15 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| 16 #include "chrome/browser/ui/search_engines/template_url_table_model.h" | 16 #include "chrome/browser/ui/search_engines/template_url_table_model.h" |
| 17 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 17 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 18 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
| 18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 20 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "grit/locale_settings.h" | 23 #include "grit/locale_settings.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 OnModelChanged(); | 167 OnModelChanged(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForExtension( | 170 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForExtension( |
| 170 const extensions::Extension& extension) { | 171 const extensions::Extension& extension) { |
| 171 base::DictionaryValue* dict = new base::DictionaryValue(); | 172 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 172 dict->SetString("name", extension.name()); | 173 dict->SetString("name", extension.name()); |
| 173 dict->SetString("displayName", extension.name()); | 174 dict->SetString("displayName", extension.name()); |
| 174 dict->SetString("keyword", | 175 dict->SetString("keyword", |
| 175 extensions::OmniboxInfo::GetKeyword(&extension)); | 176 extensions::OmniboxInfo::GetKeyword(&extension)); |
| 176 GURL icon = extension.GetIconURL(16, ExtensionIconSet::MATCH_BIGGER); | 177 GURL icon = extensions::IconsInfo::GetIconURL( |
| 178 &extension, 16, ExtensionIconSet::MATCH_BIGGER); |
| 177 dict->SetString("iconURL", icon.spec()); | 179 dict->SetString("iconURL", icon.spec()); |
| 178 dict->SetString("url", string16()); | 180 dict->SetString("url", string16()); |
| 179 return dict; | 181 return dict; |
| 180 } | 182 } |
| 181 | 183 |
| 182 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( | 184 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( |
| 183 int index, bool is_default) { | 185 int index, bool is_default) { |
| 184 TemplateURLTableModel* table_model = list_controller_->table_model(); | 186 TemplateURLTableModel* table_model = list_controller_->table_model(); |
| 185 const TemplateURL* template_url = list_controller_->GetTemplateURL(index); | 187 const TemplateURL* template_url = list_controller_->GetTemplateURL(index); |
| 186 | 188 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 312 } |
| 311 // Recheck validity. It's possible to get here with invalid input if e.g. the | 313 // Recheck validity. It's possible to get here with invalid input if e.g. the |
| 312 // user calls the right JS functions directly from the web inspector. | 314 // user calls the right JS functions directly from the web inspector. |
| 313 if (edit_controller_->IsTitleValid(name) && | 315 if (edit_controller_->IsTitleValid(name) && |
| 314 edit_controller_->IsKeywordValid(keyword) && | 316 edit_controller_->IsKeywordValid(keyword) && |
| 315 edit_controller_->IsURLValid(url)) | 317 edit_controller_->IsURLValid(url)) |
| 316 edit_controller_->AcceptAddOrEdit(name, keyword, url); | 318 edit_controller_->AcceptAddOrEdit(name, keyword, url); |
| 317 } | 319 } |
| 318 | 320 |
| 319 } // namespace options | 321 } // namespace options |
| OLD | NEW |