| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/profile_import_process_host.h" | 5 #include "chrome/browser/importer/profile_import_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS), | 22 : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS), |
| 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() { | 27 ProfileImportProcessHost::~ProfileImportProcessHost() { |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool ProfileImportProcessHost::StartProfileImportProcess( | 30 bool ProfileImportProcessHost::StartProfileImportProcess( |
| 31 const importer::SourceProfile& source_profile, | 31 const importer::SourceProfile& source_profile, |
| 32 uint16 items, | 32 uint16 items) { |
| 33 bool import_to_bookmark_bar) { | |
| 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 35 if (!StartProcess()) | 34 if (!StartProcess()) |
| 36 return false; | 35 return false; |
| 37 | 36 |
| 38 // 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 |
| 39 // in the external process. | 38 // in the external process. |
| 40 DictionaryValue localized_strings; | 39 DictionaryValue localized_strings; |
| 41 localized_strings.SetString( | 40 localized_strings.SetString( |
| 42 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), | 41 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), |
| 43 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); | 42 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); |
| 44 localized_strings.SetString( | 43 localized_strings.SetString( |
| 45 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), | 44 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), |
| 46 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); | 45 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); |
| 47 localized_strings.SetString( | 46 localized_strings.SetString( |
| 48 base::IntToString(IDS_IMPORT_FROM_FIREFOX), | 47 base::IntToString(IDS_IMPORT_FROM_FIREFOX), |
| 49 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); | 48 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); |
| 50 localized_strings.SetString( | 49 localized_strings.SetString( |
| 51 base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR), | 50 base::IntToString(IDS_IMPORT_FROM_GOOGLE_TOOLBAR), |
| 52 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR)); | 51 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_GOOGLE_TOOLBAR)); |
| 53 localized_strings.SetString( | 52 localized_strings.SetString( |
| 54 base::IntToString(IDS_IMPORT_FROM_SAFARI), | 53 base::IntToString(IDS_IMPORT_FROM_SAFARI), |
| 55 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); | 54 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); |
| 55 localized_strings.SetString( |
| 56 base::IntToString(IDS_BOOMARK_BAR_FOLDER_NAME), |
| 57 l10n_util::GetStringUTF8(IDS_BOOMARK_BAR_FOLDER_NAME)); |
| 56 | 58 |
| 57 Send(new ProfileImportProcessMsg_StartImport( | 59 Send(new ProfileImportProcessMsg_StartImport(source_profile, items, |
| 58 source_profile, items, localized_strings, import_to_bookmark_bar)); | 60 localized_strings)); |
| 59 return true; | 61 return true; |
| 60 } | 62 } |
| 61 | 63 |
| 62 bool ProfileImportProcessHost::CancelProfileImportProcess() { | 64 bool ProfileImportProcessHost::CancelProfileImportProcess() { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 64 Send(new ProfileImportProcessMsg_CancelImport()); | 66 Send(new ProfileImportProcessMsg_CancelImport()); |
| 65 return true; | 67 return true; |
| 66 } | 68 } |
| 67 | 69 |
| 68 bool ProfileImportProcessHost::ReportImportItemFinished( | 70 bool ProfileImportProcessHost::ReportImportItemFinished( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 BrowserThread::PostTask( | 134 BrowserThread::PostTask( |
| 133 thread_id_, FROM_HERE, | 135 thread_id_, FROM_HERE, |
| 134 NewRunnableMethod(import_process_client_.get(), | 136 NewRunnableMethod(import_process_client_.get(), |
| 135 &ProfileImportProcessClient::OnProcessCrashed, | 137 &ProfileImportProcessClient::OnProcessCrashed, |
| 136 exit_code)); | 138 exit_code)); |
| 137 } | 139 } |
| 138 | 140 |
| 139 bool ProfileImportProcessHost::CanShutdown() { | 141 bool ProfileImportProcessHost::CanShutdown() { |
| 140 return true; | 142 return true; |
| 141 } | 143 } |
| OLD | NEW |