From f6061aeddb0c01a9c80aabf769b04c96a31f066f Mon Sep 17 00:00:00 2001 From: "jeremy@chromium.org" Date: Tue, 6 Oct 2009 16:28:57 +0000 Subject: (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 --- chrome/browser/importer/importer_bridge.cc | 89 ++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 chrome/browser/importer/importer_bridge.cc (limited to 'chrome/browser/importer/importer_bridge.cc') 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& 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& fav_icons) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddFavicons, fav_icons)); +} + +void InProcessImporterBridge::SetHistoryItems( + const std::vector &rows) { + main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, + &ProfileWriter::AddHistoryPage, rows)); +} + +void InProcessImporterBridge::SetKeywords( + const std::vector& 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)); +} -- cgit v1.1