| 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/external_process_importer_bridge.h" | 5 #include "chrome/browser/importer/external_process_importer_bridge.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
| 12 #include "chrome/browser/importer/profile_import_process_messages.h" | 12 #include "chrome/browser/importer/profile_import_process_messages.h" |
| 13 #include "content/common/child_thread.h" | |
| 14 #include "webkit/glue/password_form.h" | 13 #include "webkit/glue/password_form.h" |
| 15 | 14 |
| 16 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 17 #include "chrome/browser/password_manager/ie7_password.h" | 16 #include "chrome/browser/password_manager/ie7_password.h" |
| 18 #endif | 17 #endif |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 // Rather than sending all import items over IPC at once we chunk them into | 20 // Rather than sending all import items over IPC at once we chunk them into |
| 22 // separate requests. This avoids the case of a large import causing | 21 // separate requests. This avoids the case of a large import causing |
| 23 // oversized IPC messages. | 22 // oversized IPC messages. |
| 24 const int kNumBookmarksToSend = 100; | 23 const int kNumBookmarksToSend = 100; |
| 25 const int kNumHistoryRowsToSend = 100; | 24 const int kNumHistoryRowsToSend = 100; |
| 26 const int kNumFaviconsToSend = 100; | 25 const int kNumFaviconsToSend = 100; |
| 27 } | 26 } |
| 28 | 27 |
| 29 ExternalProcessImporterBridge::ExternalProcessImporterBridge( | 28 ExternalProcessImporterBridge::ExternalProcessImporterBridge( |
| 30 const DictionaryValue& localized_strings) { | 29 const DictionaryValue& localized_strings, |
| 30 IPC::Message::Sender* sender) |
| 31 : sender_(sender) { |
| 31 // Bridge needs to make its own copy because OS 10.6 autoreleases the | 32 // Bridge needs to make its own copy because OS 10.6 autoreleases the |
| 32 // localized_strings value that is passed in (see http://crbug.com/46003 ). | 33 // localized_strings value that is passed in (see http://crbug.com/46003 ). |
| 33 localized_strings_.reset(localized_strings.DeepCopy()); | 34 localized_strings_.reset(localized_strings.DeepCopy()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void ExternalProcessImporterBridge::AddBookmarks( | 37 void ExternalProcessImporterBridge::AddBookmarks( |
| 37 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, | 38 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, |
| 38 const string16& first_folder_name) { | 39 const string16& first_folder_name) { |
| 39 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart( | 40 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart( |
| 40 first_folder_name, bookmarks.size())); | 41 first_folder_name, bookmarks.size())); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 138 |
| 138 string16 ExternalProcessImporterBridge::GetLocalizedString(int message_id) { | 139 string16 ExternalProcessImporterBridge::GetLocalizedString(int message_id) { |
| 139 string16 message; | 140 string16 message; |
| 140 localized_strings_->GetString(base::IntToString(message_id), &message); | 141 localized_strings_->GetString(base::IntToString(message_id), &message); |
| 141 return message; | 142 return message; |
| 142 } | 143 } |
| 143 | 144 |
| 144 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} | 145 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} |
| 145 | 146 |
| 146 bool ExternalProcessImporterBridge::Send(IPC::Message* message) { | 147 bool ExternalProcessImporterBridge::Send(IPC::Message* message) { |
| 147 return ChildThread::current()->Send(message); | 148 return sender_->Send(message); |
| 148 } | 149 } |
| OLD | NEW |