| 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" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 void SearchEngineManagerHandler::OnItemsRemoved(int start, int length) { | 166 void SearchEngineManagerHandler::OnItemsRemoved(int start, int length) { |
| 167 OnModelChanged(); | 167 OnModelChanged(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( | 170 base::DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( |
| 171 int index, bool is_default, bool is_extension) { | 171 int index, bool is_default, bool is_extension) { |
| 172 TemplateURLTableModel* table_model = list_controller_->table_model(); | 172 TemplateURLTableModel* table_model = list_controller_->table_model(); |
| 173 const TemplateURL* template_url = list_controller_->GetTemplateURL(index); | 173 const TemplateURL* template_url = list_controller_->GetTemplateURL(index); |
| 174 | 174 |
| 175 // The items which are to be written into |dict| are also described in |
| 176 // chrome/browser/resources/options/search_engine_manager_engine_list.js |
| 177 // in @typedef for SearchEngine. Please update it whenever you add or remove |
| 178 // any keys here. |
| 175 base::DictionaryValue* dict = new base::DictionaryValue(); | 179 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 176 dict->SetString("name", template_url->short_name()); | 180 dict->SetString("name", template_url->short_name()); |
| 177 dict->SetString("displayName", table_model->GetText( | 181 dict->SetString("displayName", table_model->GetText( |
| 178 index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)); | 182 index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)); |
| 179 dict->SetString("keyword", table_model->GetText( | 183 dict->SetString("keyword", table_model->GetText( |
| 180 index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)); | 184 index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)); |
| 181 dict->SetString("url", template_url->url_ref().DisplayURL( | 185 dict->SetString("url", template_url->url_ref().DisplayURL( |
| 182 UIThreadSearchTermsData(Profile::FromWebUI(web_ui())))); | 186 UIThreadSearchTermsData(Profile::FromWebUI(web_ui())))); |
| 183 dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0); | 187 dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0); |
| 184 GURL icon_url = template_url->favicon_url(); | 188 GURL icon_url = template_url->favicon_url(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 319 |
| 316 // Recheck validity. It's possible to get here with invalid input if e.g. the | 320 // Recheck validity. It's possible to get here with invalid input if e.g. the |
| 317 // user calls the right JS functions directly from the web inspector. | 321 // user calls the right JS functions directly from the web inspector. |
| 318 if (edit_controller_->IsTitleValid(name) && | 322 if (edit_controller_->IsTitleValid(name) && |
| 319 edit_controller_->IsKeywordValid(keyword) && | 323 edit_controller_->IsKeywordValid(keyword) && |
| 320 edit_controller_->IsURLValid(url)) | 324 edit_controller_->IsURLValid(url)) |
| 321 edit_controller_->AcceptAddOrEdit(name, keyword, url); | 325 edit_controller_->AcceptAddOrEdit(name, keyword, url); |
| 322 } | 326 } |
| 323 | 327 |
| 324 } // namespace options | 328 } // namespace options |
| OLD | NEW |