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

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

Issue 2290503003: Remove use of stl_util in search_engines. (Closed)
Patch Set: ios for reals Created 4 years, 3 months 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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/favicon/favicon_service_factory.h" 21 #include "chrome/browser/favicon/favicon_service_factory.h"
21 #include "chrome/browser/history/history_service_factory.h" 22 #include "chrome/browser/history/history_service_factory.h"
22 #include "chrome/browser/password_manager/password_store_factory.h" 23 #include "chrome/browser/password_manager/password_store_factory.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 TemplateURLService* model = 312 TemplateURLService* model =
312 TemplateURLServiceFactory::GetForProfile(profile_); 313 TemplateURLServiceFactory::GetForProfile(profile_);
313 HostPathMap host_path_map; 314 HostPathMap host_path_map;
314 if (unique_on_host_and_path) 315 if (unique_on_host_and_path)
315 BuildHostPathMap(model, &host_path_map); 316 BuildHostPathMap(model, &host_path_map);
316 317
317 for (ScopedVector<TemplateURL>::iterator i = template_urls.begin(); 318 for (ScopedVector<TemplateURL>::iterator i = template_urls.begin();
318 i != template_urls.end(); ++i) { 319 i != template_urls.end(); ++i) {
319 // TemplateURLService requires keywords to be unique. If there is already a 320 // TemplateURLService requires keywords to be unique. If there is already a
320 // TemplateURL with this keyword, don't import it again. 321 // TemplateURL with this keyword, don't import it again.
321 if (model->GetTemplateURLForKeyword((*i)->keyword()) != NULL) 322 if (model->GetTemplateURLForKeyword((*i)->keyword()) != nullptr)
322 continue; 323 continue;
323 324
324 // For search engines if there is already a keyword with the same 325 // For search engines if there is already a keyword with the same
325 // host+path, we don't import it. This is done to avoid both duplicate 326 // host+path, we don't import it. This is done to avoid both duplicate
326 // search providers (such as two Googles, or two Yahoos) as well as making 327 // search providers (such as two Googles, or two Yahoos) as well as making
327 // sure the search engines we provide aren't replaced by those from the 328 // sure the search engines we provide aren't replaced by those from the
328 // imported browser. 329 // imported browser.
329 if (unique_on_host_and_path && 330 if (unique_on_host_and_path &&
330 (host_path_map.find(BuildHostPathKey( 331 (host_path_map.find(BuildHostPathKey(
331 *i, model->search_terms_data(), true)) != host_path_map.end())) 332 *i, model->search_terms_data(), true)) != host_path_map.end()))
332 continue; 333 continue;
333 334
334 // Only add valid TemplateURLs to the model. 335 // Only add valid TemplateURLs to the model.
335 if ((*i)->url_ref().IsValid(model->search_terms_data())) { 336 if ((*i)->url_ref().IsValid(model->search_terms_data())) {
336 model->Add(*i); // Takes ownership. 337 model->Add(base::WrapUnique(*i)); // Takes ownership.
Peter Kasting 2016/08/31 04:12:55 Nit: Comment is now redundant.
Avi (use Gerrit) 2016/09/01 00:34:25 Done.
337 *i = NULL; // Prevent the vector from deleting *i later. 338 *i = nullptr; // Prevent the vector from deleting *i later.
338 } 339 }
339 } 340 }
340 } 341 }
341 342
342 void ProfileWriter::AddAutofillFormDataEntries( 343 void ProfileWriter::AddAutofillFormDataEntries(
343 const std::vector<autofill::AutofillEntry>& autofill_entries) { 344 const std::vector<autofill::AutofillEntry>& autofill_entries) {
344 scoped_refptr<autofill::AutofillWebDataService> web_data_service = 345 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
345 WebDataServiceFactory::GetAutofillWebDataForProfile( 346 WebDataServiceFactory::GetAutofillWebDataForProfile(
346 profile_, ServiceAccessType::EXPLICIT_ACCESS); 347 profile_, ServiceAccessType::EXPLICIT_ACCESS);
347 if (web_data_service.get()) 348 if (web_data_service.get())
348 web_data_service->UpdateAutofillEntries(autofill_entries); 349 web_data_service->UpdateAutofillEntries(autofill_entries);
349 } 350 }
350 351
351 ProfileWriter::~ProfileWriter() {} 352 ProfileWriter::~ProfileWriter() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698