diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 16:28:57 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-06 16:28:57 +0000 |
commit | f6061aeddb0c01a9c80aabf769b04c96a31f066f (patch) | |
tree | 85760537cc584c6ead179fa788047c10da618a0a /chrome/browser/importer/importer_bridge.cc | |
parent | 5b137dcbe79a56673fbed5f23d3a2480270fce13 (diff) | |
download | chromium_src-f6061aeddb0c01a9c80aabf769b04c96a31f066f.zip chromium_src-f6061aeddb0c01a9c80aabf769b04c96a31f066f.tar.gz chromium_src-f6061aeddb0c01a9c80aabf769b04c96a31f066f.tar.bz2 |
(please review thoroughly since this touches many moving parts).
Refactor ImporterHost as preparation for OOPprofile import.
ImporterHost currently requires substantial infrastructure in order to run which we don't need or can't have in a utility process.
This change splits ImporterHost into a couple of subclasses so that the profile import process can remain light weight and doesn't need to initialize Profile, etc.
ImporterList: Manages the list of importers, this class will allow the utility process to locate and instantiate an importer without initializing the world.
ImprterBridge/InProcessImporterBridge: Provides an abstract interface for the importers to interact with the rest of the App. The idea is to stick the IPC boundary in using this interface.
There may still be some rough spots in the separation (e.g. Firefox locking and surrounding UI) but I'll sort those out in a followup CL that makes the OOP stuff work. For now I'm trying to keep these CLs as small as I can.
BUG=14458
TEST=Profile import should continue to work on Windows/Linux & Mac.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=27996
Review URL: http://codereview.chromium.org/242091
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer/importer_bridge.cc')
-rw-r--r-- | chrome/browser/importer/importer_bridge.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/chrome/browser/importer/importer_bridge.cc b/chrome/browser/importer/importer_bridge.cc new file mode 100644 index 0000000..dfe98fd --- /dev/null +++ b/chrome/browser/importer/importer_bridge.cc @@ -0,0 +1,89 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/importer/importer_bridge.h" + +#include "base/message_loop.h" +#include "chrome/browser/importer/importer.h" +#if defined(OS_WIN) +#include "chrome/browser/password_manager/ie7_password.h" +#endif +#include "webkit/glue/password_form.h" + +InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer, + MessageLoop* delegate_loop, + ImporterHost* host) + : ImporterBridge(writer, delegate_loop, host), + main_loop_(MessageLoop::current()), + delegate_loop_(NULL) { +} + +void InProcessImporterBridge::AddBookmarkEntries( + const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, + const std::wstring& first_folder_name, + int options) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddBookmarkEntry, bookmarks, first_folder_name, + options)); +} + +void InProcessImporterBridge::AddHomePage(const GURL &home_page) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddHomepage, home_page)); +} + +#if defined(OS_WIN) +void InProcessImporterBridge::AddIE7PasswordInfo( + const IE7PasswordInfo password_info) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddIE7PasswordInfo, password_info)); +} +#endif // OS_WIN + +void InProcessImporterBridge::SetFavIcons( + const std::vector<history::ImportedFavIconUsage>& fav_icons) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddFavicons, fav_icons)); +} + +void InProcessImporterBridge::SetHistoryItems( + const std::vector<history::URLRow> &rows) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddHistoryPage, rows)); +} + +void InProcessImporterBridge::SetKeywords( + const std::vector<TemplateURL*>& template_urls, + int default_keyword_index, + bool unique_on_host_and_path) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddKeywords, template_urls, default_keyword_index, + unique_on_host_and_path)); +} + +void InProcessImporterBridge::SetPasswordForm( + const webkit_glue::PasswordForm& form) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddPasswordForm, form)); +} + +void InProcessImporterBridge::NotifyItemStarted(ImportItem item) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, + &ImporterHost::ImportItemStarted, item)); +} + +void InProcessImporterBridge::NotifyItemEnded(ImportItem item) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, + &ImporterHost::ImportItemEnded, item)); +} + +void InProcessImporterBridge::NotifyStarted() { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, + &ImporterHost::ImportStarted)); +} + +void InProcessImporterBridge::NotifyEnded() { + main_loop_->PostTask(FROM_HERE, + NewRunnableMethod(host_, &ImporterHost::ImportEnded)); +} |