| 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/importer/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // the TemplateURLService that has a valid search url. | 294 // the TemplateURLService that has a valid search url. |
| 295 static void BuildHostPathMap(TemplateURLService* model, | 295 static void BuildHostPathMap(TemplateURLService* model, |
| 296 HostPathMap* host_path_map) { | 296 HostPathMap* host_path_map) { |
| 297 TemplateURLService::TemplateURLVector template_urls = | 297 TemplateURLService::TemplateURLVector template_urls = |
| 298 model->GetTemplateURLs(); | 298 model->GetTemplateURLs(); |
| 299 for (size_t i = 0; i < template_urls.size(); ++i) { | 299 for (size_t i = 0; i < template_urls.size(); ++i) { |
| 300 const std::string host_path = BuildHostPathKey( | 300 const std::string host_path = BuildHostPathKey( |
| 301 template_urls[i], model->search_terms_data(), false); | 301 template_urls[i], model->search_terms_data(), false); |
| 302 if (!host_path.empty()) { | 302 if (!host_path.empty()) { |
| 303 const TemplateURL* existing_turl = (*host_path_map)[host_path]; | 303 const TemplateURL* existing_turl = (*host_path_map)[host_path]; |
| 304 if (!existing_turl || | 304 TemplateURL* t_url = template_urls[i]; |
| 305 (template_urls[i]->show_in_default_list() && | 305 if (!existing_turl || (model->ShowInDefaultList(t_url) && |
| 306 !existing_turl->show_in_default_list())) { | 306 !model->ShowInDefaultList(existing_turl))) { |
| 307 // If there are multiple TemplateURLs with the same host+path, favor | 307 // If there are multiple TemplateURLs with the same host+path, favor |
| 308 // those shown in the default list. If there are multiple potential | 308 // those shown in the default list. If there are multiple potential |
| 309 // defaults, favor the first one, which should be the more commonly used | 309 // defaults, favor the first one, which should be the more commonly used |
| 310 // one. | 310 // one. |
| 311 (*host_path_map)[host_path] = template_urls[i]; | 311 (*host_path_map)[host_path] = t_url; |
| 312 } | 312 } |
| 313 } // else case, TemplateURL doesn't have a search url, doesn't support | 313 } // else case, TemplateURL doesn't have a search url, doesn't support |
| 314 // replacement, or doesn't have valid GURL. Ignore it. | 314 // replacement, or doesn't have valid GURL. Ignore it. |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 void ProfileWriter::AddKeywords( | 318 void ProfileWriter::AddKeywords( |
| 319 TemplateURLService::OwnedTemplateURLVector template_urls, | 319 TemplateURLService::OwnedTemplateURLVector template_urls, |
| 320 bool unique_on_host_and_path) { | 320 bool unique_on_host_and_path) { |
| 321 TemplateURLService* model = | 321 TemplateURLService* model = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 349 void ProfileWriter::AddAutofillFormDataEntries( | 349 void ProfileWriter::AddAutofillFormDataEntries( |
| 350 const std::vector<autofill::AutofillEntry>& autofill_entries) { | 350 const std::vector<autofill::AutofillEntry>& autofill_entries) { |
| 351 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 351 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 352 WebDataServiceFactory::GetAutofillWebDataForProfile( | 352 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 353 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 353 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 354 if (web_data_service.get()) | 354 if (web_data_service.get()) |
| 355 web_data_service->UpdateAutofillEntries(autofill_entries); | 355 web_data_service->UpdateAutofillEntries(autofill_entries); |
| 356 } | 356 } |
| 357 | 357 |
| 358 ProfileWriter::~ProfileWriter() {} | 358 ProfileWriter::~ProfileWriter() {} |
| OLD | NEW |