| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 6 #define CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/history/history_types.h" | 15 #include "chrome/browser/history/history_types.h" |
| 16 #include "chrome/common/importer/importer_autofill_form_data_entry.h" |
| 16 #include "chrome/common/importer/importer_data_types.h" | 17 #include "chrome/common/importer/importer_data_types.h" |
| 17 #include "chrome/common/importer/importer_url_row.h" | 18 #include "chrome/common/importer/importer_url_row.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/utility_process_host_client.h" | 20 #include "content/public/browser/utility_process_host_client.h" |
| 20 | 21 |
| 21 class ExternalProcessImporterHost; | 22 class ExternalProcessImporterHost; |
| 22 struct ImportedBookmarkEntry; | 23 struct ImportedBookmarkEntry; |
| 23 struct ImportedFaviconUsage; | 24 struct ImportedFaviconUsage; |
| 24 class InProcessImporterBridge; | 25 class InProcessImporterBridge; |
| 25 | 26 |
| 26 namespace autofill { | 27 namespace autofill { |
| 27 struct PasswordForm; | 28 struct PasswordForm; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content{ | 31 namespace content{ |
| 31 class UtilityProcessHost; | 32 class UtilityProcessHost; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace importer { | 35 namespace importer { |
| 35 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 36 struct ImporterIE7PasswordInfo; | 37 struct ImporterIE7PasswordInfo; |
| 37 #endif | 38 #endif |
| 39 struct ImporterAutofillFormDataEntry; |
| 38 struct URLKeywordInfo; | 40 struct URLKeywordInfo; |
| 39 } | 41 } |
| 40 | 42 |
| 41 // This class is the client for the out of process profile importing. It | 43 // This class is the client for the out of process profile importing. It |
| 42 // collects notifications from this process host and feeds data back to the | 44 // collects notifications from this process host and feeds data back to the |
| 43 // importer host, who actually does the writing. | 45 // importer host, who actually does the writing. |
| 44 class ExternalProcessImporterClient : public content::UtilityProcessHostClient { | 46 class ExternalProcessImporterClient : public content::UtilityProcessHostClient { |
| 45 public: | 47 public: |
| 46 ExternalProcessImporterClient( | 48 ExternalProcessImporterClient( |
| 47 base::WeakPtr<ExternalProcessImporterHost> importer_host, | 49 base::WeakPtr<ExternalProcessImporterHost> importer_host, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 const std::vector<ImportedBookmarkEntry>& bookmarks_group); | 77 const std::vector<ImportedBookmarkEntry>& bookmarks_group); |
| 76 void OnFaviconsImportStart(size_t total_favicons_count); | 78 void OnFaviconsImportStart(size_t total_favicons_count); |
| 77 void OnFaviconsImportGroup( | 79 void OnFaviconsImportGroup( |
| 78 const std::vector<ImportedFaviconUsage>& favicons_group); | 80 const std::vector<ImportedFaviconUsage>& favicons_group); |
| 79 void OnPasswordFormImportReady(const autofill::PasswordForm& form); | 81 void OnPasswordFormImportReady(const autofill::PasswordForm& form); |
| 80 void OnKeywordsImportReady( | 82 void OnKeywordsImportReady( |
| 81 const std::vector<importer::URLKeywordInfo>& url_keywords, | 83 const std::vector<importer::URLKeywordInfo>& url_keywords, |
| 82 bool unique_on_host_and_path); | 84 bool unique_on_host_and_path); |
| 83 void OnFirefoxSearchEngineDataReceived( | 85 void OnFirefoxSearchEngineDataReceived( |
| 84 const std::vector<std::string> search_engine_data); | 86 const std::vector<std::string> search_engine_data); |
| 87 void OnAutofillFormDataImportStart( |
| 88 size_t total_autofill_form_data_entry_count); |
| 89 void OnAutofillFormDataImportGroup(const std::vector< |
| 90 ImporterAutofillFormDataEntry>& autofill_form_data_entry_group); |
| 85 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
| 86 void OnIE7PasswordReceived( | 92 void OnIE7PasswordReceived( |
| 87 const importer::ImporterIE7PasswordInfo& importer_password_info); | 93 const importer::ImporterIE7PasswordInfo& importer_password_info); |
| 88 #endif | 94 #endif |
| 89 | 95 |
| 90 protected: | 96 protected: |
| 91 virtual ~ExternalProcessImporterClient(); | 97 virtual ~ExternalProcessImporterClient(); |
| 92 | 98 |
| 93 private: | 99 private: |
| 94 // Notifies the importerhost that import has finished, and calls Release(). | 100 // Notifies the importerhost that import has finished, and calls Release(). |
| 95 void Cleanup(); | 101 void Cleanup(); |
| 96 | 102 |
| 97 // Cancel import process on IO thread. | 103 // Cancel import process on IO thread. |
| 98 void CancelImportProcessOnIOThread(); | 104 void CancelImportProcessOnIOThread(); |
| 99 | 105 |
| 100 // Report item completely downloaded on IO thread. | 106 // Report item completely downloaded on IO thread. |
| 101 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); | 107 void NotifyItemFinishedOnIOThread(importer::ImportItem import_item); |
| 102 | 108 |
| 103 // Creates a new UtilityProcessHost, which launches the import process. | 109 // Creates a new UtilityProcessHost, which launches the import process. |
| 104 void StartProcessOnIOThread(content::BrowserThread::ID thread_id); | 110 void StartProcessOnIOThread(content::BrowserThread::ID thread_id); |
| 105 | 111 |
| 106 // These variables store data being collected from the importer until the | 112 // These variables store data being collected from the importer until the |
| 107 // entire group has been collected and is ready to be written to the profile. | 113 // entire group has been collected and is ready to be written to the profile. |
| 108 std::vector<ImporterURLRow> history_rows_; | 114 std::vector<ImporterURLRow> history_rows_; |
| 109 std::vector<ImportedBookmarkEntry> bookmarks_; | 115 std::vector<ImportedBookmarkEntry> bookmarks_; |
| 110 std::vector<ImportedFaviconUsage> favicons_; | 116 std::vector<ImportedFaviconUsage> favicons_; |
| 117 std::vector<ImporterAutofillFormDataEntry> autofill_form_data_; |
| 111 | 118 |
| 112 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder | 119 // Usually some variation on IDS_BOOKMARK_GROUP_...; the name of the folder |
| 113 // under which imported bookmarks will be placed. | 120 // under which imported bookmarks will be placed. |
| 114 base::string16 bookmarks_first_folder_name_; | 121 base::string16 bookmarks_first_folder_name_; |
| 115 | 122 |
| 116 // Total number of bookmarks to import. | 123 // Total number of bookmarks to import. |
| 117 size_t total_bookmarks_count_; | 124 size_t total_bookmarks_count_; |
| 118 | 125 |
| 119 // Total number of history items to import. | 126 // Total number of history items to import. |
| 120 size_t total_history_rows_count_; | 127 size_t total_history_rows_count_; |
| 121 | 128 |
| 122 // Total number of favicons to import. | 129 // Total number of favicons to import. |
| 123 size_t total_favicons_count_; | 130 size_t total_favicons_count_; |
| 124 | 131 |
| 132 // Total number of autofill form data entries to import. |
| 133 size_t total_autofill_form_data_entry_count_; |
| 134 |
| 125 // Notifications received from the ProfileImportProcessHost are passed back | 135 // Notifications received from the ProfileImportProcessHost are passed back |
| 126 // to process_importer_host_, which calls the ProfileWriter to record the | 136 // to process_importer_host_, which calls the ProfileWriter to record the |
| 127 // import data. When the import process is done, process_importer_host_ | 137 // import data. When the import process is done, process_importer_host_ |
| 128 // deletes itself. This is a weak ptr so that any messages received after | 138 // deletes itself. This is a weak ptr so that any messages received after |
| 129 // the host has deleted itself are ignored (e.g., it's possible to receive | 139 // the host has deleted itself are ignored (e.g., it's possible to receive |
| 130 // OnProcessCrashed() after NotifyImportEnded()). | 140 // OnProcessCrashed() after NotifyImportEnded()). |
| 131 base::WeakPtr<ExternalProcessImporterHost> process_importer_host_; | 141 base::WeakPtr<ExternalProcessImporterHost> process_importer_host_; |
| 132 | 142 |
| 133 // Handles sending messages to the external process. Deletes itself when | 143 // Handles sending messages to the external process. Deletes itself when |
| 134 // the external process dies (see | 144 // the external process dies (see |
| 135 // BrowserChildProcessHost::OnChildDisconnected). | 145 // BrowserChildProcessHost::OnChildDisconnected). |
| 136 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 146 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 137 | 147 |
| 138 // Data to be passed from the importer host to the external importer. | 148 // Data to be passed from the importer host to the external importer. |
| 139 importer::SourceProfile source_profile_; | 149 importer::SourceProfile source_profile_; |
| 140 uint16 items_; | 150 uint16 items_; |
| 141 | 151 |
| 142 // Takes import data coming over IPC and delivers it to be written by the | 152 // Takes import data coming over IPC and delivers it to be written by the |
| 143 // ProfileWriter. | 153 // ProfileWriter. |
| 144 scoped_refptr<InProcessImporterBridge> bridge_; | 154 scoped_refptr<InProcessImporterBridge> bridge_; |
| 145 | 155 |
| 146 // True if import process has been cancelled. | 156 // True if import process has been cancelled. |
| 147 bool cancelled_; | 157 bool cancelled_; |
| 148 | 158 |
| 149 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); | 159 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterClient); |
| 150 }; | 160 }; |
| 151 | 161 |
| 152 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ | 162 #endif // CHROME_BROWSER_IMPORTER_EXTERNAL_PROCESS_IMPORTER_CLIENT_H_ |
| OLD | NEW |