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