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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/importer/external_process_importer_bridge.h" 6 7 #include "base/logging.h" 8 #include "base/string_number_conversions.h" 9 #include "base/utf_string_conversions.h" 10 #include "base/values.h" 11 #include "chrome/browser/history/history_types.h" 12 #include "chrome/profile_import/profile_import_thread.h" 13 #include "webkit/glue/password_form.h" 14 15 #if defined(OS_WIN) 16 #include "chrome/browser/password_manager/ie7_password.h" 17 #endif 18 19 ExternalProcessImporterBridge::ExternalProcessImporterBridge( 20 ProfileImportThread* profile_import_thread, 21 const DictionaryValue& localized_strings) 22 : profile_import_thread_(profile_import_thread) { 23 // Bridge needs to make its own copy because OS 10.6 autoreleases the 24 // localized_strings value that is passed in (see http://crbug.com/46003 ). 25 localized_strings_.reset(localized_strings.DeepCopy()); 26 } 27 28 void ExternalProcessImporterBridge::AddBookmarkEntries( 29 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, 30 const string16& first_folder_name, 31 int options) { 32 profile_import_thread_->NotifyBookmarksImportReady( 33 bookmarks, first_folder_name, options); 34 } 35 36 void ExternalProcessImporterBridge::AddHomePage(const GURL& home_page) { 37 NOTIMPLEMENTED(); 38 } 39 40 #if defined(OS_WIN) 41 void ExternalProcessImporterBridge::AddIE7PasswordInfo( 42 const IE7PasswordInfo& password_info) { 43 NOTIMPLEMENTED(); 44 } 45 #endif 46 47 void ExternalProcessImporterBridge::SetFavicons( 48 const std::vector<history::ImportedFaviconUsage>& favicons) { 49 profile_import_thread_->NotifyFaviconsImportReady(favicons); 50 } 51 52 void ExternalProcessImporterBridge::SetHistoryItems( 53 const std::vector<history::URLRow>& rows, 54 history::VisitSource visit_source) { 55 profile_import_thread_->NotifyHistoryImportReady(rows, visit_source); 56 } 57 58 void ExternalProcessImporterBridge::SetKeywords( 59 const std::vector<TemplateURL*>& template_urls, 60 int default_keyword_index, 61 bool unique_on_host_and_path) { 62 profile_import_thread_->NotifyKeywordsReady( 63 template_urls, default_keyword_index, unique_on_host_and_path); 64 } 65 66 void ExternalProcessImporterBridge::SetPasswordForm( 67 const webkit_glue::PasswordForm& form) { 68 profile_import_thread_->NotifyPasswordFormReady(form); 69 } 70 71 void ExternalProcessImporterBridge::NotifyStarted() { 72 profile_import_thread_->NotifyStarted(); 73 } 74 75 void ExternalProcessImporterBridge::NotifyItemStarted( 76 importer::ImportItem item) { 77 profile_import_thread_->NotifyItemStarted(item); 78 } 79 80 void ExternalProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) { 81 profile_import_thread_->NotifyItemEnded(item); 82 } 83 84 void ExternalProcessImporterBridge::NotifyEnded() { 85 // The internal process detects import end when all items have been received. 86 } 87 88 string16 ExternalProcessImporterBridge::GetLocalizedString(int message_id) { 89 string16 message; 90 localized_strings_->GetString(base::IntToString(message_id), &message); 91 return message; 92 } 93 94 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} 95