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_PROFILE_IMPORT_PROCESS_CLIENT_H_ 6 #define CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_ 7 #pragma once 8 9 #include <string> 10 #include <vector> 11 12 #include "base/basictypes.h" 13 #include "base/memory/ref_counted.h" 14 #include "chrome/browser/importer/profile_writer.h" 15 16 class GURL; 17 class TemplateURL; 18 19 namespace history { 20 class URLRow; 21 } 22 23 namespace IPC { 24 class Message; 25 } 26 27 namespace webkit_glue { 28 struct PasswordForm; 29 } 30 31 // An interface that must be implemented by consumers of the profile import 32 // process in order to get results back from the process host. The 33 // ProfileImportProcessHost calls the client's functions on the thread passed to 34 // it when it's created. 35 class ProfileImportProcessClient : 36 public base::RefCountedThreadSafe<ProfileImportProcessClient> { 37 public: 38 ProfileImportProcessClient(); 39 40 // These methods are used by the ProfileImportProcessHost to pass messages 41 // received from the external process back to the ImportProcessClient in 42 // ImporterHost. 43 virtual void OnProcessCrashed(int exit_status); 44 virtual void OnImportStart(); 45 virtual void OnImportFinished(bool succeeded, const std::string& error_msg); 46 virtual void OnImportItemStart(int item); 47 virtual void OnImportItemFinished(int item); 48 virtual void OnImportItemFailed(const std::string& error_msg); 49 50 // These methods pass back data to be written to the user's profile from 51 // the external process to the process host client. 52 virtual void OnHistoryImportStart(size_t total_history_rows_count); 53 virtual void OnHistoryImportGroup( 54 const std::vector<history::URLRow>& history_rows_group, 55 int visit_source); // visit_source has history::VisitSource type. 56 57 virtual void OnHomePageImportReady(const GURL& home_page); 58 59 virtual void OnBookmarksImportStart( 60 const string16& first_folder_name, 61 int options, 62 size_t total_bookmarks_count); 63 virtual void OnBookmarksImportGroup( 64 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks); 65 66 virtual void OnFaviconsImportStart(size_t total_favicons_count); 67 virtual void OnFaviconsImportGroup( 68 const std::vector<history::ImportedFaviconUsage>& favicons_group); 69 70 virtual void OnPasswordFormImportReady( 71 const webkit_glue::PasswordForm& form); 72 73 virtual void OnKeywordsImportReady( 74 const std::vector<TemplateURL>& template_urls, 75 int default_keyword_index, 76 bool unique_on_host_and_path); 77 78 virtual bool OnMessageReceived(const IPC::Message& message); 79 80 protected: 81 friend class base::RefCountedThreadSafe<ProfileImportProcessClient>; 82 83 virtual ~ProfileImportProcessClient(); 84 85 private: 86 friend class ProfileImportProcessHost; 87 88 DISALLOW_COPY_AND_ASSIGN(ProfileImportProcessClient); 89 }; 90 91 #endif // CHROME_BROWSER_IMPORTER_PROFILE_IMPORT_PROCESS_CLIENT_H_ 92