summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_bookmarks_module.cc
diff options
context:
space:
mode:
authorfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 21:40:55 +0000
committerfeldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 21:40:55 +0000
commitdc0412127385b73df3647ebfb313b61e51ef1496 (patch)
treef1a6db934166721bf81c80909d87fd6a15565dd3 /chrome/browser/extensions/extension_bookmarks_module.cc
parent31db0071f84abe836f54218bd9240adb847d3211 (diff)
downloadchromium_src-dc0412127385b73df3647ebfb313b61e51ef1496.zip
chromium_src-dc0412127385b73df3647ebfb313b61e51ef1496.tar.gz
chromium_src-dc0412127385b73df3647ebfb313b61e51ef1496.tar.bz2
Move onImportBegan/Ended to the regular bookmarks api
It used to live in the experimental.bookmarkManager namespace. BUG=35320 TEST=none Review URL: http://codereview.chromium.org/1353004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_bookmarks_module.cc')
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index d561e2a..e0fadaf 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -9,12 +9,15 @@
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/browser/bookmarks/bookmark_codec.h"
+#include "chrome/browser/bookmarks/bookmark_html_writer.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/extensions/extension_bookmarks_module_constants.h"
#include "chrome/browser/extensions/extension_message_service.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/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/notification_service.h"
@@ -857,3 +860,64 @@ void CreateBookmarkFunction::GetQuotaLimitHeuristics(
QuotaLimitHeuristics* heuristics) const {
BookmarksQuotaLimitFactory::BuildForCreate(heuristics, profile());
}
+
+void BookmarksIOFunction::SelectFile(SelectFileDialog::Type type) {
+ // Balanced in one of the three callbacks of SelectFileDialog:
+ // either FileSelectionCanceled, MultiFilesSelected, or FileSelected
+ AddRef();
+ select_file_dialog_ = SelectFileDialog::Create(this);
+ SelectFileDialog::FileTypeInfo file_type_info;
+ file_type_info.extensions.resize(1);
+ file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html"));
+
+ select_file_dialog_->SelectFile(type,
+ string16(),
+ FilePath(),
+ &file_type_info,
+ 0,
+ FILE_PATH_LITERAL(""),
+ NULL,
+ NULL);
+}
+
+void BookmarksIOFunction::FileSelectionCanceled(void* params) {
+ Release(); // Balanced in BookmarksIOFunction::SelectFile()
+}
+
+void BookmarksIOFunction::MultiFilesSelected(
+ const std::vector<FilePath>& files, void* params) {
+ Release(); // Balanced in BookmarsIOFunction::SelectFile()
+ NOTREACHED() << "Should not be able to select multiple files";
+}
+
+bool ImportBookmarksFunction::RunImpl() {
+ SelectFile(SelectFileDialog::SELECT_OPEN_FILE);
+ return true;
+}
+
+void ImportBookmarksFunction::FileSelected(const FilePath& path,
+ int index,
+ void* params) {
+ ImporterHost* host = new ImporterHost();
+ importer::ProfileInfo profile_info;
+ profile_info.browser_type = importer::BOOKMARKS_HTML;
+ profile_info.source_path = path.ToWStringHack();
+ host->StartImportSettings(profile_info,
+ profile(),
+ importer::FAVORITES,
+ new ProfileWriter(profile()),
+ true);
+ Release(); // Balanced in BookmarksIOFunction::SelectFile()
+}
+
+bool ExportBookmarksFunction::RunImpl() {
+ SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE);
+ return true;
+}
+
+void ExportBookmarksFunction::FileSelected(const FilePath& path,
+ int index,
+ void* params) {
+ bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
+ Release(); // Balanced in BookmarksIOFunction::SelectFile()
+}