summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.cc21
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.h17
2 files changed, 28 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index 180a5bb..bab5412 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extensions_quota_service.h"
-#include "chrome/browser/importer/importer.h"
#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -803,15 +802,21 @@ bool ImportBookmarksFunction::RunImpl() {
void ImportBookmarksFunction::FileSelected(const FilePath& path,
int index,
void* params) {
- ImporterHost* host = new ImporterHost();
+ source_path_ = path;
+ importer_host_ = new ImporterHost(this);
+ // SourceProfilesLoaded() will be called once the Importer has loaded the list
+ // of source profiles.
+}
+
+void ImportBookmarksFunction::SourceProfilesLoaded() {
importer::ProfileInfo profile_info;
profile_info.browser_type = importer::BOOKMARKS_HTML;
- profile_info.source_path = path;
- host->StartImportSettings(profile_info,
- profile(),
- importer::FAVORITES,
- new ProfileWriter(profile()),
- true);
+ profile_info.source_path = source_path_;
+ importer_host_->StartImportSettings(profile_info,
+ profile(),
+ importer::FAVORITES,
+ new ProfileWriter(profile()),
+ true);
Release(); // Balanced in BookmarksIOFunction::SelectFile()
}
diff --git a/chrome/browser/extensions/extension_bookmarks_module.h b/chrome/browser/extensions/extension_bookmarks_module.h
index 21b9ad8..60e79f6 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.h
+++ b/chrome/browser/extensions/extension_bookmarks_module.h
@@ -10,9 +10,12 @@
#include <set>
#include <string>
+#include "base/ref_counted.h"
#include "base/singleton.h"
#include "chrome/browser/bookmarks/bookmark_model_observer.h"
#include "chrome/browser/extensions/extension_function.h"
+#include "chrome/browser/importer/importer.h"
+#include "chrome/browser/importer/importer_list.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
@@ -188,13 +191,23 @@ class BookmarksIOFunction : public BookmarksFunction,
scoped_refptr<SelectFileDialog> select_file_dialog_;
};
-class ImportBookmarksFunction : public BookmarksIOFunction {
+class ImportBookmarksFunction : public BookmarksIOFunction,
+ public ImporterList::Observer {
public:
- // Override BookmarkManagerIOFunction.
+ // BookmarkManagerIOFunction implementation.
virtual bool RunImpl();
virtual void FileSelected(const FilePath& path, int index, void* params);
+ // ImporterList::Observer implementation.
+ virtual void SourceProfilesLoaded();
+
private:
+ // The selected file path used to import bookmarks from.
+ FilePath source_path_;
+
+ // The ImporterHost used to import the bookmarks.
+ scoped_refptr<ImporterHost> importer_host_;
+
DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.import");
};