| 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/search_engines/util.h" | 5 #include "chrome/browser/search_engines/util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 IDMap::iterator existing_url_iter(id_to_turl.find(prepopulated_id)); | 123 IDMap::iterator existing_url_iter(id_to_turl.find(prepopulated_id)); |
| 124 if (existing_url_iter != id_to_turl.end()) { | 124 if (existing_url_iter != id_to_turl.end()) { |
| 125 // Update the data store with the new prepopulated data. Preserve user | 125 // Update the data store with the new prepopulated data. Preserve user |
| 126 // edits to the name and keyword. | 126 // edits to the name and keyword. |
| 127 TemplateURLData data(prepopulated_url->data()); | 127 TemplateURLData data(prepopulated_url->data()); |
| 128 scoped_ptr<TemplateURL> existing_url(existing_url_iter->second); | 128 scoped_ptr<TemplateURL> existing_url(existing_url_iter->second); |
| 129 id_to_turl.erase(existing_url_iter); | 129 id_to_turl.erase(existing_url_iter); |
| 130 if (!existing_url->safe_for_autoreplace()) { | 130 if (!existing_url->safe_for_autoreplace()) { |
| 131 data.safe_for_autoreplace = false; | 131 data.safe_for_autoreplace = false; |
| 132 data.SetKeyword(existing_url->keyword()); | 132 data.SetKeyword(existing_url->keyword()); |
| 133 data.SetAutogenerateKeyword(existing_url->autogenerate_keyword()); | |
| 134 data.short_name = existing_url->short_name(); | 133 data.short_name = existing_url->short_name(); |
| 135 } | 134 } |
| 136 data.id = existing_url->id(); | 135 data.id = existing_url->id(); |
| 137 url_in_vector = new TemplateURL(profile, data); | |
| 138 if (service) | 136 if (service) |
| 139 service->UpdateKeyword(*url_in_vector); | 137 service->UpdateKeyword(data); |
| 140 | 138 |
| 141 // Replace the entry in |template_urls| with the updated one. | 139 // Replace the entry in |template_urls| with the updated one. |
| 142 std::vector<TemplateURL*>::iterator j = std::find(template_urls->begin(), | 140 std::vector<TemplateURL*>::iterator j = std::find(template_urls->begin(), |
| 143 template_urls->end(), existing_url.get()); | 141 template_urls->end(), existing_url.get()); |
| 144 *j = url_in_vector; | 142 *j = new TemplateURL(profile, data); |
| 143 url_in_vector = *j; |
| 145 if (*default_search_provider == existing_url.get()) | 144 if (*default_search_provider == existing_url.get()) |
| 146 *default_search_provider = url_in_vector; | 145 *default_search_provider = url_in_vector; |
| 147 } else { | 146 } else { |
| 148 template_urls->push_back(prepopulated_url.release()); | 147 template_urls->push_back(prepopulated_url.release()); |
| 149 url_in_vector = template_urls->back(); | 148 url_in_vector = template_urls->back(); |
| 150 } | 149 } |
| 151 DCHECK(url_in_vector); | 150 DCHECK(url_in_vector); |
| 152 if (i == default_search_index && !*default_search_provider) | 151 if (i == default_search_index && !*default_search_provider) |
| 153 *default_search_provider = url_in_vector; | 152 *default_search_provider = url_in_vector; |
| 154 } | 153 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (!keyword_result.did_default_search_provider_change) | 231 if (!keyword_result.did_default_search_provider_change) |
| 233 return false; | 232 return false; |
| 234 | 233 |
| 235 if (keyword_result.backup_valid) { | 234 if (keyword_result.backup_valid) { |
| 236 backup_default_search_provider->reset(new TemplateURL(profile, | 235 backup_default_search_provider->reset(new TemplateURL(profile, |
| 237 keyword_result.default_search_provider_backup)); | 236 keyword_result.default_search_provider_backup)); |
| 238 } | 237 } |
| 239 return true; | 238 return true; |
| 240 } | 239 } |
| 241 | 240 |
| OLD | NEW |