| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profile_import_process_host.h" | 5 #include "chrome/browser/profile_import_process_host.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/importer/firefox_importer_utils.h" | 12 #include "chrome/browser/importer/firefox_importer_utils.h" |
| 13 #include "chrome/browser/importer/importer_messages.h" | 13 #include "chrome/browser/importer/importer_messages.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "ipc/ipc_switches.h" | 16 #include "ipc/ipc_switches.h" |
| 17 | 17 |
| 18 ProfileImportProcessHost::ProfileImportProcessHost( | 18 ProfileImportProcessHost::ProfileImportProcessHost( |
| 19 ResourceDispatcherHost* resource_dispatcher, | 19 ResourceDispatcherHost* resource_dispatcher, |
| 20 ImportProcessClient* import_process_client, | 20 ImportProcessClient* import_process_client, |
| 21 ChromeThread::ID thread_id) | 21 ChromeThread::ID thread_id) |
| 22 : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS, resource_dispatcher), | 22 : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS, resource_dispatcher), |
| 23 import_process_client_(import_process_client), | 23 import_process_client_(import_process_client), |
| 24 thread_id_(thread_id) { | 24 thread_id_(thread_id) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 ProfileImportProcessHost::~ProfileImportProcessHost() { |
| 28 } |
| 29 |
| 27 bool ProfileImportProcessHost::StartProfileImportProcess( | 30 bool ProfileImportProcessHost::StartProfileImportProcess( |
| 28 const importer::ProfileInfo& profile_info, int items, | 31 const importer::ProfileInfo& profile_info, int items, |
| 29 bool import_to_bookmark_bar) { | 32 bool import_to_bookmark_bar) { |
| 30 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 33 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 31 if (!StartProcess()) | 34 if (!StartProcess()) |
| 32 return false; | 35 return false; |
| 33 | 36 |
| 34 // Dictionary of all localized strings that could be needed by the importer | 37 // Dictionary of all localized strings that could be needed by the importer |
| 35 // in the external process. | 38 // in the external process. |
| 36 DictionaryValue localized_strings; | 39 DictionaryValue localized_strings; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 128 } |
| 126 | 129 |
| 127 void ProfileImportProcessHost::OnProcessCrashed() { | 130 void ProfileImportProcessHost::OnProcessCrashed() { |
| 128 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 131 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 129 ChromeThread::PostTask( | 132 ChromeThread::PostTask( |
| 130 thread_id_, FROM_HERE, | 133 thread_id_, FROM_HERE, |
| 131 NewRunnableMethod(import_process_client_.get(), | 134 NewRunnableMethod(import_process_client_.get(), |
| 132 &ImportProcessClient::OnProcessCrashed)); | 135 &ImportProcessClient::OnProcessCrashed)); |
| 133 } | 136 } |
| 134 | 137 |
| 138 bool ProfileImportProcessHost::CanShutdown() { |
| 139 return true; |
| 140 } |
| 141 |
| 142 URLRequestContext* ProfileImportProcessHost::GetRequestContext( |
| 143 uint32 request_id, |
| 144 const ViewHostMsg_Resource_Request& request_data) { |
| 145 return NULL; |
| 146 } |
| 147 |
| 148 ProfileImportProcessHost::ImportProcessClient::ImportProcessClient() {} |
| 149 |
| 150 ProfileImportProcessHost::ImportProcessClient::~ImportProcessClient() {} |
| 151 |
| 135 void ProfileImportProcessHost::ImportProcessClient::OnMessageReceived( | 152 void ProfileImportProcessHost::ImportProcessClient::OnMessageReceived( |
| 136 const IPC::Message& message) { | 153 const IPC::Message& message) { |
| 137 IPC_BEGIN_MESSAGE_MAP(ProfileImportProcessHost, message) | 154 IPC_BEGIN_MESSAGE_MAP(ProfileImportProcessHost, message) |
| 138 // Notification messages about the state of the import process. | 155 // Notification messages about the state of the import process. |
| 139 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started, | 156 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started, |
| 140 ImportProcessClient::OnImportStart) | 157 ImportProcessClient::OnImportStart) |
| 141 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished, | 158 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished, |
| 142 ImportProcessClient::OnImportFinished) | 159 ImportProcessClient::OnImportFinished) |
| 143 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started, | 160 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started, |
| 144 ImportProcessClient::OnImportItemStart) | 161 ImportProcessClient::OnImportItemStart) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 159 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFavIconsImportStart, | 176 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFavIconsImportStart, |
| 160 ImportProcessClient::OnFavIconsImportStart) | 177 ImportProcessClient::OnFavIconsImportStart) |
| 161 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFavIconsImportGroup, | 178 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFavIconsImportGroup, |
| 162 ImportProcessClient::OnFavIconsImportGroup) | 179 ImportProcessClient::OnFavIconsImportGroup) |
| 163 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady, | 180 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady, |
| 164 ImportProcessClient::OnPasswordFormImportReady) | 181 ImportProcessClient::OnPasswordFormImportReady) |
| 165 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady, | 182 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady, |
| 166 ImportProcessClient::OnKeywordsImportReady) | 183 ImportProcessClient::OnKeywordsImportReady) |
| 167 IPC_END_MESSAGE_MAP_EX() | 184 IPC_END_MESSAGE_MAP_EX() |
| 168 } | 185 } |
| OLD | NEW |