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

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

Issue 2216713002: Use BookmarkModelFactory::GetForBrowserContext everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks
Patch Set: Replace in .mm files Created 4 years, 4 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>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Shows the bookmarks toolbar. 77 // Shows the bookmarks toolbar.
78 void ShowBookmarkBar(Profile* profile) { 78 void ShowBookmarkBar(Profile* profile) {
79 profile->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true); 79 profile->GetPrefs()->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true);
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 ProfileWriter::ProfileWriter(Profile* profile) : profile_(profile) {} 84 ProfileWriter::ProfileWriter(Profile* profile) : profile_(profile) {}
85 85
86 bool ProfileWriter::BookmarkModelIsLoaded() const { 86 bool ProfileWriter::BookmarkModelIsLoaded() const {
87 return BookmarkModelFactory::GetForProfile(profile_)->loaded(); 87 return BookmarkModelFactory::GetForBrowserContext(profile_)->loaded();
88 } 88 }
89 89
90 bool ProfileWriter::TemplateURLServiceIsLoaded() const { 90 bool ProfileWriter::TemplateURLServiceIsLoaded() const {
91 return TemplateURLServiceFactory::GetForProfile(profile_)->loaded(); 91 return TemplateURLServiceFactory::GetForProfile(profile_)->loaded();
92 } 92 }
93 93
94 void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) { 94 void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) {
95 PasswordStoreFactory::GetForProfile( 95 PasswordStoreFactory::GetForProfile(
96 profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddLogin(form); 96 profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddLogin(form);
97 } 97 }
(...skipping 22 matching lines...) Expand all
120 prefs->SetString(prefs::kHomePage, home_page.spec()); 120 prefs->SetString(prefs::kHomePage, home_page.spec());
121 } 121 }
122 } 122 }
123 123
124 void ProfileWriter::AddBookmarks( 124 void ProfileWriter::AddBookmarks(
125 const std::vector<ImportedBookmarkEntry>& bookmarks, 125 const std::vector<ImportedBookmarkEntry>& bookmarks,
126 const base::string16& top_level_folder_name) { 126 const base::string16& top_level_folder_name) {
127 if (bookmarks.empty()) 127 if (bookmarks.empty())
128 return; 128 return;
129 129
130 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); 130 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_);
131 DCHECK(model->loaded()); 131 DCHECK(model->loaded());
132 132
133 // If the bookmark bar is currently empty, we should import directly to it. 133 // If the bookmark bar is currently empty, we should import directly to it.
134 // Otherwise, we should import everything to a subfolder. 134 // Otherwise, we should import everything to a subfolder.
135 const BookmarkNode* bookmark_bar = model->bookmark_bar_node(); 135 const BookmarkNode* bookmark_bar = model->bookmark_bar_node();
136 bool import_to_top_level = bookmark_bar->empty(); 136 bool import_to_top_level = bookmark_bar->empty();
137 137
138 // Reorder bookmarks so that the toolbar entries come first. 138 // Reorder bookmarks so that the toolbar entries come first.
139 std::vector<ImportedBookmarkEntry> toolbar_bookmarks; 139 std::vector<ImportedBookmarkEntry> toolbar_bookmarks;
140 std::vector<ImportedBookmarkEntry> reordered_bookmarks; 140 std::vector<ImportedBookmarkEntry> reordered_bookmarks;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void ProfileWriter::AddAutofillFormDataEntries( 342 void ProfileWriter::AddAutofillFormDataEntries(
343 const std::vector<autofill::AutofillEntry>& autofill_entries) { 343 const std::vector<autofill::AutofillEntry>& autofill_entries) {
344 scoped_refptr<autofill::AutofillWebDataService> web_data_service = 344 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
345 WebDataServiceFactory::GetAutofillWebDataForProfile( 345 WebDataServiceFactory::GetAutofillWebDataForProfile(
346 profile_, ServiceAccessType::EXPLICIT_ACCESS); 346 profile_, ServiceAccessType::EXPLICIT_ACCESS);
347 if (web_data_service.get()) 347 if (web_data_service.get())
348 web_data_service->UpdateAutofillEntries(autofill_entries); 348 web_data_service->UpdateAutofillEntries(autofill_entries);
349 } 349 }
350 350
351 ProfileWriter::~ProfileWriter() {} 351 ProfileWriter::~ProfileWriter() {}
OLDNEW
« no previous file with comments | « chrome/browser/importer/external_process_importer_host.cc ('k') | chrome/browser/importer/profile_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698