| Index: chrome/utility/chrome_content_utility_client.cc
|
| diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
|
| index f1a072485c1fc38e3990092aa699af2ed2af641b..51fa4d562c07372a480835b982a76aae2a7bf3b6 100644
|
| --- a/chrome/utility/chrome_content_utility_client.cc
|
| +++ b/chrome/utility/chrome_content_utility_client.cc
|
| @@ -4,10 +4,11 @@
|
|
|
| #include "chrome/utility/chrome_content_utility_client.h"
|
|
|
| -#include "base/bind.h"
|
| #include "base/base64.h"
|
| +#include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/json/json_reader.h"
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/message_loop_proxy.h"
|
| #include "base/threading/thread.h"
|
| #include "chrome/browser/importer/external_process_importer_bridge.h"
|
| @@ -21,6 +22,7 @@
|
| #include "chrome/common/extensions/unpacker.h"
|
| #include "chrome/common/extensions/update_manifest.h"
|
| #include "chrome/common/web_resource/web_resource_unpacker.h"
|
| +#include "chrome/utility/profile_import_handler.h"
|
| #include "content/public/utility/utility_thread.h"
|
| #include "printing/backend/print_backend.h"
|
| #include "printing/page_range.h"
|
| @@ -31,7 +33,6 @@
|
|
|
| #if defined(OS_WIN)
|
| #include "base/file_util.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| #include "base/path_service.h"
|
| #include "base/win/iat_patch_function.h"
|
| #include "base/win/scoped_handle.h"
|
| @@ -42,7 +43,10 @@
|
|
|
| namespace chrome {
|
|
|
| -ChromeContentUtilityClient::ChromeContentUtilityClient() : items_to_import_(0) {
|
| +ChromeContentUtilityClient::ChromeContentUtilityClient() {
|
| +#if !defined(OS_ANDROID)
|
| + import_handler_.reset(new ProfileImportHandler());
|
| +#endif
|
| }
|
|
|
| ChromeContentUtilityClient::~ChromeContentUtilityClient() {
|
| @@ -82,14 +86,14 @@ bool ChromeContentUtilityClient::OnMessageReceived(
|
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
|
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
|
| OnGetPrinterCapsAndDefaults)
|
| - IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_StartImport,
|
| - OnImportStart)
|
| - IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_CancelImport,
|
| - OnImportCancel)
|
| - IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_ReportImportItemFinished,
|
| - OnImportItemFinished)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| +
|
| +#if !defined(OS_ANDROID)
|
| + if (!handled)
|
| + handled = import_handler_->OnMessageReceived(message);
|
| +#endif
|
| +
|
| return handled;
|
| }
|
|
|
| @@ -391,54 +395,4 @@ void ChromeContentUtilityClient::OnGetPrinterCapsAndDefaults(
|
| content::UtilityThread::Get()->ReleaseProcessIfNeeded();
|
| }
|
|
|
| -void ChromeContentUtilityClient::OnImportStart(
|
| - const importer::SourceProfile& source_profile,
|
| - uint16 items,
|
| - const DictionaryValue& localized_strings) {
|
| - bridge_ = new ExternalProcessImporterBridge(
|
| - localized_strings, content::UtilityThread::Get(),
|
| - base::MessageLoopProxy::current());
|
| - importer_ = importer::CreateImporterByType(source_profile.importer_type);
|
| - if (!importer_) {
|
| - Send(new ProfileImportProcessHostMsg_Import_Finished(false,
|
| - "Importer could not be created."));
|
| - return;
|
| - }
|
| -
|
| - items_to_import_ = items;
|
| -
|
| - // Create worker thread in which importer runs.
|
| - import_thread_.reset(new base::Thread("import_thread"));
|
| - base::Thread::Options options;
|
| - options.message_loop_type = MessageLoop::TYPE_IO;
|
| - if (!import_thread_->StartWithOptions(options)) {
|
| - NOTREACHED();
|
| - ImporterCleanup();
|
| - }
|
| - import_thread_->message_loop()->PostTask(
|
| - FROM_HERE, base::Bind(&Importer::StartImport, importer_.get(),
|
| - source_profile, items, bridge_));
|
| -}
|
| -
|
| -void ChromeContentUtilityClient::OnImportCancel() {
|
| - ImporterCleanup();
|
| -}
|
| -
|
| -void ChromeContentUtilityClient::OnImportItemFinished(uint16 item) {
|
| - items_to_import_ ^= item; // Remove finished item from mask.
|
| - // If we've finished with all items, notify the browser process.
|
| - if (items_to_import_ == 0) {
|
| - Send(new ProfileImportProcessHostMsg_Import_Finished(true, ""));
|
| - ImporterCleanup();
|
| - }
|
| -}
|
| -
|
| -void ChromeContentUtilityClient::ImporterCleanup() {
|
| - importer_->Cancel();
|
| - importer_ = NULL;
|
| - bridge_ = NULL;
|
| - import_thread_.reset();
|
| - content::UtilityThread::Get()->ReleaseProcessIfNeeded();
|
| -}
|
| -
|
| } // namespace chrome
|
|
|