| 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/importer/importer_bridge.h" | 5 #include "chrome/browser/importer/importer_bridge.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/chrome_thread.h" | 13 #include "chrome/browser/chrome_thread.h" |
| 14 #include "chrome/browser/history/history_types.h" | 14 #include "chrome/browser/history/history_types.h" |
| 15 #include "chrome/browser/importer/importer.h" | 15 #include "chrome/browser/importer/importer.h" |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include "chrome/browser/password_manager/ie7_password.h" | 17 #include "chrome/browser/password_manager/ie7_password.h" |
| 18 #endif | 18 #endif |
| 19 #include "chrome/common/child_thread.h" | 19 #include "chrome/common/child_thread.h" |
| 20 #include "chrome/browser/importer/importer_messages.h" | 20 #include "chrome/browser/importer/importer_messages.h" |
| 21 #include "chrome/profile_import/profile_import_thread.h" | 21 #include "chrome/profile_import/profile_import_thread.h" |
| 22 #include "webkit/glue/password_form.h" | 22 #include "webkit/glue/password_form.h" |
| 23 | 23 |
| 24 ImporterBridge::ImporterBridge() { } |
| 25 |
| 26 ImporterBridge::~ImporterBridge() { } |
| 27 |
| 24 InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer, | 28 InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer, |
| 25 ImporterHost* host) | 29 ImporterHost* host) |
| 26 : writer_(writer), host_(host) { | 30 : writer_(writer), host_(host) { |
| 27 } | 31 } |
| 28 | 32 |
| 29 void InProcessImporterBridge::AddBookmarkEntries( | 33 void InProcessImporterBridge::AddBookmarkEntries( |
| 30 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, | 34 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, |
| 31 const std::wstring& first_folder_name, | 35 const std::wstring& first_folder_name, |
| 32 int options) { | 36 int options) { |
| 33 ChromeThread::PostTask( | 37 ChromeThread::PostTask( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void InProcessImporterBridge::NotifyEnded() { | 113 void InProcessImporterBridge::NotifyEnded() { |
| 110 ChromeThread::PostTask( | 114 ChromeThread::PostTask( |
| 111 ChromeThread::UI, FROM_HERE, | 115 ChromeThread::UI, FROM_HERE, |
| 112 NewRunnableMethod(host_, &ImporterHost::ImportEnded)); | 116 NewRunnableMethod(host_, &ImporterHost::ImportEnded)); |
| 113 } | 117 } |
| 114 | 118 |
| 115 std::wstring InProcessImporterBridge::GetLocalizedString(int message_id) { | 119 std::wstring InProcessImporterBridge::GetLocalizedString(int message_id) { |
| 116 return l10n_util::GetString(message_id); | 120 return l10n_util::GetString(message_id); |
| 117 } | 121 } |
| 118 | 122 |
| 123 InProcessImporterBridge::~InProcessImporterBridge() {} |
| 124 |
| 119 ExternalProcessImporterBridge::ExternalProcessImporterBridge( | 125 ExternalProcessImporterBridge::ExternalProcessImporterBridge( |
| 120 ProfileImportThread* profile_import_thread, | 126 ProfileImportThread* profile_import_thread, |
| 121 const DictionaryValue& localized_strings) | 127 const DictionaryValue& localized_strings) |
| 122 : profile_import_thread_(profile_import_thread) { | 128 : profile_import_thread_(profile_import_thread) { |
| 123 // Bridge needs to make its own copy because OS 10.6 autoreleases the | 129 // Bridge needs to make its own copy because OS 10.6 autoreleases the |
| 124 // localized_strings value that is passed in (see http://crbug.com/46003 ). | 130 // localized_strings value that is passed in (see http://crbug.com/46003 ). |
| 125 localized_strings_.reset( | 131 localized_strings_.reset( |
| 126 static_cast<DictionaryValue*>(localized_strings.DeepCopy())); | 132 static_cast<DictionaryValue*>(localized_strings.DeepCopy())); |
| 127 } | 133 } |
| 128 | 134 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // The internal process detects import end when all items have been received. | 193 // The internal process detects import end when all items have been received. |
| 188 } | 194 } |
| 189 | 195 |
| 190 // TODO(viettrungluu): convert to string16. | 196 // TODO(viettrungluu): convert to string16. |
| 191 std::wstring ExternalProcessImporterBridge::GetLocalizedString( | 197 std::wstring ExternalProcessImporterBridge::GetLocalizedString( |
| 192 int message_id) { | 198 int message_id) { |
| 193 string16 message; | 199 string16 message; |
| 194 localized_strings_->GetString(base::IntToString(message_id), &message); | 200 localized_strings_->GetString(base::IntToString(message_id), &message); |
| 195 return UTF16ToWideHack(message); | 201 return UTF16ToWideHack(message); |
| 196 } | 202 } |
| 203 |
| 204 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} |
| OLD | NEW |