| 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_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| 6 #define CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 6 #define CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/common/importer/importer_bridge.h" | 15 #include "chrome/common/importer/importer_bridge.h" |
| 16 #include "chrome/common/importer/profile_import.mojom.h" |
| 16 #include "components/favicon_base/favicon_usage_data.h" | 17 #include "components/favicon_base/favicon_usage_data.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 struct ImportedBookmarkEntry; | 20 struct ImportedBookmarkEntry; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class DictionaryValue; | 23 class DictionaryValue; |
| 23 class TaskRunner; | |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace importer { | 26 namespace importer { |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 struct ImporterIE7PasswordInfo; | 28 struct ImporterIE7PasswordInfo; |
| 29 #endif | 29 #endif |
| 30 struct ImporterURLRow; | 30 struct ImporterURLRow; |
| 31 struct SearchEngineInfo; | 31 struct SearchEngineInfo; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace IPC { | 34 // TODO(tibell): Now that profile import is a Mojo service perhaps ImportBridge, |
| 35 class Message; | 35 // ProfileWriter or something in between should be the actual Mojo interface, |
| 36 class Sender; | 36 // instead of having the current split. |
| 37 } | |
| 38 | 37 |
| 39 // When the importer is run in an external process, the bridge is effectively | 38 // When the importer is run in an external process, the bridge is effectively |
| 40 // split in half by the IPC infrastructure. The external bridge receives data | 39 // split in half by the IPC infrastructure. The external bridge receives data |
| 41 // and notifications from the importer, and sends it across IPC. The | 40 // and notifications from the importer, and sends it across IPC. The |
| 42 // internal bridge gathers the data from the IPC host and writes it to the | 41 // internal bridge gathers the data from the IPC host and writes it to the |
| 43 // profile. | 42 // profile. |
| 44 class ExternalProcessImporterBridge : public ImporterBridge { | 43 class ExternalProcessImporterBridge : public ImporterBridge { |
| 45 public: | 44 public: |
| 45 // |observer| must outlive this object. |
| 46 ExternalProcessImporterBridge( | 46 ExternalProcessImporterBridge( |
| 47 const base::DictionaryValue& localized_strings, | 47 const base::DictionaryValue& localized_strings, |
| 48 IPC::Sender* sender, | 48 scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> |
| 49 base::TaskRunner* task_runner); | 49 observer); |
| 50 | 50 |
| 51 // Begin ImporterBridge implementation: | 51 // Begin ImporterBridge implementation: |
| 52 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, | 52 void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks, |
| 53 const base::string16& first_folder_name) override; | 53 const base::string16& first_folder_name) override; |
| 54 | 54 |
| 55 void AddHomePage(const GURL& home_page) override; | 55 void AddHomePage(const GURL& home_page) override; |
| 56 | 56 |
| 57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 58 void AddIE7PasswordInfo( | 58 void AddIE7PasswordInfo( |
| 59 const importer::ImporterIE7PasswordInfo& password_info) override; | 59 const importer::ImporterIE7PasswordInfo& password_info) override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 void NotifyItemStarted(importer::ImportItem item) override; | 80 void NotifyItemStarted(importer::ImportItem item) override; |
| 81 void NotifyItemEnded(importer::ImportItem item) override; | 81 void NotifyItemEnded(importer::ImportItem item) override; |
| 82 void NotifyEnded() override; | 82 void NotifyEnded() override; |
| 83 | 83 |
| 84 base::string16 GetLocalizedString(int message_id) override; | 84 base::string16 GetLocalizedString(int message_id) override; |
| 85 // End ImporterBridge implementation. | 85 // End ImporterBridge implementation. |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 ~ExternalProcessImporterBridge() override; | 88 ~ExternalProcessImporterBridge() override; |
| 89 | 89 |
| 90 void Send(IPC::Message* message); | |
| 91 void SendInternal(IPC::Message* message); | |
| 92 | |
| 93 // Holds strings needed by the external importer because the resource | 90 // Holds strings needed by the external importer because the resource |
| 94 // bundle isn't available to the external process. | 91 // bundle isn't available to the external process. |
| 95 std::unique_ptr<base::DictionaryValue> localized_strings_; | 92 std::unique_ptr<base::DictionaryValue> localized_strings_; |
| 96 | 93 |
| 97 IPC::Sender* sender_; | 94 scoped_refptr<chrome::mojom::ThreadSafeProfileImportObserverPtr> observer_; |
| 98 scoped_refptr<base::TaskRunner> task_runner_; | |
| 99 | 95 |
| 100 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); | 96 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); |
| 101 }; | 97 }; |
| 102 | 98 |
| 103 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ | 99 #endif // CHROME_UTILITY_IMPORTER_EXTERNAL_PROCESS_IMPORTER_BRIDGE_H_ |
| OLD | NEW |