| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/importer/external_process_importer_client.h" | 5 #include "chrome/browser/importer/external_process_importer_client.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 9 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/importer/external_process_importer_host.h" | 13 #include "chrome/browser/importer/external_process_importer_host.h" |
| 12 #include "chrome/browser/importer/in_process_importer_bridge.h" | 14 #include "chrome/browser/importer/in_process_importer_bridge.h" |
| 13 #include "chrome/common/importer/firefox_importer_utils.h" | 15 #include "chrome/common/importer/firefox_importer_utils.h" |
| 14 #include "chrome/common/importer/imported_bookmark_entry.h" | 16 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 15 #include "chrome/common/importer/profile_import_process_messages.h" | |
| 16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 17 #include "components/strings/grit/components_strings.h" | 18 #include "components/strings/grit/components_strings.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/utility_process_host.h" | 20 #include "content/public/browser/utility_process_host.h" |
| 21 #include "services/service_manager/public/cpp/interface_provider.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 21 | 23 |
| 22 using content::BrowserThread; | 24 using content::BrowserThread; |
| 23 using content::UtilityProcessHost; | 25 using content::UtilityProcessHost; |
| 24 | 26 |
| 25 ExternalProcessImporterClient::ExternalProcessImporterClient( | 27 ExternalProcessImporterClient::ExternalProcessImporterClient( |
| 26 base::WeakPtr<ExternalProcessImporterHost> importer_host, | 28 base::WeakPtr<ExternalProcessImporterHost> importer_host, |
| 27 const importer::SourceProfile& source_profile, | 29 const importer::SourceProfile& source_profile, |
| 28 uint16_t items, | 30 uint16_t items, |
| 29 InProcessImporterBridge* bridge) | 31 InProcessImporterBridge* bridge) |
| 30 : total_bookmarks_count_(0), | 32 : total_bookmarks_count_(0), |
| 31 total_history_rows_count_(0), | 33 total_history_rows_count_(0), |
| 32 total_favicons_count_(0), | 34 total_favicons_count_(0), |
| 33 process_importer_host_(importer_host), | 35 process_importer_host_(importer_host), |
| 34 source_profile_(source_profile), | 36 source_profile_(source_profile), |
| 35 items_(items), | 37 items_(items), |
| 36 bridge_(bridge), | 38 bridge_(bridge), |
| 37 cancelled_(false) { | 39 cancelled_(false), |
| 40 binding_(this) { |
| 38 process_importer_host_->NotifyImportStarted(); | 41 process_importer_host_->NotifyImportStarted(); |
| 39 } | 42 } |
| 40 | 43 |
| 41 void ExternalProcessImporterClient::Start() { | 44 void ExternalProcessImporterClient::Start() { |
| 42 AddRef(); // balanced in Cleanup. | 45 AddRef(); // balanced in Cleanup. |
| 46 |
| 47 chrome::mojom::ProfileImportRequest request = |
| 48 mojo::GetProxy(&profile_import_); |
| 49 |
| 43 BrowserThread::ID thread_id; | 50 BrowserThread::ID thread_id; |
| 44 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); | 51 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); |
| 45 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 46 BrowserThread::IO, FROM_HERE, | 53 BrowserThread::IO, FROM_HERE, |
| 47 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, | 54 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, this, |
| 48 this, | 55 thread_id, base::Passed(std::move(request)))); |
| 49 thread_id)); | 56 |
| 57 // Dictionary of all localized strings that could be needed by the importer |
| 58 // in the external process. |
| 59 base::DictionaryValue localized_strings; |
| 60 localized_strings.SetString(base::IntToString(IDS_BOOKMARK_GROUP), |
| 61 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)); |
| 62 localized_strings.SetString( |
| 63 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), |
| 64 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); |
| 65 localized_strings.SetString( |
| 66 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), |
| 67 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); |
| 68 localized_strings.SetString( |
| 69 base::IntToString(IDS_IMPORT_FROM_FIREFOX), |
| 70 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); |
| 71 localized_strings.SetString( |
| 72 base::IntToString(IDS_IMPORT_FROM_ICEWEASEL), |
| 73 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)); |
| 74 localized_strings.SetString(base::IntToString(IDS_IMPORT_FROM_SAFARI), |
| 75 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); |
| 76 localized_strings.SetString( |
| 77 base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), |
| 78 l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); |
| 79 |
| 80 // If the utility process hasn't started yet the message will queue until it |
| 81 // does. |
| 82 auto observer_ptr = binding_.CreateInterfacePtrAndBind(); |
| 83 profile_import_->StartImport(source_profile_, items_, localized_strings, |
| 84 std::move(observer_ptr)); |
| 50 } | 85 } |
| 51 | 86 |
| 52 void ExternalProcessImporterClient::Cancel() { | 87 void ExternalProcessImporterClient::Cancel() { |
| 53 if (cancelled_) | 88 if (cancelled_) |
| 54 return; | 89 return; |
| 55 | 90 |
| 56 cancelled_ = true; | 91 cancelled_ = true; |
| 57 BrowserThread::PostTask( | 92 if (utility_process_host_) |
| 58 BrowserThread::IO, FROM_HERE, | 93 profile_import_->CancelImport(); |
| 59 base::Bind( | 94 CloseMojoHandles(); |
| 60 &ExternalProcessImporterClient::CancelImportProcessOnIOThread, | |
| 61 this)); | |
| 62 Release(); | 95 Release(); |
| 63 } | 96 } |
| 64 | 97 |
| 65 void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) { | 98 void ExternalProcessImporterClient::OnProcessCrashed(int exit_code) { |
| 66 DLOG(ERROR) << __func__; | 99 DLOG(ERROR) << __func__; |
| 67 if (cancelled_) | 100 if (cancelled_) |
| 68 return; | 101 return; |
| 69 | 102 |
| 70 // If the host is still around, cancel the import; otherwise it means the | 103 // If the host is still around, cancel the import; otherwise it means the |
| 71 // import was already cancelled or completed and this message can be dropped. | 104 // import was already cancelled or completed and this message can be dropped. |
| 72 if (process_importer_host_.get()) | 105 if (process_importer_host_.get()) |
| 73 process_importer_host_->Cancel(); | 106 process_importer_host_->Cancel(); |
| 74 } | 107 } |
| 75 | 108 |
| 76 bool ExternalProcessImporterClient::OnMessageReceived( | 109 bool ExternalProcessImporterClient::OnMessageReceived( |
| 77 const IPC::Message& message) { | 110 const IPC::Message& message) { |
| 78 bool handled = true; | 111 return false; |
| 79 IPC_BEGIN_MESSAGE_MAP(ExternalProcessImporterClient, message) | |
| 80 // Notification messages about the state of the import process. | |
| 81 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Started, | |
| 82 OnImportStart) | |
| 83 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_Import_Finished, | |
| 84 OnImportFinished) | |
| 85 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Started, | |
| 86 OnImportItemStart) | |
| 87 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_ImportItem_Finished, | |
| 88 OnImportItemFinished) | |
| 89 // Data messages containing items to be written to the user profile. | |
| 90 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportStart, | |
| 91 OnHistoryImportStart) | |
| 92 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, | |
| 93 OnHistoryImportGroup) | |
| 94 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyHomePageImportReady, | |
| 95 OnHomePageImportReady) | |
| 96 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportStart, | |
| 97 OnBookmarksImportStart) | |
| 98 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup, | |
| 99 OnBookmarksImportGroup) | |
| 100 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportStart, | |
| 101 OnFaviconsImportStart) | |
| 102 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup, | |
| 103 OnFaviconsImportGroup) | |
| 104 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyPasswordFormReady, | |
| 105 OnPasswordFormImportReady) | |
| 106 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyKeywordsReady, | |
| 107 OnKeywordsImportReady) | |
| 108 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData, | |
| 109 OnFirefoxSearchEngineDataReceived) | |
| 110 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_AutofillFormDataImportStart, | |
| 111 OnAutofillFormDataImportStart) | |
| 112 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_AutofillFormDataImportGroup, | |
| 113 OnAutofillFormDataImportGroup) | |
| 114 #if defined(OS_WIN) | |
| 115 IPC_MESSAGE_HANDLER(ProfileImportProcessHostMsg_NotifyIE7PasswordInfo, | |
| 116 OnIE7PasswordReceived) | |
| 117 #endif | |
| 118 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 119 IPC_END_MESSAGE_MAP() | |
| 120 return handled; | |
| 121 } | 112 } |
| 122 | 113 |
| 123 void ExternalProcessImporterClient::OnImportStart() { | 114 void ExternalProcessImporterClient::OnImportStart() { |
| 124 if (cancelled_) | 115 if (cancelled_) |
| 125 return; | 116 return; |
| 126 | 117 |
| 127 bridge_->NotifyStarted(); | 118 bridge_->NotifyStarted(); |
| 128 } | 119 } |
| 129 | 120 |
| 130 void ExternalProcessImporterClient::OnImportFinished( | 121 void ExternalProcessImporterClient::OnImportFinished( |
| 131 bool succeeded, const std::string& error_msg) { | 122 bool succeeded, const std::string& error_msg) { |
| 132 if (cancelled_) | 123 if (cancelled_) |
| 133 return; | 124 return; |
| 134 | 125 |
| 135 if (!succeeded) | 126 if (!succeeded) |
| 136 LOG(WARNING) << "Import failed. Error: " << error_msg; | 127 LOG(WARNING) << "Import failed. Error: " << error_msg; |
| 137 Cleanup(); | 128 Cleanup(); |
| 138 } | 129 } |
| 139 | 130 |
| 140 void ExternalProcessImporterClient::OnImportItemStart(int item_data) { | 131 void ExternalProcessImporterClient::OnImportItemStart( |
| 132 importer::ImportItem import_item) { |
| 141 if (cancelled_) | 133 if (cancelled_) |
| 142 return; | 134 return; |
| 143 | 135 |
| 144 bridge_->NotifyItemStarted(static_cast<importer::ImportItem>(item_data)); | 136 bridge_->NotifyItemStarted(import_item); |
| 145 } | 137 } |
| 146 | 138 |
| 147 void ExternalProcessImporterClient::OnImportItemFinished(int item_data) { | 139 void ExternalProcessImporterClient::OnImportItemFinished( |
| 140 importer::ImportItem import_item) { |
| 148 if (cancelled_) | 141 if (cancelled_) |
| 149 return; | 142 return; |
| 150 | 143 |
| 151 importer::ImportItem import_item = | |
| 152 static_cast<importer::ImportItem>(item_data); | |
| 153 bridge_->NotifyItemEnded(import_item); | 144 bridge_->NotifyItemEnded(import_item); |
| 154 BrowserThread::PostTask( | 145 profile_import_->ReportImportItemFinished(import_item); |
| 155 BrowserThread::IO, FROM_HERE, | |
| 156 base::Bind(&ExternalProcessImporterClient::NotifyItemFinishedOnIOThread, | |
| 157 this, | |
| 158 import_item)); | |
| 159 } | 146 } |
| 160 | 147 |
| 161 void ExternalProcessImporterClient::OnHistoryImportStart( | 148 void ExternalProcessImporterClient::OnHistoryImportStart( |
| 162 size_t total_history_rows_count) { | 149 uint32_t total_history_rows_count) { |
| 163 if (cancelled_) | 150 if (cancelled_) |
| 164 return; | 151 return; |
| 165 | 152 |
| 166 total_history_rows_count_ = total_history_rows_count; | 153 total_history_rows_count_ = total_history_rows_count; |
| 167 history_rows_.reserve(total_history_rows_count); | 154 history_rows_.reserve(total_history_rows_count); |
| 168 } | 155 } |
| 169 | 156 |
| 170 void ExternalProcessImporterClient::OnHistoryImportGroup( | 157 void ExternalProcessImporterClient::OnHistoryImportGroup( |
| 171 const std::vector<ImporterURLRow>& history_rows_group, | 158 const std::vector<ImporterURLRow>& history_rows_group, |
| 172 int visit_source) { | 159 int visit_source) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 void ExternalProcessImporterClient::OnHomePageImportReady( | 170 void ExternalProcessImporterClient::OnHomePageImportReady( |
| 184 const GURL& home_page) { | 171 const GURL& home_page) { |
| 185 if (cancelled_) | 172 if (cancelled_) |
| 186 return; | 173 return; |
| 187 | 174 |
| 188 bridge_->AddHomePage(home_page); | 175 bridge_->AddHomePage(home_page); |
| 189 } | 176 } |
| 190 | 177 |
| 191 void ExternalProcessImporterClient::OnBookmarksImportStart( | 178 void ExternalProcessImporterClient::OnBookmarksImportStart( |
| 192 const base::string16& first_folder_name, | 179 const base::string16& first_folder_name, |
| 193 size_t total_bookmarks_count) { | 180 uint32_t total_bookmarks_count) { |
| 194 if (cancelled_) | 181 if (cancelled_) |
| 195 return; | 182 return; |
| 196 | 183 |
| 197 bookmarks_first_folder_name_ = first_folder_name; | 184 bookmarks_first_folder_name_ = first_folder_name; |
| 198 total_bookmarks_count_ = total_bookmarks_count; | 185 total_bookmarks_count_ = total_bookmarks_count; |
| 199 bookmarks_.reserve(total_bookmarks_count); | 186 bookmarks_.reserve(total_bookmarks_count); |
| 200 } | 187 } |
| 201 | 188 |
| 202 void ExternalProcessImporterClient::OnBookmarksImportGroup( | 189 void ExternalProcessImporterClient::OnBookmarksImportGroup( |
| 203 const std::vector<ImportedBookmarkEntry>& bookmarks_group) { | 190 const std::vector<ImportedBookmarkEntry>& bookmarks_group) { |
| 204 if (cancelled_) | 191 if (cancelled_) |
| 205 return; | 192 return; |
| 206 | 193 |
| 207 // Collect sets of bookmarks from importer process until we have reached | 194 // Collect sets of bookmarks from importer process until we have reached |
| 208 // total_bookmarks_count_: | 195 // total_bookmarks_count_: |
| 209 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(), | 196 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(), |
| 210 bookmarks_group.end()); | 197 bookmarks_group.end()); |
| 211 if (bookmarks_.size() >= total_bookmarks_count_) | 198 if (bookmarks_.size() >= total_bookmarks_count_) |
| 212 bridge_->AddBookmarks(bookmarks_, bookmarks_first_folder_name_); | 199 bridge_->AddBookmarks(bookmarks_, bookmarks_first_folder_name_); |
| 213 } | 200 } |
| 214 | 201 |
| 215 void ExternalProcessImporterClient::OnFaviconsImportStart( | 202 void ExternalProcessImporterClient::OnFaviconsImportStart( |
| 216 size_t total_favicons_count) { | 203 uint32_t total_favicons_count) { |
| 217 if (cancelled_) | 204 if (cancelled_) |
| 218 return; | 205 return; |
| 219 | 206 |
| 220 total_favicons_count_ = total_favicons_count; | 207 total_favicons_count_ = total_favicons_count; |
| 221 favicons_.reserve(total_favicons_count); | 208 favicons_.reserve(total_favicons_count); |
| 222 } | 209 } |
| 223 | 210 |
| 224 void ExternalProcessImporterClient::OnFaviconsImportGroup( | 211 void ExternalProcessImporterClient::OnFaviconsImportGroup( |
| 225 const favicon_base::FaviconUsageDataList& favicons_group) { | 212 const favicon_base::FaviconUsageDataList& favicons_group) { |
| 226 if (cancelled_) | 213 if (cancelled_) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 242 | 229 |
| 243 void ExternalProcessImporterClient::OnKeywordsImportReady( | 230 void ExternalProcessImporterClient::OnKeywordsImportReady( |
| 244 const std::vector<importer::SearchEngineInfo>& search_engines, | 231 const std::vector<importer::SearchEngineInfo>& search_engines, |
| 245 bool unique_on_host_and_path) { | 232 bool unique_on_host_and_path) { |
| 246 if (cancelled_) | 233 if (cancelled_) |
| 247 return; | 234 return; |
| 248 bridge_->SetKeywords(search_engines, unique_on_host_and_path); | 235 bridge_->SetKeywords(search_engines, unique_on_host_and_path); |
| 249 } | 236 } |
| 250 | 237 |
| 251 void ExternalProcessImporterClient::OnFirefoxSearchEngineDataReceived( | 238 void ExternalProcessImporterClient::OnFirefoxSearchEngineDataReceived( |
| 252 const std::vector<std::string> search_engine_data) { | 239 const std::vector<std::string>& search_engine_data) { |
| 253 if (cancelled_) | 240 if (cancelled_) |
| 254 return; | 241 return; |
| 255 bridge_->SetFirefoxSearchEnginesXMLData(search_engine_data); | 242 bridge_->SetFirefoxSearchEnginesXMLData(search_engine_data); |
| 256 } | 243 } |
| 257 | 244 |
| 258 void ExternalProcessImporterClient::OnAutofillFormDataImportStart( | 245 void ExternalProcessImporterClient::OnAutofillFormDataImportStart( |
| 259 size_t total_autofill_form_data_entry_count) { | 246 uint32_t total_autofill_form_data_entry_count) { |
| 260 if (cancelled_) | 247 if (cancelled_) |
| 261 return; | 248 return; |
| 262 | 249 |
| 263 total_autofill_form_data_entry_count_ = total_autofill_form_data_entry_count; | 250 total_autofill_form_data_entry_count_ = total_autofill_form_data_entry_count; |
| 264 autofill_form_data_.reserve(total_autofill_form_data_entry_count); | 251 autofill_form_data_.reserve(total_autofill_form_data_entry_count); |
| 265 } | 252 } |
| 266 | 253 |
| 267 void ExternalProcessImporterClient::OnAutofillFormDataImportGroup( | 254 void ExternalProcessImporterClient::OnAutofillFormDataImportGroup( |
| 268 const std::vector<ImporterAutofillFormDataEntry>& | 255 const std::vector<ImporterAutofillFormDataEntry>& |
| 269 autofill_form_data_entry_group) { | 256 autofill_form_data_entry_group) { |
| 270 if (cancelled_) | 257 if (cancelled_) |
| 271 return; | 258 return; |
| 272 | 259 |
| 273 autofill_form_data_.insert(autofill_form_data_.end(), | 260 autofill_form_data_.insert(autofill_form_data_.end(), |
| 274 autofill_form_data_entry_group.begin(), | 261 autofill_form_data_entry_group.begin(), |
| 275 autofill_form_data_entry_group.end()); | 262 autofill_form_data_entry_group.end()); |
| 276 if (autofill_form_data_.size() >= total_autofill_form_data_entry_count_) | 263 if (autofill_form_data_.size() >= total_autofill_form_data_entry_count_) |
| 277 bridge_->SetAutofillFormData(autofill_form_data_); | 264 bridge_->SetAutofillFormData(autofill_form_data_); |
| 278 } | 265 } |
| 279 | 266 |
| 280 #if defined(OS_WIN) | |
| 281 void ExternalProcessImporterClient::OnIE7PasswordReceived( | 267 void ExternalProcessImporterClient::OnIE7PasswordReceived( |
| 282 const importer::ImporterIE7PasswordInfo& importer_password_info) { | 268 const importer::ImporterIE7PasswordInfo& importer_password_info) { |
| 269 #if defined(OS_WIN) |
| 283 if (cancelled_) | 270 if (cancelled_) |
| 284 return; | 271 return; |
| 285 bridge_->AddIE7PasswordInfo(importer_password_info); | 272 bridge_->AddIE7PasswordInfo(importer_password_info); |
| 273 #else |
| 274 NOTREACHED(); |
| 275 #endif |
| 286 } | 276 } |
| 287 #endif | |
| 288 | 277 |
| 289 ExternalProcessImporterClient::~ExternalProcessImporterClient() {} | 278 ExternalProcessImporterClient::~ExternalProcessImporterClient() {} |
| 290 | 279 |
| 291 void ExternalProcessImporterClient::Cleanup() { | 280 void ExternalProcessImporterClient::Cleanup() { |
| 292 if (cancelled_) | 281 if (cancelled_) |
| 293 return; | 282 return; |
| 294 | 283 |
| 295 if (process_importer_host_.get()) | 284 if (process_importer_host_.get()) |
| 296 process_importer_host_->NotifyImportEnded(); | 285 process_importer_host_->NotifyImportEnded(); |
| 286 CloseMojoHandles(); |
| 297 Release(); | 287 Release(); |
| 298 } | 288 } |
| 299 | 289 |
| 300 void ExternalProcessImporterClient::CancelImportProcessOnIOThread() { | |
| 301 if (utility_process_host_.get()) | |
| 302 utility_process_host_->Send(new ProfileImportProcessMsg_CancelImport()); | |
| 303 } | |
| 304 | |
| 305 void ExternalProcessImporterClient::NotifyItemFinishedOnIOThread( | |
| 306 importer::ImportItem import_item) { | |
| 307 utility_process_host_->Send( | |
| 308 new ProfileImportProcessMsg_ReportImportItemFinished(import_item)); | |
| 309 } | |
| 310 | |
| 311 void ExternalProcessImporterClient::StartProcessOnIOThread( | 290 void ExternalProcessImporterClient::StartProcessOnIOThread( |
| 312 BrowserThread::ID thread_id) { | 291 BrowserThread::ID thread_id, |
| 292 chrome::mojom::ProfileImportRequest request) { |
| 313 utility_process_host_ = | 293 utility_process_host_ = |
| 314 UtilityProcessHost::Create( | 294 UtilityProcessHost::Create( |
| 315 this, BrowserThread::GetTaskRunnerForThread(thread_id).get()) | 295 this, BrowserThread::GetTaskRunnerForThread(thread_id).get()) |
| 316 ->AsWeakPtr(); | 296 ->AsWeakPtr(); |
| 317 utility_process_host_->SetName(l10n_util::GetStringUTF16( | 297 utility_process_host_->SetName(l10n_util::GetStringUTF16( |
| 318 IDS_UTILITY_PROCESS_PROFILE_IMPORTER_NAME)); | 298 IDS_UTILITY_PROCESS_PROFILE_IMPORTER_NAME)); |
| 319 utility_process_host_->DisableSandbox(); | 299 utility_process_host_->DisableSandbox(); |
| 320 | 300 |
| 321 #if defined(OS_MACOSX) | 301 #if defined(OS_MACOSX) |
| 322 base::EnvironmentMap env; | 302 base::EnvironmentMap env; |
| 323 std::string dylib_path = GetFirefoxDylibPath().value(); | 303 std::string dylib_path = GetFirefoxDylibPath().value(); |
| 324 if (!dylib_path.empty()) | 304 if (!dylib_path.empty()) |
| 325 env["DYLD_FALLBACK_LIBRARY_PATH"] = dylib_path; | 305 env["DYLD_FALLBACK_LIBRARY_PATH"] = dylib_path; |
| 326 utility_process_host_->SetEnv(env); | 306 utility_process_host_->SetEnv(env); |
| 327 #endif | 307 #endif |
| 328 | 308 |
| 329 // Dictionary of all localized strings that could be needed by the importer | 309 utility_process_host_->Start(); |
| 330 // in the external process. | 310 chrome::mojom::ProfileImportPtr profile_import; |
| 331 base::DictionaryValue localized_strings; | 311 utility_process_host_->GetRemoteInterfaces()->GetInterface( |
| 332 localized_strings.SetString( | 312 std::move(request)); |
| 333 base::IntToString(IDS_BOOKMARK_GROUP), | 313 } |
| 334 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)); | |
| 335 localized_strings.SetString( | |
| 336 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), | |
| 337 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); | |
| 338 localized_strings.SetString( | |
| 339 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), | |
| 340 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); | |
| 341 localized_strings.SetString( | |
| 342 base::IntToString(IDS_IMPORT_FROM_FIREFOX), | |
| 343 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); | |
| 344 localized_strings.SetString( | |
| 345 base::IntToString(IDS_IMPORT_FROM_ICEWEASEL), | |
| 346 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)); | |
| 347 localized_strings.SetString( | |
| 348 base::IntToString(IDS_IMPORT_FROM_SAFARI), | |
| 349 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); | |
| 350 localized_strings.SetString( | |
| 351 base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), | |
| 352 l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); | |
| 353 | 314 |
| 354 utility_process_host_->Send(new ProfileImportProcessMsg_StartImport( | 315 void ExternalProcessImporterClient::CloseMojoHandles() { |
| 355 source_profile_, items_, localized_strings)); | 316 profile_import_.reset(); |
| 317 binding_.Close(); |
| 356 } | 318 } |
| OLD | NEW |