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 #ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ 6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ 7 #pragma once 8 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "base/compiler_specific.h" 13 #include "base/memory/scoped_ptr.h" 14 #include "chrome/browser/importer/importer_bridge.h" 15 #include "chrome/browser/importer/profile_writer.h" 16 17 class DictionaryValue; 18 class GURL; 19 class ProfileImportThread; 20 21 // When the importer is run in an external process, the bridge is effectively 22 // split in half by the IPC infrastructure. The external bridge receives data 23 // and notifications from the importer, and sends it across IPC. The 24 // internal bridge gathers the data from the IPC host and writes it to the 25 // profile. 26 class ExternalProcessImporterBridge : public ImporterBridge { 27 public: 28 ExternalProcessImporterBridge(ProfileImportThread* profile_import_thread, 29 const DictionaryValue& localized_strings); 30 31 // Begin ImporterBridge implementation: 32 virtual void AddBookmarkEntries( 33 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, 34 const string16& first_folder_name, 35 int options) OVERRIDE; 36 37 virtual void AddHomePage(const GURL& home_page) OVERRIDE; 38 39 #if defined(OS_WIN) 40 virtual void AddIE7PasswordInfo( 41 const IE7PasswordInfo& password_info) OVERRIDE; 42 #endif 43 44 virtual void SetFavicons( 45 const std::vector<history::ImportedFaviconUsage>& favicons) OVERRIDE; 46 47 virtual void SetHistoryItems(const std::vector<history::URLRow>& rows, 48 history::VisitSource visit_source) OVERRIDE; 49 50 virtual void SetKeywords(const std::vector<TemplateURL*>& template_urls, 51 int default_keyword_index, 52 bool unique_on_host_and_path) OVERRIDE; 53 54 virtual void SetPasswordForm(const webkit_glue::PasswordForm& form) OVERRIDE; 55 56 virtual void NotifyStarted() OVERRIDE; 57 virtual void NotifyItemStarted(importer::ImportItem item) OVERRIDE; 58 virtual void NotifyItemEnded(importer::ImportItem item) OVERRIDE; 59 virtual void NotifyEnded() OVERRIDE; 60 61 virtual string16 GetLocalizedString(int message_id) OVERRIDE; 62 // End ImporterBridge implementation. 63 64 private: 65 virtual ~ExternalProcessImporterBridge(); 66 67 // Call back to send data and messages across IPC. 68 ProfileImportThread* const profile_import_thread_; 69 70 // Holds strings needed by the external importer because the resource 71 // bundle isn't available to the external process. 72 scoped_ptr<DictionaryValue> localized_strings_; 73 74 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); 75 }; 76 77 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ 78