| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_IMPORTER_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_IMPORTER_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_BRIDGE_H_ | 6 #define CHROME_BROWSER_IMPORTER_IMPORTER_BRIDGE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "chrome/browser/chrome_thread.h" | 16 #include "chrome/browser/chrome_thread.h" |
| 17 #include "chrome/browser/importer/importer_data_types.h" | 17 #include "chrome/browser/importer/importer_data_types.h" |
| 18 // TODO: remove this, see friend declaration in ImporterBridge. | 18 // TODO: remove this, see friend declaration in ImporterBridge. |
| 19 #include "chrome/browser/importer/toolbar_importer.h" | 19 #include "chrome/browser/importer/toolbar_importer.h" |
| 20 | 20 |
| 21 class ProfileImportThread; | 21 class ProfileImportThread; |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 class ImporterHost; | 23 class ImporterHost; |
| 24 | 24 |
| 25 class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> { | 25 class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> { |
| 26 public: | 26 public: |
| 27 ImporterBridge() { } | 27 ImporterBridge(); |
| 28 | 28 |
| 29 virtual void AddBookmarkEntries( | 29 virtual void AddBookmarkEntries( |
| 30 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, | 30 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, |
| 31 const std::wstring& first_folder_name, | 31 const std::wstring& first_folder_name, |
| 32 int options) = 0; | 32 int options) = 0; |
| 33 virtual void AddHomePage(const GURL &home_page) = 0; | 33 virtual void AddHomePage(const GURL &home_page) = 0; |
| 34 | 34 |
| 35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 36 virtual void AddIE7PasswordInfo(const IE7PasswordInfo password_info) = 0; | 36 virtual void AddIE7PasswordInfo(const IE7PasswordInfo password_info) = 0; |
| 37 #endif | 37 #endif |
| (...skipping 27 matching lines...) Expand all Loading... |
| 65 // external import process, since the importer only needs a few strings. | 65 // external import process, since the importer only needs a few strings. |
| 66 virtual std::wstring GetLocalizedString(int message_id) = 0; | 66 virtual std::wstring GetLocalizedString(int message_id) = 0; |
| 67 | 67 |
| 68 protected: | 68 protected: |
| 69 friend class base::RefCountedThreadSafe<ImporterBridge>; | 69 friend class base::RefCountedThreadSafe<ImporterBridge>; |
| 70 // TODO: In order to run Toolbar5Importer OOP we need to cut this | 70 // TODO: In order to run Toolbar5Importer OOP we need to cut this |
| 71 // connection, but as an interim step we allow Toolbar5Import to break | 71 // connection, but as an interim step we allow Toolbar5Import to break |
| 72 // the abstraction here and assume import is in-process. | 72 // the abstraction here and assume import is in-process. |
| 73 friend class Toolbar5Importer; | 73 friend class Toolbar5Importer; |
| 74 | 74 |
| 75 virtual ~ImporterBridge() {} | 75 virtual ~ImporterBridge(); |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(ImporterBridge); | 77 DISALLOW_COPY_AND_ASSIGN(ImporterBridge); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class InProcessImporterBridge : public ImporterBridge { | 80 class InProcessImporterBridge : public ImporterBridge { |
| 81 public: | 81 public: |
| 82 InProcessImporterBridge(ProfileWriter* writer, | 82 InProcessImporterBridge(ProfileWriter* writer, |
| 83 ImporterHost* host); | 83 ImporterHost* host); |
| 84 | 84 |
| 85 // Methods inherited from ImporterBridge. On the internal side, these | 85 // Methods inherited from ImporterBridge. On the internal side, these |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 bool unique_on_host_and_path); | 103 bool unique_on_host_and_path); |
| 104 virtual void SetPasswordForm(const webkit_glue::PasswordForm& form); | 104 virtual void SetPasswordForm(const webkit_glue::PasswordForm& form); |
| 105 | 105 |
| 106 virtual void NotifyItemStarted(importer::ImportItem item); | 106 virtual void NotifyItemStarted(importer::ImportItem item); |
| 107 virtual void NotifyItemEnded(importer::ImportItem item); | 107 virtual void NotifyItemEnded(importer::ImportItem item); |
| 108 virtual void NotifyStarted(); | 108 virtual void NotifyStarted(); |
| 109 virtual void NotifyEnded(); | 109 virtual void NotifyEnded(); |
| 110 virtual std::wstring GetLocalizedString(int message_id); | 110 virtual std::wstring GetLocalizedString(int message_id); |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 ~InProcessImporterBridge() {} | 113 virtual ~InProcessImporterBridge(); |
| 114 | 114 |
| 115 ProfileWriter* const writer_; // weak | 115 ProfileWriter* const writer_; // weak |
| 116 ImporterHost* const host_; // weak | 116 ImporterHost* const host_; // weak |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(InProcessImporterBridge); | 118 DISALLOW_COPY_AND_ASSIGN(InProcessImporterBridge); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // When the importer is run in an external process, the bridge is effectively | 121 // When the importer is run in an external process, the bridge is effectively |
| 122 // split in half by the IPC infrastructure. The external bridge receives data | 122 // split in half by the IPC infrastructure. The external bridge receives data |
| 123 // and notifications from the importer, and sends it across IPC. The | 123 // and notifications from the importer, and sends it across IPC. The |
| (...skipping 25 matching lines...) Expand all Loading... |
| 149 bool unique_on_host_and_path); | 149 bool unique_on_host_and_path); |
| 150 virtual void SetPasswordForm(const webkit_glue::PasswordForm& form); | 150 virtual void SetPasswordForm(const webkit_glue::PasswordForm& form); |
| 151 | 151 |
| 152 virtual void NotifyItemStarted(importer::ImportItem item); | 152 virtual void NotifyItemStarted(importer::ImportItem item); |
| 153 virtual void NotifyItemEnded(importer::ImportItem item); | 153 virtual void NotifyItemEnded(importer::ImportItem item); |
| 154 virtual void NotifyStarted(); | 154 virtual void NotifyStarted(); |
| 155 virtual void NotifyEnded(); | 155 virtual void NotifyEnded(); |
| 156 virtual std::wstring GetLocalizedString(int message_id); | 156 virtual std::wstring GetLocalizedString(int message_id); |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 ~ExternalProcessImporterBridge() {} | 159 ~ExternalProcessImporterBridge(); |
| 160 | 160 |
| 161 // Call back to send data and messages across IPC. | 161 // Call back to send data and messages across IPC. |
| 162 ProfileImportThread* const profile_import_thread_; | 162 ProfileImportThread* const profile_import_thread_; |
| 163 | 163 |
| 164 // Holds strings needed by the external importer because the resource | 164 // Holds strings needed by the external importer because the resource |
| 165 // bundle isn't available to the external process. | 165 // bundle isn't available to the external process. |
| 166 scoped_ptr<DictionaryValue> localized_strings_; | 166 scoped_ptr<DictionaryValue> localized_strings_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); | 168 DISALLOW_COPY_AND_ASSIGN(ExternalProcessImporterBridge); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_BRIDGE_H_ | 171 #endif // CHROME_BROWSER_IMPORTER_IMPORTER_BRIDGE_H_ |
| OLD | NEW |