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

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

Issue 10831061: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/importer/profile_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/importer_host.h" 5 #include "chrome/browser/importer/importer_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/importer/firefox_profile_lock.h" 12 #include "chrome/browser/importer/firefox_profile_lock.h"
12 #include "chrome/browser/importer/importer.h" 13 #include "chrome/browser/importer/importer.h"
13 #include "chrome/browser/importer/importer_lock_dialog.h" 14 #include "chrome/browser/importer/importer_lock_dialog.h"
14 #include "chrome/browser/importer/importer_progress_observer.h" 15 #include "chrome/browser/importer/importer_progress_observer.h"
15 #include "chrome/browser/importer/importer_type.h" 16 #include "chrome/browser/importer/importer_type.h"
16 #include "chrome/browser/importer/in_process_importer_bridge.h" 17 #include "chrome/browser/importer/in_process_importer_bridge.h"
17 #include "chrome/browser/importer/toolbar_importer_utils.h" 18 #include "chrome/browser/importer/toolbar_importer_utils.h"
18 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 importer_->Cancel(); 184 importer_->Cancel();
184 } 185 }
185 186
186 ImporterHost::~ImporterHost() { 187 ImporterHost::~ImporterHost() {
187 BrowserList::RemoveObserver(this); 188 BrowserList::RemoveObserver(this);
188 if (NULL != importer_) 189 if (NULL != importer_)
189 importer_->Release(); 190 importer_->Release();
190 191
191 if (installed_bookmark_observer_) { 192 if (installed_bookmark_observer_) {
192 DCHECK(profile_); 193 DCHECK(profile_);
193 profile_->GetBookmarkModel()->RemoveObserver(this); 194 BookmarkModelFactory::GetForProfile(profile_)->RemoveObserver(this);
194 } 195 }
195 } 196 }
196 197
197 void ImporterHost::CheckForFirefoxLock( 198 void ImporterHost::CheckForFirefoxLock(
198 const importer::SourceProfile& source_profile, 199 const importer::SourceProfile& source_profile,
199 uint16 items, 200 uint16 items,
200 bool first_run) { 201 bool first_run) {
201 if (source_profile.importer_type == importer::TYPE_FIREFOX2 || 202 if (source_profile.importer_type == importer::TYPE_FIREFOX2 ||
202 source_profile.importer_type == importer::TYPE_FIREFOX3) { 203 source_profile.importer_type == importer::TYPE_FIREFOX3) {
203 DCHECK(!firefox_lock_.get()); 204 DCHECK(!firefox_lock_.get());
204 firefox_lock_.reset(new FirefoxProfileLock(source_profile.source_path)); 205 firefox_lock_.reset(new FirefoxProfileLock(source_profile.source_path));
205 if (!firefox_lock_->HasAcquired()) { 206 if (!firefox_lock_->HasAcquired()) {
206 // If fail to acquire the lock, we set the source unreadable and 207 // If fail to acquire the lock, we set the source unreadable and
207 // show a warning dialog, unless running without UI. 208 // show a warning dialog, unless running without UI.
208 is_source_readable_ = false; 209 is_source_readable_ = false;
209 ShowWarningDialog(); 210 ShowWarningDialog();
210 } 211 }
211 } 212 }
212 } 213 }
213 214
214 void ImporterHost::CheckForLoadedModels(uint16 items) { 215 void ImporterHost::CheckForLoadedModels(uint16 items) {
215 // A target profile must be loaded by StartImportSettings(). 216 // A target profile must be loaded by StartImportSettings().
216 DCHECK(profile_); 217 DCHECK(profile_);
217 218
218 // BookmarkModel should be loaded before adding IE favorites. So we observe 219 // BookmarkModel should be loaded before adding IE favorites. So we observe
219 // the BookmarkModel if needed, and start the task after it has been loaded. 220 // the BookmarkModel if needed, and start the task after it has been loaded.
220 if ((items & importer::FAVORITES) && !writer_->BookmarkModelIsLoaded()) { 221 if ((items & importer::FAVORITES) && !writer_->BookmarkModelIsLoaded()) {
221 profile_->GetBookmarkModel()->AddObserver(this); 222 BookmarkModelFactory::GetForProfile(profile_)->AddObserver(this);
222 waiting_for_bookmarkbar_model_ = true; 223 waiting_for_bookmarkbar_model_ = true;
223 installed_bookmark_observer_ = true; 224 installed_bookmark_observer_ = true;
224 } 225 }
225 226
226 // Observes the TemplateURLService if needed to import search engines from the 227 // Observes the TemplateURLService if needed to import search engines from the
227 // other browser. We also check to see if we're importing bookmarks because 228 // other browser. We also check to see if we're importing bookmarks because
228 // we can import bookmark keywords from Firefox as search engines. 229 // we can import bookmark keywords from Firefox as search engines.
229 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) { 230 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) {
230 if (!writer_->TemplateURLServiceIsLoaded()) { 231 if (!writer_->TemplateURLServiceIsLoaded()) {
231 TemplateURLService* model = 232 TemplateURLService* model =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const content::NotificationDetails& details) { 266 const content::NotificationDetails& details) {
266 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); 267 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
267 registrar_.RemoveAll(); 268 registrar_.RemoveAll();
268 InvokeTaskIfDone(); 269 InvokeTaskIfDone();
269 } 270 }
270 271
271 void ImporterHost::OnBrowserRemoved(Browser* browser) { 272 void ImporterHost::OnBrowserRemoved(Browser* browser) {
272 if (browser_ == browser) 273 if (browser_ == browser)
273 browser_ = NULL; 274 browser_ = NULL;
274 } 275 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/importer/profile_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698