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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 10777012: Disable uses of ProfileImportProcess on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Yaron's comments Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
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 9a129e9a37326f2002d2f87e8ea1fbc728563b9d..f8073c40776857d7d34ddb5b1cce83ee1d94a198 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/extension_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,8 @@
namespace chrome {
-ChromeContentUtilityClient::ChromeContentUtilityClient() : items_to_import_(0) {
+ChromeContentUtilityClient::ChromeContentUtilityClient()
+ : import_handler_(new ProfileImportHandler()) {
}
ChromeContentUtilityClient::~ChromeContentUtilityClient() {
@@ -82,14 +84,12 @@ 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 (!handled)
+ handled = import_handler_->OnMessageReceived(message);
+
return handled;
}
@@ -391,54 +391,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

Powered by Google App Engine
This is Rietveld 408576698