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> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 BrowserThread::ID thread_id; | 50 BrowserThread::ID thread_id; |
51 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); | 51 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id)); |
52 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
53 BrowserThread::IO, FROM_HERE, | 53 BrowserThread::IO, FROM_HERE, |
54 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, this, | 54 base::Bind(&ExternalProcessImporterClient::StartProcessOnIOThread, this, |
55 thread_id, base::Passed(std::move(request)))); | 55 thread_id, base::Passed(std::move(request)))); |
56 | 56 |
57 // Dictionary of all localized strings that could be needed by the importer | 57 // Dictionary of all localized strings that could be needed by the importer |
58 // in the external process. | 58 // in the external process. |
59 base::DictionaryValue localized_strings; | 59 auto localized_strings = base::MakeUnique<base::DictionaryValue>(); |
60 localized_strings.SetString(base::IntToString(IDS_BOOKMARK_GROUP), | 60 localized_strings->SetString(base::IntToString(IDS_BOOKMARK_GROUP), |
61 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)); | 61 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP)); |
62 localized_strings.SetString( | 62 localized_strings->SetString( |
63 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), | 63 base::IntToString(IDS_BOOKMARK_GROUP_FROM_FIREFOX), |
64 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); | 64 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_FIREFOX)); |
65 localized_strings.SetString( | 65 localized_strings->SetString( |
66 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), | 66 base::IntToString(IDS_BOOKMARK_GROUP_FROM_SAFARI), |
67 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); | 67 l10n_util::GetStringUTF8(IDS_BOOKMARK_GROUP_FROM_SAFARI)); |
68 localized_strings.SetString( | 68 localized_strings->SetString( |
69 base::IntToString(IDS_IMPORT_FROM_FIREFOX), | 69 base::IntToString(IDS_IMPORT_FROM_FIREFOX), |
70 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); | 70 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_FIREFOX)); |
71 localized_strings.SetString( | 71 localized_strings->SetString( |
72 base::IntToString(IDS_IMPORT_FROM_ICEWEASEL), | 72 base::IntToString(IDS_IMPORT_FROM_ICEWEASEL), |
73 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)); | 73 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_ICEWEASEL)); |
74 localized_strings.SetString(base::IntToString(IDS_IMPORT_FROM_SAFARI), | 74 localized_strings->SetString( |
75 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); | 75 base::IntToString(IDS_IMPORT_FROM_SAFARI), |
76 localized_strings.SetString( | 76 l10n_util::GetStringUTF8(IDS_IMPORT_FROM_SAFARI)); |
| 77 localized_strings->SetString( |
77 base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), | 78 base::IntToString(IDS_BOOKMARK_BAR_FOLDER_NAME), |
78 l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); | 79 l10n_util::GetStringUTF8(IDS_BOOKMARK_BAR_FOLDER_NAME)); |
79 | 80 |
80 // If the utility process hasn't started yet the message will queue until it | 81 // If the utility process hasn't started yet the message will queue until it |
81 // does. | 82 // does. |
82 auto observer_ptr = binding_.CreateInterfacePtrAndBind(); | 83 auto observer_ptr = binding_.CreateInterfacePtrAndBind(); |
83 profile_import_->StartImport(source_profile_, items_, localized_strings, | 84 profile_import_->StartImport(source_profile_, items_, |
| 85 std::move(localized_strings), |
84 std::move(observer_ptr)); | 86 std::move(observer_ptr)); |
85 } | 87 } |
86 | 88 |
87 void ExternalProcessImporterClient::Cancel() { | 89 void ExternalProcessImporterClient::Cancel() { |
88 if (cancelled_) | 90 if (cancelled_) |
89 return; | 91 return; |
90 | 92 |
91 cancelled_ = true; | 93 cancelled_ = true; |
92 if (utility_process_host_) | 94 if (utility_process_host_) |
93 profile_import_->CancelImport(); | 95 profile_import_->CancelImport(); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 utility_process_host_->Start(); | 311 utility_process_host_->Start(); |
310 chrome::mojom::ProfileImportPtr profile_import; | 312 chrome::mojom::ProfileImportPtr profile_import; |
311 utility_process_host_->GetRemoteInterfaces()->GetInterface( | 313 utility_process_host_->GetRemoteInterfaces()->GetInterface( |
312 std::move(request)); | 314 std::move(request)); |
313 } | 315 } |
314 | 316 |
315 void ExternalProcessImporterClient::CloseMojoHandles() { | 317 void ExternalProcessImporterClient::CloseMojoHandles() { |
316 profile_import_.reset(); | 318 profile_import_.reset(); |
317 binding_.Close(); | 319 binding_.Close(); |
318 } | 320 } |
OLD | NEW |