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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 13 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
14 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 14 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
15 #include "chrome/browser/ui/search_engines/template_url_table_model.h" | 15 #include "chrome/browser/ui/search_engines/template_url_table_model.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" |
17 #include "components/search_engines/template_url.h" | 18 #include "components/search_engines/template_url.h" |
18 #include "components/search_engines/template_url_service.h" | 19 #include "components/search_engines/template_url_service.h" |
19 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
20 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
22 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
23 #include "grit/generated_resources.h" | |
24 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 enum EngineInfoIndexes { | 29 enum EngineInfoIndexes { |
30 ENGINE_NAME, | 30 ENGINE_NAME, |
31 ENGINE_KEYWORD, | 31 ENGINE_KEYWORD, |
32 ENGINE_URL, | 32 ENGINE_URL, |
33 }; | 33 }; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 const std::string& url) { | 262 const std::string& url) { |
263 DCHECK(!url.empty()); | 263 DCHECK(!url.empty()); |
264 if (template_url) | 264 if (template_url) |
265 list_controller_->ModifyTemplateURL(template_url, title, keyword, url); | 265 list_controller_->ModifyTemplateURL(template_url, title, keyword, url); |
266 else | 266 else |
267 list_controller_->AddTemplateURL(title, keyword, url); | 267 list_controller_->AddTemplateURL(title, keyword, url); |
268 edit_controller_.reset(); | 268 edit_controller_.reset(); |
269 } | 269 } |
270 | 270 |
271 void SearchEngineManagerHandler::CheckSearchEngineInfoValidity( | 271 void SearchEngineManagerHandler::CheckSearchEngineInfoValidity( |
272 const base::ListValue* args) | 272 const base::ListValue* args) { |
273 { | |
274 if (!edit_controller_.get()) | 273 if (!edit_controller_.get()) |
275 return; | 274 return; |
276 base::string16 name; | 275 base::string16 name; |
277 base::string16 keyword; | 276 base::string16 keyword; |
278 std::string url; | 277 std::string url; |
279 std::string modelIndex; | 278 std::string modelIndex; |
280 if (!args->GetString(ENGINE_NAME, &name) || | 279 if (!args->GetString(ENGINE_NAME, &name) || |
281 !args->GetString(ENGINE_KEYWORD, &keyword) || | 280 !args->GetString(ENGINE_KEYWORD, &keyword) || |
282 !args->GetString(ENGINE_URL, &url) || | 281 !args->GetString(ENGINE_URL, &url) || |
283 !args->GetString(3, &modelIndex)) { | 282 !args->GetString(3, &modelIndex)) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 315 |
317 // Recheck validity. It's possible to get here with invalid input if e.g. the | 316 // Recheck validity. It's possible to get here with invalid input if e.g. the |
318 // user calls the right JS functions directly from the web inspector. | 317 // user calls the right JS functions directly from the web inspector. |
319 if (edit_controller_->IsTitleValid(name) && | 318 if (edit_controller_->IsTitleValid(name) && |
320 edit_controller_->IsKeywordValid(keyword) && | 319 edit_controller_->IsKeywordValid(keyword) && |
321 edit_controller_->IsURLValid(url)) | 320 edit_controller_->IsURLValid(url)) |
322 edit_controller_->AcceptAddOrEdit(name, keyword, url); | 321 edit_controller_->AcceptAddOrEdit(name, keyword, url); |
323 } | 322 } |
324 | 323 |
325 } // namespace options | 324 } // namespace options |
OLD | NEW |