summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-03 15:42:11 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-03 15:42:11 +0000
commitd8497188bea09c351be4703eeb1ab0ef03011e4d (patch)
tree04d3614125e3f187a11be2001c36b586de187618
parent6097726ec20525f0f8524e5a799c474a96ab35be (diff)
downloadchromium_src-d8497188bea09c351be4703eeb1ab0ef03011e4d.zip
chromium_src-d8497188bea09c351be4703eeb1ab0ef03011e4d.tar.gz
chromium_src-d8497188bea09c351be4703eeb1ab0ef03011e4d.tar.bz2
Get rid of the profile import process code, and instead go through the utility process like the rest of our tasks that we want to run outside the browser. When that code was first written, we didn't have the utility process.
Review URL: http://codereview.chromium.org/8108001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103714 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_main.cc6
-rw-r--r--chrome/browser/importer/external_process_importer_bridge.cc83
-rw-r--r--chrome/browser/importer/external_process_importer_bridge.h12
-rw-r--r--chrome/browser/importer/external_process_importer_client.cc92
-rw-r--r--chrome/browser/importer/external_process_importer_client.h87
-rw-r--r--chrome/browser/importer/profile_import_process_client.cc118
-rw-r--r--chrome/browser/importer/profile_import_process_client.h89
-rw-r--r--chrome/browser/importer/profile_import_process_host.cc149
-rw-r--r--chrome/browser/importer/profile_import_process_host.h78
-rw-r--r--chrome/chrome.gyp13
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/chrome_tests.gypi4
-rw-r--r--chrome/profile_import/DEPS6
-rw-r--r--chrome/profile_import/profile_import_main.cc24
-rw-r--r--chrome/profile_import/profile_import_thread.cc196
-rw-r--r--chrome/profile_import/profile_import_thread.h107
-rw-r--r--chrome/utility/DEPS1
-rw-r--r--chrome/utility/chrome_content_utility_client.cc63
-rw-r--r--chrome/utility/chrome_content_utility_client.h37
-rw-r--r--content/browser/utility_process_host.cc2
-rw-r--r--content/browser/utility_process_host.h8
-rw-r--r--content/common/content_switches.cc3
-rw-r--r--content/common/content_switches.h2
-rw-r--r--content/common/sandbox_init_wrapper_mac.cc1
-rw-r--r--content/common/sandbox_policy.cc5
25 files changed, 300 insertions, 891 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index a752644..4d7fbe4 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -102,7 +102,6 @@ base::LazyInstance<chrome::ChromeContentPluginClient>
g_chrome_content_plugin_client(base::LINKER_INITIALIZED);
extern int NaClMain(const MainFunctionParams&);
-extern int ProfileImportMain(const MainFunctionParams&);
extern int ServiceProcessMain(const MainFunctionParams&);
#if defined(OS_WIN)
@@ -226,9 +225,6 @@ static void AdjustLinuxOOMScore(const std::string& process_type) {
process_type == switches::kGpuProcess ||
process_type == switches::kServiceProcess) {
score = kMiscScore;
- } else if (process_type == switches::kProfileImportProcess) {
- NOTIMPLEMENTED();
- score = kZygoteScore;
#ifndef DISABLE_NACL
} else if (process_type == switches::kNaClLoaderProcess) {
score = kPluginScore;
@@ -655,8 +651,6 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
{ switches::kExtensionProcess, RendererMain },
{ switches::kServiceProcess, ServiceProcessMain },
#if defined(OS_MACOSX)
- // TODO(port): Use OOP profile import - http://crbug.com/22142 .
- { switches::kProfileImportProcess, ProfileImportMain },
{ switches::kRelauncherProcess,
mac_relauncher::internal::RelauncherMain },
#endif
diff --git a/chrome/browser/importer/external_process_importer_bridge.cc b/chrome/browser/importer/external_process_importer_bridge.cc
index 59d30ac..fd6090a8 100644
--- a/chrome/browser/importer/external_process_importer_bridge.cc
+++ b/chrome/browser/importer/external_process_importer_bridge.cc
@@ -9,17 +9,25 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/history/history_types.h"
-#include "chrome/profile_import/profile_import_thread.h"
+#include "chrome/browser/importer/profile_import_process_messages.h"
+#include "content/common/child_thread.h"
#include "webkit/glue/password_form.h"
#if defined(OS_WIN)
#include "chrome/browser/password_manager/ie7_password.h"
#endif
+namespace {
+// Rather than sending all import items over IPC at once we chunk them into
+// separate requests. This avoids the case of a large import causing
+// oversized IPC messages.
+const int kNumBookmarksToSend = 100;
+const int kNumHistoryRowsToSend = 100;
+const int kNumFaviconsToSend = 100;
+}
+
ExternalProcessImporterBridge::ExternalProcessImporterBridge(
- ProfileImportThread* profile_import_thread,
- const DictionaryValue& localized_strings)
- : profile_import_thread_(profile_import_thread) {
+ const DictionaryValue& localized_strings) {
// Bridge needs to make its own copy because OS 10.6 autoreleases the
// localized_strings value that is passed in (see http://crbug.com/46003 ).
localized_strings_.reset(localized_strings.DeepCopy());
@@ -28,8 +36,21 @@ ExternalProcessImporterBridge::ExternalProcessImporterBridge(
void ExternalProcessImporterBridge::AddBookmarks(
const std::vector<ProfileWriter::BookmarkEntry>& bookmarks,
const string16& first_folder_name) {
- profile_import_thread_->NotifyBookmarksImportReady(bookmarks,
- first_folder_name);
+ Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart(
+ first_folder_name, bookmarks.size()));
+
+ std::vector<ProfileWriter::BookmarkEntry>::const_iterator it;
+ for (it = bookmarks.begin(); it < bookmarks.end();
+ it = it + kNumBookmarksToSend) {
+ std::vector<ProfileWriter::BookmarkEntry> bookmark_group;
+ std::vector<ProfileWriter::BookmarkEntry>::const_iterator end_group =
+ it + kNumBookmarksToSend < bookmarks.end() ?
+ it + kNumBookmarksToSend : bookmarks.end();
+ bookmark_group.assign(it, end_group);
+
+ Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportGroup(
+ bookmark_group));
+ }
}
void ExternalProcessImporterBridge::AddHomePage(const GURL& home_page) {
@@ -45,39 +66,69 @@ void ExternalProcessImporterBridge::AddIE7PasswordInfo(
void ExternalProcessImporterBridge::SetFavicons(
const std::vector<history::ImportedFaviconUsage>& favicons) {
- profile_import_thread_->NotifyFaviconsImportReady(favicons);
+ Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportStart(
+ favicons.size()));
+
+ std::vector<history::ImportedFaviconUsage>::const_iterator it;
+ for (it = favicons.begin(); it < favicons.end();
+ it = it + kNumFaviconsToSend) {
+ std::vector<history::ImportedFaviconUsage> favicons_group;
+ std::vector<history::ImportedFaviconUsage>::const_iterator end_group =
+ std::min(it + kNumFaviconsToSend, favicons.end());
+ favicons_group.assign(it, end_group);
+
+ Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportGroup(
+ favicons_group));
+ }
}
void ExternalProcessImporterBridge::SetHistoryItems(
const std::vector<history::URLRow>& rows,
history::VisitSource visit_source) {
- profile_import_thread_->NotifyHistoryImportReady(rows, visit_source);
+ Send(new ProfileImportProcessHostMsg_NotifyHistoryImportStart(rows.size()));
+
+ std::vector<history::URLRow>::const_iterator it;
+ for (it = rows.begin(); it < rows.end();
+ it = it + kNumHistoryRowsToSend) {
+ std::vector<history::URLRow> row_group;
+ std::vector<history::URLRow>::const_iterator end_group =
+ it + kNumHistoryRowsToSend < rows.end() ?
+ it + kNumHistoryRowsToSend : rows.end();
+ row_group.assign(it, end_group);
+
+ Send(new ProfileImportProcessHostMsg_NotifyHistoryImportGroup(row_group,
+ visit_source));
+ }
}
void ExternalProcessImporterBridge::SetKeywords(
const std::vector<TemplateURL*>& template_urls,
int default_keyword_index,
bool unique_on_host_and_path) {
- profile_import_thread_->NotifyKeywordsReady(
- template_urls, default_keyword_index, unique_on_host_and_path);
+ std::vector<TemplateURL> urls;
+ for (size_t i = 0; i < template_urls.size(); ++i) {
+ urls.push_back(*template_urls[i]);
+ }
+ Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls,
+ default_keyword_index, unique_on_host_and_path));
}
void ExternalProcessImporterBridge::SetPasswordForm(
const webkit_glue::PasswordForm& form) {
- profile_import_thread_->NotifyPasswordFormReady(form);
+ Send(new ProfileImportProcessHostMsg_NotifyPasswordFormReady(form));
}
void ExternalProcessImporterBridge::NotifyStarted() {
- profile_import_thread_->NotifyStarted();
+ Send(new ProfileImportProcessHostMsg_Import_Started());
}
void ExternalProcessImporterBridge::NotifyItemStarted(
importer::ImportItem item) {
- profile_import_thread_->NotifyItemStarted(item);
+ Send(new ProfileImportProcessHostMsg_ImportItem_Started(item));
}
void ExternalProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) {
- profile_import_thread_->NotifyItemEnded(item);
+ Send(new ProfileImportProcessHostMsg_ImportItem_Finished(item));
}
void ExternalProcessImporterBridge::NotifyEnded() {
@@ -91,3 +142,7 @@ string16 ExternalProcessImporterBridge::GetLocalizedString(int message_id) {
}
ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {}
+
+bool ExternalProcessImporterBridge::Send(IPC::Message* message) {
+ return ChildThread::current()->Send(message);
+}
diff --git a/chrome/browser/importer/external_process_importer_bridge.h b/chrome/browser/importer/external_process_importer_bridge.h
index 80c2724..4c50a78 100644
--- a/chrome/browser/importer/external_process_importer_bridge.h
+++ b/chrome/browser/importer/external_process_importer_bridge.h
@@ -15,7 +15,10 @@
#include "chrome/browser/importer/profile_writer.h"
class GURL;
-class ProfileImportThread;
+
+namespace IPC {
+class Message;
+}
namespace base {
class DictionaryValue;
@@ -28,8 +31,8 @@ class DictionaryValue;
// profile.
class ExternalProcessImporterBridge : public ImporterBridge {
public:
- ExternalProcessImporterBridge(ProfileImportThread* profile_import_thread,
- const base::DictionaryValue& localized_strings);
+ explicit ExternalProcessImporterBridge(
+ const base::DictionaryValue& localized_strings);
// Begin ImporterBridge implementation:
virtual void AddBookmarks(
@@ -66,8 +69,7 @@ class ExternalProcessImporterBridge : public ImporterBridge {
private:
virtual ~ExternalProcessImporterBridge();
- // Call back to send data and messages across IPC.
- ProfileImportThread* const profile_import_thread_;
+ bool Send(IPC::Message* message);
// Holds strings needed by the external importer because the resource
// bundle isn't available to the external process.
diff --git a/chrome/browser/importer/external_process_importer_client.cc b/chrome/browser/importer/external_process_importer_client.cc
index 1d3b7d3..992df73 100644
--- a/chrome/browser/importer/external_process_importer_client.cc
+++ b/chrome/browser/importer/external_process_importer_client.cc
@@ -4,15 +4,19 @@
#include "chrome/browser/importer/external_process_importer_client.h"
+#include "base/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/importer/external_process_importer_host.h"
+#include "chrome/browser/importer/firefox_importer_utils.h"
#include "chrome/browser/importer/importer_host.h"
#include "chrome/browser/importer/in_process_importer_bridge.h"
-#include "chrome/browser/importer/profile_import_process_host.h"
+#include "chrome/browser/importer/profile_import_process_messages.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
ExternalProcessImporterClient::ExternalProcessImporterClient(
ExternalProcessImporterHost* importer_host,
@@ -23,7 +27,7 @@ ExternalProcessImporterClient::ExternalProcessImporterClient(
total_history_rows_count_(0),
total_favicons_count_(0),
process_importer_host_(importer_host),
- profile_import_process_host_(NULL),
+ utility_process_host_(NULL),
source_profile_(source_profile),
items_(items),
bridge_(bridge),
@@ -37,12 +41,13 @@ ExternalProcessImporterClient::~ExternalProcessImporterClient() {
}
void ExternalProcessImporterClient::CancelImportProcessOnIOThread() {
- profile_import_process_host_->CancelProfileImportProcess();
+ utility_process_host_->Send(new ProfileImportProcessMsg_CancelImport());
}
void ExternalProcessImporterClient::NotifyItemFinishedOnIOThread(
importer::ImportItem import_item) {
- profile_import_process_host_->ReportImportItemFinished(import_item);
+ utility_process_host_->Send(
+ new ProfileImportProcessMsg_ReportImportItemFinished(import_item));
}
void ExternalProcessImporterClient::Cleanup() {
@@ -68,10 +73,41 @@ void ExternalProcessImporterClient::Start() {
void ExternalProcessImporterClient::StartProcessOnIOThread(
BrowserThread::ID thread_id) {
- profile_import_process_host_ =
- new ProfileImportProcessHost(this, thread_id);
- profile_import_process_host_->StartProfileImportProcess(source_profile_,
- items_);
+ utility_process_host_ = new UtilityProcessHost(this, thread_id);
+ utility_process_host_->set_no_sandbox(true);
+
+#if defined(OS_MACOSX)
+ base::environment_vector env;
+ std::string dylib_path = GetFirefoxDylibPath().value();
+ if (!dylib_path.empty())
+ env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path));
+ utility_process_host_->set_env(env);
+#endif
+
+ // Dictionary of all localized strings that could be needed by the importer
+ // in the external process.
+ DictionaryValue localized_strings;
+ localized_strings.SetString(
+ base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX),
+ l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX));
+ localized_strings.SetString(
+ base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI),
+ l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI));
+ localized_strings.SetString(
+ base::IntToString(IDS_IMPORT_FROM_FIREFOX),
+ l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX));
+ localized_strings.SetString(
+ base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR),
+ l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR));
+ localized_strings.SetString(
+ base::IntToString(IDS_IMPORT_FROM_SAFARI),
+ l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI));
+ localized_strings.SetString(
+ base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME),
+ l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME));
+
+ utility_process_host_->Send(new ProfileImportProcessMsg_StartImport(
+ source_profile_, items_, localized_strings));
}
void ExternalProcessImporterClient::Cancel() {
@@ -79,7 +115,7 @@ void ExternalProcessImporterClient::Cancel() {
return;
cancelled_ = true;
- if (profile_import_process_host_) {
+ if (utility_process_host_) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this,
@@ -89,12 +125,50 @@ void ExternalProcessImporterClient::Cancel() {
}
void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) {
+ utility_process_host_ = NULL;
if (cancelled_)
return;
process_importer_host_->Cancel();
}
+bool ExternalProcessImporterClient::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ExternalProcessImporterClient, message)
+ // Notification messages about the state of the import process.
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started,
+ OnImportStart)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished,
+ OnImportFinished)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started,
+ OnImportItemStart)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Finished,
+ OnImportItemFinished)
+ // Data messages containing items to be written to the user profile.
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportStart,
+ OnHistoryImportStart)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportGroup,
+ OnHistoryImportGroup)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHomePageImportReady,
+ OnHomePageImportReady)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportStart,
+ OnBookmarksImportStart)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup,
+ OnBookmarksImportGroup)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportStart,
+ OnFaviconsImportStart)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup,
+ OnFaviconsImportGroup)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady,
+ OnPasswordFormImportReady)
+ IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady,
+ OnKeywordsImportReady)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP_EX()
+ return handled;
+}
+
void ExternalProcessImporterClient::OnImportStart() {
if (cancelled_)
return;
diff --git a/chrome/browser/importer/external_process_importer_client.h b/chrome/browser/importer/external_process_importer_client.h
index 2e5bdd5..81ba8fc 100644
--- a/chrome/browser/importer/external_process_importer_client.h
+++ b/chrome/browser/importer/external_process_importer_client.h
@@ -14,22 +14,22 @@
#include "base/string16.h"
#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/importer/profile_writer.h"
-#include "chrome/browser/importer/profile_import_process_client.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/utility_process_host.h"
class ExternalProcessImporterHost;
class InProcessImporterBridge;
-class ProfileImportProcessHost;
+class UtilityProcessHost;
namespace history {
class URLRow;
struct ImportedFaviconUsage;
}
-// This class is the client for the ProfileImportProcessHost. It collects
-// notifications from this process host and feeds data back to the importer
-// host, who actually does the writing.
-class ExternalProcessImporterClient : public ProfileImportProcessClient {
+// This class is the client for the out of process profile importing. It
+// collects notifications from this process host and feeds data back to the
+// importer host, who actually does the writing.
+class ExternalProcessImporterClient : public UtilityProcessHost::Client {
public:
ExternalProcessImporterClient(ExternalProcessImporterHost* importer_host,
const importer::SourceProfile& source_profile,
@@ -49,63 +49,38 @@ class ExternalProcessImporterClient : public ProfileImportProcessClient {
// Launches the task to start the external process.
virtual void Start();
- // Creates a new ProfileImportProcessHost, which launches the import process.
+ // Creates a new UtilityProcessHost, which launches the import process.
virtual void StartProcessOnIOThread(BrowserThread::ID thread_id);
// Called by the ExternalProcessImporterHost on import cancel.
virtual void Cancel();
- // Begin ProfileImportProcessHost::ImportProcessClient implementation.
- virtual void OnProcessCrashed(int exit_status) OVERRIDE;
- virtual void OnImportStart() OVERRIDE;
- virtual void OnImportFinished(bool succeeded,
- const std::string& error_msg) OVERRIDE;
- virtual void OnImportItemStart(int item) OVERRIDE;
- virtual void OnImportItemFinished(int item) OVERRIDE;
-
- // Called on first message received when importing history; gives total
- // number of rows to be imported.
- virtual void OnHistoryImportStart(size_t total_history_rows_count) OVERRIDE;
-
- // Called when a group of URLRows has been received.
- virtual void OnHistoryImportGroup(
+ // UtilityProcessHost::Client implementation:
+ virtual void OnProcessCrashed(int exit_code) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // Message handlers
+ void OnImportStart();
+ void OnImportFinished(bool succeeded, const std::string& error_msg);
+ void OnImportItemStart(int item);
+ void OnImportItemFinished(int item);
+ void OnHistoryImportStart(size_t total_history_rows_count);
+ void OnHistoryImportGroup(
const std::vector<history::URLRow>& history_rows_group,
- int visit_source) OVERRIDE;
-
- // Called when the home page has been received.
- virtual void OnHomePageImportReady(const GURL& home_page) OVERRIDE;
-
- // First message received when importing bookmarks.
- // |first_folder_name| can be NULL.
- // |total_bookmarks_count| is the total number of bookmarks to be imported.
- virtual void OnBookmarksImportStart(const string16& first_folder_name,
- size_t total_bookmarks_count) OVERRIDE;
-
- // Called when a group of bookmarks has been received.
- virtual void OnBookmarksImportGroup(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group)
- OVERRIDE;
-
- // First message received when importing favicons. |total_favicons_size|
- // gives the total number of favicons to be imported.
- virtual void OnFaviconsImportStart(size_t total_favicons_count) OVERRIDE;
-
- // Called when a group of favicons has been received.
- virtual void OnFaviconsImportGroup(
- const std::vector<history::ImportedFaviconUsage>& favicons_group)
- OVERRIDE;
-
- // Called when the passwordform has been received.
- virtual void OnPasswordFormImportReady(
- const webkit_glue::PasswordForm& form) OVERRIDE;
-
- // Called when search engines have been received.
- virtual void OnKeywordsImportReady(
+ int visit_source);
+ void OnHomePageImportReady(const GURL& home_page);
+ void OnBookmarksImportStart(const string16& first_folder_name,
+ size_t total_bookmarks_count);
+ void OnBookmarksImportGroup(
+ const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group);
+ void OnFaviconsImportStart(size_t total_favicons_count);
+ void OnFaviconsImportGroup(
+ const std::vector<history::ImportedFaviconUsage>& favicons_group);
+ void OnPasswordFormImportReady(const webkit_glue::PasswordForm& form);
+ void OnKeywordsImportReady(
const std::vector<TemplateURL>& template_urls,
int default_keyword_index,
- bool unique_on_host_and_path) OVERRIDE;
-
- // End ProfileImportProcessClient implementation.
+ bool unique_on_host_and_path);
private:
// These variables store data being collected from the importer until the
@@ -135,7 +110,7 @@ class ExternalProcessImporterClient : public ProfileImportProcessClient {
// Handles sending messages to the external process. Deletes itself when
// the external process dies (see ChildProcessHost::OnChildDied).
- ProfileImportProcessHost* profile_import_process_host_;
+ UtilityProcessHost* utility_process_host_;
// Data to be passed from the importer host to the external importer.
const importer::SourceProfile& source_profile_;
diff --git a/chrome/browser/importer/profile_import_process_client.cc b/chrome/browser/importer/profile_import_process_client.cc
deleted file mode 100644
index 407b5b3..0000000
--- a/chrome/browser/importer/profile_import_process_client.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2011 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/profile_import_process_client.h"
-
-#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/importer/profile_import_process_host.h"
-#include "chrome/browser/importer/profile_import_process_messages.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "googleurl/src/gurl.h"
-#include "ipc/ipc_message_macros.h"
-#include "webkit/glue/password_form.h"
-
-ProfileImportProcessClient::ProfileImportProcessClient() {
-}
-
-void ProfileImportProcessClient::OnProcessCrashed(int exit_status) {
-}
-
-void ProfileImportProcessClient::OnImportStart() {
-}
-
-void ProfileImportProcessClient::OnImportFinished(
- bool succeeded,
- const std::string& error_msg) {
-}
-
-void ProfileImportProcessClient::OnImportItemStart(int item) {
-}
-
-void ProfileImportProcessClient::OnImportItemFinished(int item) {
-}
-
-void ProfileImportProcessClient::OnImportItemFailed(
- const std::string& error_msg) {
-}
-
-void ProfileImportProcessClient::OnHistoryImportStart(
- size_t total_history_rows_count) {
-}
-
-void ProfileImportProcessClient::OnHistoryImportGroup(
- const std::vector<history::URLRow>& history_rows_group,
- int visit_source) {
-}
-
-void ProfileImportProcessClient::OnHomePageImportReady(const GURL& home_page) {
-}
-
-void ProfileImportProcessClient::OnBookmarksImportStart(
- const string16& first_folder_name,
- size_t total_bookmarks_count) {
-}
-
-void ProfileImportProcessClient::OnBookmarksImportGroup(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks) {
-}
-
-void ProfileImportProcessClient::OnFaviconsImportStart(
- size_t total_favicons_count) {
-}
-
-void ProfileImportProcessClient::OnFaviconsImportGroup(
- const std::vector<history::ImportedFaviconUsage>& favicons_group) {
-}
-
-void ProfileImportProcessClient::OnPasswordFormImportReady(
- const webkit_glue::PasswordForm& form) {
-}
-
-void ProfileImportProcessClient::OnKeywordsImportReady(
- const std::vector<TemplateURL>& template_urls,
- int default_keyword_index,
- bool unique_on_host_and_path) {
-}
-
-bool ProfileImportProcessClient::OnMessageReceived(
- const IPC::Message& message) {
- bool msg_is_ok = true;
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(ProfileImportProcessClient, message, msg_is_ok)
- // Notification messages about the state of the import process.
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started,
- OnImportStart)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished,
- OnImportFinished)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started,
- OnImportItemStart)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Finished,
- OnImportItemFinished)
-
- // Data messages containing items to be written to the user profile.
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportStart,
- OnHistoryImportStart)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportGroup,
- OnHistoryImportGroup)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHomePageImportReady,
- OnHomePageImportReady)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportStart,
- OnBookmarksImportStart)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup,
- OnBookmarksImportGroup)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportStart,
- OnFaviconsImportStart)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup,
- OnFaviconsImportGroup)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady,
- OnPasswordFormImportReady)
- IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady,
- OnKeywordsImportReady)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
- return handled;
-}
-
-ProfileImportProcessClient::~ProfileImportProcessClient() {
-}
diff --git a/chrome/browser/importer/profile_import_process_client.h b/chrome/browser/importer/profile_import_process_client.h
deleted file mode 100644
index b87b701..0000000
--- a/chrome/browser/importer/profile_import_process_client.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_
-#define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "chrome/browser/importer/profile_writer.h"
-
-class GURL;
-class TemplateURL;
-
-namespace history {
-class URLRow;
-}
-
-namespace IPC {
-class Message;
-}
-
-namespace webkit_glue {
-struct PasswordForm;
-}
-
-// An interface that must be implemented by consumers of the profile import
-// process in order to get results back from the process host. The
-// ProfileImportProcessHost calls the client's functions on the thread passed to
-// it when it's created.
-class ProfileImportProcessClient
- : public base::RefCountedThreadSafe<ProfileImportProcessClient> {
- public:
- ProfileImportProcessClient();
-
- // These methods are used by the ProfileImportProcessHost to pass messages
- // received from the external process back to the ImportProcessClient in
- // ImporterHost.
- virtual void OnProcessCrashed(int exit_status);
- virtual void OnImportStart();
- virtual void OnImportFinished(bool succeeded, const std::string& error_msg);
- virtual void OnImportItemStart(int item);
- virtual void OnImportItemFinished(int item);
- virtual void OnImportItemFailed(const std::string& error_msg);
-
- // These methods pass back data to be written to the user's profile from
- // the external process to the process host client.
- virtual void OnHistoryImportStart(size_t total_history_rows_count);
- virtual void OnHistoryImportGroup(
- const std::vector<history::URLRow>& history_rows_group,
- int visit_source); // visit_source has history::VisitSource type.
-
- virtual void OnHomePageImportReady(const GURL& home_page);
-
- virtual void OnBookmarksImportStart(const string16& first_folder_name,
- size_t total_bookmarks_count);
- virtual void OnBookmarksImportGroup(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks);
-
- virtual void OnFaviconsImportStart(size_t total_favicons_count);
- virtual void OnFaviconsImportGroup(
- const std::vector<history::ImportedFaviconUsage>& favicons_group);
-
- virtual void OnPasswordFormImportReady(
- const webkit_glue::PasswordForm& form);
-
- virtual void OnKeywordsImportReady(
- const std::vector<TemplateURL>& template_urls,
- int default_keyword_index,
- bool unique_on_host_and_path);
-
- virtual bool OnMessageReceived(const IPC::Message& message);
-
- protected:
- friend class base::RefCountedThreadSafe<ProfileImportProcessClient>;
-
- virtual ~ProfileImportProcessClient();
-
- private:
- friend class ProfileImportProcessHost;
-
- DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessClient);
-};
-
-#endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_
diff --git a/chrome/browser/importer/profile_import_process_host.cc b/chrome/browser/importer/profile_import_process_host.cc
deleted file mode 100644
index 51d339d..0000000
--- a/chrome/browser/importer/profile_import_process_host.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright (c) 2011 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/profile_import_process_host.h"
-
-#include "base/command_line.h"
-#include "base/message_loop.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/importer/firefox_importer_utils.h"
-#include "chrome/browser/importer/profile_import_process_client.h"
-#include "chrome/browser/importer/profile_import_process_messages.h"
-#include "chrome/common/chrome_switches.h"
-#include "grit/generated_resources.h"
-#include "ipc/ipc_switches.h"
-#include "ui/base/l10n/l10n_util.h"
-
-ProfileImportProcessHost::ProfileImportProcessHost(
- ProfileImportProcessClient* import_process_client,
- BrowserThread::ID thread_id)
- : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS),
- import_process_client_(import_process_client),
- thread_id_(thread_id) {
-}
-
-ProfileImportProcessHost::~ProfileImportProcessHost() {
-}
-
-bool ProfileImportProcessHost::StartProfileImportProcess(
- const importer::SourceProfile& source_profile,
- uint16 items) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!StartProcess())
- return false;
-
- // Dictionary of all localized strings that could be needed by the importer
- // in the external process.
- DictionaryValue localized_strings;
- localized_strings.SetString(
- base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX),
- l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX));
- localized_strings.SetString(
- base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI),
- l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI));
- localized_strings.SetString(
- base::IntToString(IDS_IMPORT_FROM_FIREFOX),
- l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX));
- localized_strings.SetString(
- base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR),
- l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR));
- localized_strings.SetString(
- base::IntToString(IDS_IMPORT_FROM_SAFARI),
- l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI));
- localized_strings.SetString(
- base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME),
- l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME));
-
- Send(new ProfileImportProcessMsg_StartImport(source_profile, items,
- localized_strings));
- return true;
-}
-
-bool ProfileImportProcessHost::CancelProfileImportProcess() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- Send(new ProfileImportProcessMsg_CancelImport());
- return true;
-}
-
-bool ProfileImportProcessHost::ReportImportItemFinished(
- importer::ImportItem item) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- Send(new ProfileImportProcessMsg_ReportImportItemFinished(item));
- return true;
-}
-
-FilePath ProfileImportProcessHost::GetProfileImportProcessCmd() {
-#if defined(OS_LINUX)
- int flags = CHILD_ALLOW_SELF;
-#else
- int flags = CHILD_NORMAL;
-#endif
- return GetChildPath(flags);
-}
-
-bool ProfileImportProcessHost::StartProcess() {
- set_name(ASCIIToUTF16("profile import process"));
-
- if (!CreateChannel())
- return false;
-
- FilePath exe_path = GetProfileImportProcessCmd();
- if (exe_path.empty()) {
- NOTREACHED() << "Unable to get profile import process binary name.";
- return false;
- }
-
- CommandLine* cmd_line = new CommandLine(exe_path);
- cmd_line->AppendSwitchASCII(switches::kProcessType,
- switches::kProfileImportProcess);
- cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id());
-
- const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
- if (browser_command_line.HasSwitch(switches::kChromeFrame))
- cmd_line->AppendSwitch(switches::kChromeFrame);
-
-#if defined(OS_MACOSX)
- base::environment_vector env;
- std::string dylib_path = GetFirefoxDylibPath().value();
- if (!dylib_path.empty())
- env.push_back(std::make_pair("DYLD_FALLBACK_LIBRARY_PATH", dylib_path));
-
- Launch(false, env, cmd_line);
-#elif defined(OS_WIN)
- FilePath no_exposed_directory;
-
- Launch(no_exposed_directory, cmd_line);
-#else
- base::environment_vector env;
-
- Launch(false, env, cmd_line);
-#endif
-
- return true;
-}
-
-bool ProfileImportProcessHost::OnMessageReceived(const IPC::Message& message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- thread_id_, FROM_HERE,
- NewRunnableMethod(import_process_client_.get(),
- &ProfileImportProcessClient::OnMessageReceived,
- message));
- return true;
-}
-
-void ProfileImportProcessHost::OnProcessCrashed(int exit_code) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- thread_id_, FROM_HERE,
- NewRunnableMethod(import_process_client_.get(),
- &ProfileImportProcessClient::OnProcessCrashed,
- exit_code));
-}
-
-bool ProfileImportProcessHost::CanShutdown() {
- return true;
-}
diff --git a/chrome/browser/importer/profile_import_process_host.h b/chrome/browser/importer/profile_import_process_host.h
deleted file mode 100644
index 9403b37..0000000
--- a/chrome/browser/importer/profile_import_process_host.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_
-#define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "chrome/browser/importer/profile_writer.h"
-#include "content/browser/browser_child_process_host.h"
-#include "content/browser/browser_thread.h"
-
-class ProfileImportProcessClient;
-
-namespace webkit_glue {
-struct PasswordForm;
-}
-
-// Browser-side host to a profile import process. This class lives only on
-// the IO thread. It passes messages back to the |thread_id_| thread through
-// a client object.
-class ProfileImportProcessHost : public BrowserChildProcessHost {
- public:
- // |import_process_client| implements callbacks which are triggered by
- // incoming IPC messages. This client creates an interface between IPC
- // messages received by the ProfileImportProcessHost and the internal
- // importer_bridge.
- // |thread_id| gives the thread where the client lives. The
- // ProfileImportProcessHost spawns tasks on this thread for the client.
- ProfileImportProcessHost(ProfileImportProcessClient* import_process_client,
- BrowserThread::ID thread_id);
- virtual ~ProfileImportProcessHost();
-
- // |source_profile| and |items| are needed by the external importer process.
- bool StartProfileImportProcess(const importer::SourceProfile& source_profile,
- uint16 items);
-
- // Cancel the external import process.
- bool CancelProfileImportProcess();
-
- // Report that an item has been successfully imported. We need to make
- // sure that all import messages have come across the wire before the
- // external import process shuts itself down.
- bool ReportImportItemFinished(importer::ImportItem item);
-
- protected:
- // This method is virtual to be overridden by tests.
- virtual FilePath GetProfileImportProcessCmd();
-
- private:
- // Launch the new process.
- bool StartProcess();
-
- // Called by the external importer process to send messages back to the
- // ImportProcessClient.
- virtual bool OnMessageReceived(const IPC::Message& message);
-
- // BrowserChildProcessHost:
- virtual void OnProcessCrashed(int exit_code) OVERRIDE;
- virtual bool CanShutdown() OVERRIDE;
-
- // Receives messages to be passed back to the importer host.
- scoped_refptr<ProfileImportProcessClient> import_process_client_;
-
- // The thread where the import_process_client_ lives.
- BrowserThread::ID thread_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessHost);
-};
-
-#endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_HOST_H_
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 60ed930..51e1218 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -24,7 +24,6 @@
'common',
'browser',
'debugger',
- 'profile_import',
'plugin',
'renderer',
'syncapi_core',
@@ -478,18 +477,6 @@
],
},
{
- 'target_name': 'profile_import',
- 'type': 'static_library',
- 'dependencies': [
- '../base/base.gyp:base',
- ],
- 'sources': [
- 'profile_import/profile_import_main.cc',
- 'profile_import/profile_import_thread.cc',
- 'profile_import/profile_import_thread.h',
- ],
- },
- {
# Provides a syncapi dynamic library target from checked-in binaries,
# or from compiling a stub implementation.
'target_name': 'syncapi_core',
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1410cee..88ca626 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -19,7 +19,6 @@
'in_memory_url_index_cache_proto',
'installer_util',
'platform_locale_settings',
- 'profile_import',
'safe_browsing_proto',
'safe_browsing_report_proto',
# TODO(sync): Make browser not depend on syncapi_core directly.
@@ -1406,10 +1405,6 @@
'browser/importer/nss_decryptor_system_nss.h',
'browser/importer/nss_decryptor_win.cc',
'browser/importer/nss_decryptor_win.h',
- 'browser/importer/profile_import_process_client.cc',
- 'browser/importer/profile_import_process_client.h',
- 'browser/importer/profile_import_process_host.cc',
- 'browser/importer/profile_import_process_host.h',
'browser/importer/profile_import_process_messages.cc',
'browser/importer/profile_import_process_messages.h',
'browser/importer/profile_writer.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a35d5c2..173050c 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -655,7 +655,6 @@
'common',
'chrome_resources',
'chrome_strings',
- 'profile_import',
'test_support_ui',
'../base/base.gyp:base',
'../net/net.gyp:net',
@@ -2172,7 +2171,6 @@
'chrome',
'chrome_resources',
'chrome_strings',
- 'profile_import',
'renderer',
'test_support_common',
'../base/base.gyp:base',
@@ -3029,7 +3027,6 @@
'../third_party/bzip2/bzip2.gyp:bzip2',
'../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
'../third_party/libjingle/libjingle.gyp:libjingle',
- 'profile_import',
'syncapi_core',
'sync_notifier',
'test_support_common',
@@ -3106,7 +3103,6 @@
'chrome',
'chrome_resources',
'common',
- 'profile_import',
'renderer',
'chrome_strings',
'test_support_common',
diff --git a/chrome/profile_import/DEPS b/chrome/profile_import/DEPS
deleted file mode 100644
index 4c8adc9..0000000
--- a/chrome/profile_import/DEPS
+++ /dev/null
@@ -1,6 +0,0 @@
-include_rules = [
- "+chrome/browser/history",
- "+chrome/browser/importer",
- "+chrome/browser/search_engines",
- "+webkit/glue"
-]
diff --git a/chrome/profile_import/profile_import_main.cc b/chrome/profile_import/profile_import_main.cc
deleted file mode 100644
index 01a7c35..0000000
--- a/chrome/profile_import/profile_import_main.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2011 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 "base/message_loop.h"
-#include "base/threading/platform_thread.h"
-#include "chrome/profile_import/profile_import_thread.h"
-#include "content/common/child_process.h"
-
-struct MainFunctionParams;
-
-// Mainline routine for running as the profile import process.
-int ProfileImportMain(const MainFunctionParams& parameters) {
- // The main message loop of the profile import process.
- MessageLoop main_message_loop;
- base::PlatformThread::SetName("CrProfileImportMain");
-
- ChildProcess profile_import_process;
- profile_import_process.set_main_thread(new ProfileImportThread());
-
- MessageLoop::current()->Run();
-
- return 0;
-}
diff --git a/chrome/profile_import/profile_import_thread.cc b/chrome/profile_import/profile_import_thread.cc
deleted file mode 100644
index 5a211fb..0000000
--- a/chrome/profile_import/profile_import_thread.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright (c) 2011 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/profile_import/profile_import_thread.h"
-
-#include <stddef.h>
-#include <algorithm>
-
-#include "base/location.h"
-#include "base/message_loop.h"
-#include "base/threading/thread.h"
-#include "base/values.h"
-#include "chrome/browser/importer/external_process_importer_bridge.h"
-#include "chrome/browser/importer/importer.h"
-#include "chrome/browser/importer/importer_type.h"
-#include "chrome/browser/importer/profile_import_process_messages.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "content/common/child_process.h"
-#include "googleurl/src/gurl.h"
-#include "ipc/ipc_message_macros.h"
-
-namespace {
-// Rather than sending all import items over IPC at once we chunk them into
-// separate requests. This avoids the case of a large import causing
-// oversized IPC messages.
-const int kNumBookmarksToSend = 100;
-const int kNumHistoryRowsToSend = 100;
-const int kNumFaviconsToSend = 100;
-}
-
-ProfileImportThread::ProfileImportThread()
- : bridge_(NULL),
- items_to_import_(0),
- importer_(NULL) {
- ChildProcess::current()->AddRefProcess(); // Balanced in Cleanup().
-}
-
-ProfileImportThread::~ProfileImportThread() {}
-
-bool ProfileImportThread::OnControlMessageReceived(const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(ProfileImportThread, msg)
- 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()
- return handled;
-}
-
-void ProfileImportThread::OnImportStart(
- const importer::SourceProfile& source_profile,
- uint16 items,
- const DictionaryValue& localized_strings) {
- bridge_ = new ExternalProcessImporterBridge(this, localized_strings);
- 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();
- Cleanup();
- }
- import_thread_->message_loop()->PostTask(
- FROM_HERE, NewRunnableMethod(importer_.get(),
- &Importer::StartImport,
- source_profile,
- items,
- bridge_));
-}
-
-void ProfileImportThread::OnImportCancel() {
- Cleanup();
-}
-
-void ProfileImportThread::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)
- NotifyEnded();
-}
-
-void ProfileImportThread::NotifyStarted() {
- Send(new ProfileImportProcessHostMsg_Import_Started());
-}
-
-void ProfileImportThread::NotifyItemStarted(importer::ImportItem item) {
- Send(new ProfileImportProcessHostMsg_ImportItem_Started(item));
-}
-
-void ProfileImportThread::NotifyItemEnded(importer::ImportItem item) {
- Send(new ProfileImportProcessHostMsg_ImportItem_Finished(item));
-}
-
-void ProfileImportThread::NotifyEnded() {
- Send(new ProfileImportProcessHostMsg_Import_Finished(true, ""));
- Cleanup();
-}
-
-void ProfileImportThread::NotifyHistoryImportReady(
- const std::vector<history::URLRow> &rows,
- history::VisitSource visit_source) {
- Send(new ProfileImportProcessHostMsg_NotifyHistoryImportStart(rows.size()));
-
- std::vector<history::URLRow>::const_iterator it;
- for (it = rows.begin(); it < rows.end();
- it = it + kNumHistoryRowsToSend) {
- std::vector<history::URLRow> row_group;
- std::vector<history::URLRow>::const_iterator end_group =
- it + kNumHistoryRowsToSend < rows.end() ?
- it + kNumHistoryRowsToSend : rows.end();
- row_group.assign(it, end_group);
-
- Send(new ProfileImportProcessHostMsg_NotifyHistoryImportGroup(row_group,
- visit_source));
- }
-}
-
-void ProfileImportThread::NotifyHomePageImportReady(
- const GURL& home_page) {
- NOTIMPLEMENTED();
-}
-
-void ProfileImportThread::NotifyBookmarksImportReady(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks,
- const string16& first_folder_name) {
- Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart(
- first_folder_name, bookmarks.size()));
-
- std::vector<ProfileWriter::BookmarkEntry>::const_iterator it;
- for (it = bookmarks.begin(); it < bookmarks.end();
- it = it + kNumBookmarksToSend) {
- std::vector<ProfileWriter::BookmarkEntry> bookmark_group;
- std::vector<ProfileWriter::BookmarkEntry>::const_iterator end_group =
- it + kNumBookmarksToSend < bookmarks.end() ?
- it + kNumBookmarksToSend : bookmarks.end();
- bookmark_group.assign(it, end_group);
-
- Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportGroup(
- bookmark_group));
- }
-}
-
-void ProfileImportThread::NotifyFaviconsImportReady(
- const std::vector<history::ImportedFaviconUsage>& favicons) {
- Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportStart(
- favicons.size()));
-
- std::vector<history::ImportedFaviconUsage>::const_iterator it;
- for (it = favicons.begin(); it < favicons.end();
- it = it + kNumFaviconsToSend) {
- std::vector<history::ImportedFaviconUsage> favicons_group;
- std::vector<history::ImportedFaviconUsage>::const_iterator end_group =
- std::min(it + kNumFaviconsToSend, favicons.end());
- favicons_group.assign(it, end_group);
-
- Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportGroup(
- favicons_group));
- }
-}
-
-void ProfileImportThread::NotifyPasswordFormReady(
- const webkit_glue::PasswordForm& form) {
- Send(new ProfileImportProcessHostMsg_NotifyPasswordFormReady(form));
-}
-
-void ProfileImportThread::NotifyKeywordsReady(
- const std::vector<TemplateURL*>& template_urls,
- int default_keyword_index, bool unique_on_host_and_path) {
- std::vector<TemplateURL> urls;
- for (size_t i = 0; i < template_urls.size(); ++i) {
- urls.push_back(*template_urls[i]);
- }
- Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls,
- default_keyword_index, unique_on_host_and_path));
-}
-
-void ProfileImportThread::Cleanup() {
- importer_->Cancel();
- importer_ = NULL;
- bridge_ = NULL;
- ChildProcess::current()->ReleaseProcess();
-}
diff --git a/chrome/profile_import/profile_import_thread.h b/chrome/profile_import/profile_import_thread.h
deleted file mode 100644
index b689ed4..0000000
--- a/chrome/profile_import/profile_import_thread.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_
-#define CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_
-#pragma once
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/string16.h"
-#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "chrome/browser/importer/profile_writer.h"
-#include "content/common/child_thread.h"
-#include "webkit/glue/password_form.h"
-
-class ExternalProcessImporterBridge;
-class GURL;
-class Importer;
-class TemplateURL;
-
-namespace base {
-class DictionaryValue;
-class Thread;
-}
-
-namespace IPC {
-class Message;
-}
-
-// This class represents the background thread which communicates with the
-// importer work thread in the importer process.
-class ProfileImportThread : public ChildThread {
- public:
- ProfileImportThread();
- virtual ~ProfileImportThread();
-
- // Returns the one profile import thread.
- static ProfileImportThread* current() {
- return static_cast<ProfileImportThread*>(ChildThread::current());
- }
-
- // Bridging methods, called from importer_bridge tasks posted here.
- void NotifyStarted();
- void NotifyItemStarted(importer::ImportItem item);
- void NotifyItemEnded(importer::ImportItem item);
- void NotifyEnded();
-
- // Bridging methods that move data back across the process boundary.
- void NotifyHistoryImportReady(const std::vector<history::URLRow>& rows,
- history::VisitSource visit_source);
- void NotifyHomePageImportReady(const GURL& home_page);
- void NotifyBookmarksImportReady(
- const std::vector<ProfileWriter::BookmarkEntry>& bookmarks,
- const string16& first_folder_name);
- void NotifyFaviconsImportReady(
- const std::vector<history::ImportedFaviconUsage>& favicons);
- void NotifyPasswordFormReady(const webkit_glue::PasswordForm& form);
- void NotifyKeywordsReady(const std::vector<TemplateURL*>& template_urls,
- int default_keyword_index,
- bool unique_on_host_and_path);
-
- private:
- // IPC messages
- virtual bool OnControlMessageReceived(const IPC::Message& msg);
-
- // Creates the importer and launches it in a new thread. Import is run on
- // a separate thread so that this thread can receive messages from the
- // main process (especially cancel requests) while the worker thread handles
- // the actual import.
- void OnImportStart(
- const importer::SourceProfile& source_profile,
- uint16 items,
- const base::DictionaryValue& localized_strings);
-
- // Calls cleanup to stop the import operation.
- void OnImportCancel();
-
- // Called from the main process to notify that an item has been received
- // from the import process.
- void OnImportItemFinished(uint16 item);
-
- // Release the process and ourselves.
- void Cleanup();
-
- // Thread that importer runs on, while ProfileImportThread handles messages
- // from the browser process.
- scoped_ptr<base::Thread> import_thread_;
-
- // Bridge object is passed to importer, so that it can send IPC calls
- // directly back to the ProfileImportProcessHost.
- scoped_refptr<ExternalProcessImporterBridge> bridge_;
-
- // A bitmask of importer::ImportItem.
- uint16 items_to_import_;
-
- // Importer of the appropriate type (Firefox, Safari, IE, etc.)
- scoped_refptr<Importer> importer_;
-
- DISALLOW_COPY_AND_ASSIGN(ProfileImportThread);
-};
-
-#endif // CHROME_PROFILE_IMPORT_PROFILE_IMPORT_THREAD_H_
diff --git a/chrome/utility/DEPS b/chrome/utility/DEPS
index cdb1b38f..0a16cec 100644
--- a/chrome/utility/DEPS
+++ b/chrome/utility/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+chrome/browser", # For out of process profile import.
"+content/utility",
"+webkit/glue",
]
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 8beb181..a939f82 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -7,6 +7,10 @@
#include "base/base64.h"
#include "base/command_line.h"
#include "base/json/json_reader.h"
+#include "base/threading/thread.h"
+#include "chrome/browser/importer/external_process_importer_bridge.h"
+#include "chrome/browser/importer/importer.h"
+#include "chrome/browser/importer/profile_import_process_messages.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/extensions/extension_l10n_util.h"
@@ -35,7 +39,7 @@
namespace chrome {
-ChromeContentUtilityClient::ChromeContentUtilityClient() {
+ChromeContentUtilityClient::ChromeContentUtilityClient() : items_to_import_(0) {
}
ChromeContentUtilityClient::~ChromeContentUtilityClient() {
@@ -75,6 +79,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()
return handled;
@@ -356,4 +366,55 @@ void ChromeContentUtilityClient::OnGetPrinterCapsAndDefaults(
UtilityThread::current()->ReleaseProcessIfNeeded();
}
+void ChromeContentUtilityClient::OnImportStart(
+ const importer::SourceProfile& source_profile,
+ uint16 items,
+ const DictionaryValue& localized_strings) {
+ bridge_ = new ExternalProcessImporterBridge(localized_strings);
+ 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, NewRunnableMethod(importer_.get(),
+ &Importer::StartImport,
+ 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();
+ UtilityThread::current()->ReleaseProcessIfNeeded();
+}
+
} // namespace chrome
diff --git a/chrome/utility/chrome_content_utility_client.h b/chrome/utility/chrome_content_utility_client.h
index 47d6158..b1ef6c3 100644
--- a/chrome/utility/chrome_content_utility_client.h
+++ b/chrome/utility/chrome_content_utility_client.h
@@ -7,15 +7,28 @@
#pragma once
#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/platform_file.h"
#include "content/utility/content_utility_client.h"
+class ExternalProcessImporterBridge;
class FilePath;
+class Importer;
+
+namespace base {
+class DictionaryValue;
+class Thread;
+}
namespace gfx {
class Rect;
}
+namespace importer {
+struct SourceProfile;
+}
+
namespace printing {
struct PageRange;
}
@@ -60,6 +73,30 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {
#endif // defined(OS_WIN)
void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
+
+ void OnImportStart(
+ const importer::SourceProfile& source_profile,
+ uint16 items,
+ const base::DictionaryValue& localized_strings);
+ void OnImportCancel();
+ void OnImportItemFinished(uint16 item);
+
+ // The following are used with out of process profile import:
+ void ImporterCleanup();
+
+ // Thread that importer runs on, while ProfileImportThread handles messages
+ // from the browser process.
+ scoped_ptr<base::Thread> import_thread_;
+
+ // Bridge object is passed to importer, so that it can send IPC calls
+ // directly back to the ProfileImportProcessHost.
+ scoped_refptr<ExternalProcessImporterBridge> bridge_;
+
+ // A bitmask of importer::ImportItem.
+ uint16 items_to_import_;
+
+ // Importer of the appropriate type (Firefox, Safari, IE, etc.)
+ scoped_refptr<Importer> importer_;
};
} // namespace chrome
diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc
index d7f57f3..999e477 100644
--- a/content/browser/utility_process_host.cc
+++ b/content/browser/utility_process_host.cc
@@ -124,7 +124,7 @@ bool UtilityProcessHost::StartProcess() {
exposed_dir_,
#elif defined(OS_POSIX)
false,
- base::environment_vector(),
+ env_,
#endif
cmd_line);
diff --git a/content/browser/utility_process_host.h b/content/browser/utility_process_host.h
index 69389a2..52f4fff 100644
--- a/content/browser/utility_process_host.h
+++ b/content/browser/utility_process_host.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/process_util.h"
#include "content/browser/browser_child_process_host.h"
#include "content/browser/browser_thread.h"
#include "content/common/content_export.h"
@@ -62,10 +63,11 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost {
void EndBatchMode();
void set_exposed_dir(const FilePath& dir) { exposed_dir_ = dir; }
-
void set_no_sandbox(bool flag) { no_sandbox_ = flag; }
-
void set_child_flags(int flags) { child_flags_ = flags; }
+#if defined(OS_POSIX)
+ void set_env(const base::environment_vector& env) { env_ = env; }
+#endif
protected:
// Allow these methods to be overridden for tests.
@@ -100,6 +102,8 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost {
// Flags defined in ChildProcessHost with which to start the process.
int child_flags_;
+ base::environment_vector env_;
+
bool started_;
DISALLOW_COPY_AND_ASSIGN(UtilityProcessHost);
diff --git a/content/common/content_switches.cc b/content/common/content_switches.cc
index a6aa110..52d0362 100644
--- a/content/common/content_switches.cc
+++ b/content/common/content_switches.cc
@@ -405,9 +405,6 @@ const char kRecordMode[] = "record-mode";
// renderer or plugin host. If it's empty, it's the browser.
const char kProcessType[] = "type";
-// Causes the process to run as a profile import subprocess.
-const char kProfileImportProcess[] = "profile-import";
-
// Register Pepper plugins (see pepper_plugin_registry.cc for its format).
const char kRegisterPepperPlugins[] = "register-pepper-plugins";
diff --git a/content/common/content_switches.h b/content/common/content_switches.h
index 41385d1..26b5e05 100644
--- a/content/common/content_switches.h
+++ b/content/common/content_switches.h
@@ -130,8 +130,6 @@ extern const char kPpapiStartupDialog[];
extern const char kProcessPerSite[];
CONTENT_EXPORT extern const char kProcessPerTab[];
CONTENT_EXPORT extern const char kProcessType[];
-// TODO(jam): this doesn't belong in content.
-extern const char kProfileImportProcess[];
CONTENT_EXPORT extern const char kRecordMode[];
extern const char kRegisterPepperPlugins[];
CONTENT_EXPORT extern const char kRemoteShellPort[];
diff --git a/content/common/sandbox_init_wrapper_mac.cc b/content/common/sandbox_init_wrapper_mac.cc
index 31fb302..00c6f26 100644
--- a/content/common/sandbox_init_wrapper_mac.cc
+++ b/content/common/sandbox_init_wrapper_mac.cc
@@ -57,7 +57,6 @@ bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
} else if (process_type == switches::kGpuProcess) {
sandbox_process_type = Sandbox::SANDBOX_TYPE_GPU;
} else if ((process_type == switches::kPluginProcess) ||
- (process_type == switches::kProfileImportProcess) ||
(process_type == switches::kServiceProcess)) {
return true;
} else if (process_type == switches::kPpapiPluginProcess) {
diff --git a/content/common/sandbox_policy.cc b/content/common/sandbox_policy.cc
index 510d04d..8d5d37a 100644
--- a/content/common/sandbox_policy.cc
+++ b/content/common/sandbox_policy.cc
@@ -426,8 +426,9 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line,
VLOG(1) << "GPU sandbox is disabled";
}
- if (browser_command_line.HasSwitch(switches::kNoSandbox)) {
- // The user has explicity opted-out from all sandboxing.
+ if (browser_command_line.HasSwitch(switches::kNoSandbox) ||
+ cmd_line->HasSwitch(switches::kNoSandbox)) {
+ // The user or the caller has explicity opted-out from all sandboxing.
in_sandbox = false;
}