Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: chrome/browser/importer/profile_writer.cc

Issue 2487633003: Change behaivor to decide whether a search engine should be shown in the default list (Closed)
Patch Set: Update based on Peter and Nicolas's comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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() {}
OLDNEW
« no previous file with comments | « chrome/browser/importer/in_process_importer_bridge.cc ('k') | chrome/browser/search_engines/template_url_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698