Chromium Code Reviews| Index: chrome/browser/search_engines/template_url_prepopulate_data.cc |
| diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc |
| index ea133f85ea4a746cf4e094fa5b060343888a1876..565d71977f93108e2ab92cc0edb1ff61b752c558 100644 |
| --- a/chrome/browser/search_engines/template_url_prepopulate_data.cc |
| +++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc |
| @@ -3563,37 +3563,33 @@ void GetPrepopulatedTemplateFromPrefs(Profile* profile, |
| string16 name; |
|
Peter Kasting
2012/10/16 17:48:32
Nit: I suggest moving all these declarations insid
Joao da Silva
2012/10/16 18:53:36
Done.
|
| string16 keyword; |
| std::string search_url; |
| - std::string suggest_url; |
| - std::string instant_url; |
| - const ListValue* alternate_urls = NULL; |
| - std::string favicon_url; |
| + std::string favicon; |
|
Peter Kasting
2012/10/16 17:48:32
Nit: Leave this named "favicon_url"
Joao da Silva
2012/10/16 18:53:36
But but but then the line is 81 chars! (Done!)
|
| std::string encoding; |
| int id; |
| + const ListValue kEmptyList; |
|
Peter Kasting
2012/10/16 17:48:32
Nit: This one I'd declare just above |alternate_ur
Joao da Silva
2012/10/16 18:53:36
Done.
|
| size_t num_engines = list->GetSize(); |
| for (size_t i = 0; i != num_engines; ++i) { |
| const DictionaryValue* engine; |
| + // The following fields are required for each search engine configuration. |
| if (list->GetDictionary(i, &engine) && |
| - engine->GetString("name", &name) && |
| - engine->GetString("keyword", &keyword) && |
| - engine->GetString("search_url", &search_url) && |
| - engine->GetString("suggest_url", &suggest_url) && |
| - engine->GetString("instant_url", &instant_url) && |
| - engine->GetList("alternate_urls", &alternate_urls) && |
| - engine->GetString("favicon_url", &favicon_url) && |
| - engine->GetString("encoding", &encoding) && |
| + engine->GetString("name", &name) && !name.empty() && |
| + engine->GetString("keyword", &keyword) && !keyword.empty() && |
| + engine->GetString("search_url", &search_url) && !search_url.empty() && |
| + engine->GetString("favicon_url", &favicon) && !favicon.empty() && |
| + engine->GetString("encoding", &encoding) && !encoding.empty() && |
| engine->GetInteger("id", &id)) { |
| - // These next fields are not allowed to be empty. |
| - if (name.empty() || keyword.empty() || search_url.empty() || |
| - favicon_url.empty() || encoding.empty()) |
| - return; |
| - } else { |
| - // Got a parsing error. No big deal. |
| - continue; |
| + // These fields are optional. |
| + std::string suggest_url; |
| + std::string instant_url; |
| + const ListValue* alternate_urls = &kEmptyList; |
| + engine->GetString("suggest_url", &suggest_url); |
| + engine->GetString("instant_url", &instant_url); |
| + engine->GetList("alternate_urls", &alternate_urls); |
| + t_urls->push_back(MakePrepopulatedTemplateURL(profile, name, keyword, |
| + search_url, suggest_url, instant_url, *alternate_urls, favicon, |
| + encoding, id)); |
| } |
| - t_urls->push_back(MakePrepopulatedTemplateURL(profile, name, keyword, |
| - search_url, suggest_url, instant_url, *alternate_urls, favicon_url, |
| - encoding, id)); |
| } |
| } |