summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer/firefox2_importer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/importer/firefox2_importer.cc')
-rw-r--r--chrome/browser/importer/firefox2_importer.cc63
1 files changed, 34 insertions, 29 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc
index 943cb9e..3a38b2f 100644
--- a/chrome/browser/importer/firefox2_importer.cc
+++ b/chrome/browser/importer/firefox2_importer.cc
@@ -13,7 +13,6 @@
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/importer/firefox_importer_utils.h"
-#include "chrome/browser/importer/importer_bridge.h"
#include "chrome/browser/importer/mork_reader.h"
#include "chrome/browser/importer/nss_decryptor.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -36,16 +35,18 @@ Firefox2Importer::~Firefox2Importer() {
}
void Firefox2Importer::StartImport(ProfileInfo profile_info,
- uint16 items,
- ImporterBridge* bridge) {
- bridge_ = bridge;
+ uint16 items, ProfileWriter* writer,
+ MessageLoop* delagate_loop,
+ ImporterHost* host) {
+ writer_ = writer;
source_path_ = profile_info.source_path;
app_path_ = profile_info.app_path;
+ importer_host_ = host;
parsing_bookmarks_html_file_ = (profile_info.browser_type == BOOKMARKS_HTML);
// The order here is important!
- bridge_->NotifyStarted();
+ NotifyStarted();
if ((items & HOME_PAGE) && !cancelled())
ImportHomepage(); // Doesn't have a UI item.
@@ -53,27 +54,27 @@ void Firefox2Importer::StartImport(ProfileInfo profile_info,
// will also import favicons and we store favicon for a URL only if the URL
// exist in history or bookmarks.
if ((items & HISTORY) && !cancelled()) {
- bridge_->NotifyItemStarted(HISTORY);
+ NotifyItemStarted(HISTORY);
ImportHistory();
- bridge_->NotifyItemEnded(HISTORY);
+ NotifyItemEnded(HISTORY);
}
if ((items & FAVORITES) && !cancelled()) {
- bridge_->NotifyItemStarted(FAVORITES);
+ NotifyItemStarted(FAVORITES);
ImportBookmarks();
- bridge_->NotifyItemEnded(FAVORITES);
+ NotifyItemEnded(FAVORITES);
}
if ((items & SEARCH_ENGINES) && !cancelled()) {
- bridge_->NotifyItemStarted(SEARCH_ENGINES);
+ NotifyItemStarted(SEARCH_ENGINES);
ImportSearchEngines();
- bridge_->NotifyItemEnded(SEARCH_ENGINES);
+ NotifyItemEnded(SEARCH_ENGINES);
}
if ((items & PASSWORDS) && !cancelled()) {
- bridge_->NotifyItemStarted(PASSWORDS);
+ NotifyItemStarted(PASSWORDS);
ImportPasswords();
- bridge_->NotifyItemEnded(PASSWORDS);
+ NotifyItemEnded(PASSWORDS);
}
- bridge_->NotifyEnded();
+ NotifyEnded();
}
// static
@@ -263,19 +264,21 @@ void Firefox2Importer::ImportBookmarks() {
// Write data into profile.
if (!bookmarks.empty() && !cancelled()) {
- int options = 0;
- if (import_to_bookmark_bar())
- options = ProfileWriter::IMPORT_TO_BOOKMARK_BAR;
- bridge_->AddBookmarkEntries(bookmarks, first_folder_name, options);
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddBookmarkEntry, bookmarks,
+ first_folder_name,
+ import_to_bookmark_bar() ? ProfileWriter::IMPORT_TO_BOOKMARK_BAR : 0));
}
if (!parsing_bookmarks_html_file_ && !template_urls.empty() &&
!cancelled()) {
- bridge_->SetKeywords(template_urls, -1, false);
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddKeywords, template_urls, -1, false));
} else {
STLDeleteContainerPointers(template_urls.begin(), template_urls.end());
}
if (!favicons.empty()) {
- bridge_->SetFavIcons(favicons);
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddFavicons, favicons));
}
}
@@ -302,7 +305,8 @@ void Firefox2Importer::ImportPasswords() {
if (!cancelled()) {
for (size_t i = 0; i < forms.size(); ++i) {
- bridge_->SetPasswordForm(forms[i]);
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddPasswordForm, forms[i]));
}
}
}
@@ -310,7 +314,7 @@ void Firefox2Importer::ImportPasswords() {
void Firefox2Importer::ImportHistory() {
std::wstring file = source_path_;
file_util::AppendToPath(&file, L"history.dat");
- ImportHistoryFromFirefox2(file, bridge_);
+ ImportHistoryFromFirefox2(file, main_loop_, writer_);
}
void Firefox2Importer::ImportSearchEngines() {
@@ -319,16 +323,17 @@ void Firefox2Importer::ImportSearchEngines() {
std::vector<TemplateURL*> search_engines;
ParseSearchEnginesFromXMLFiles(files, &search_engines);
-
- int default_index =
- GetFirefoxDefaultSearchEngineIndex(search_engines, source_path_);
- bridge_->SetKeywords(search_engines, default_index, true);
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddKeywords, search_engines,
+ GetFirefoxDefaultSearchEngineIndex(search_engines, source_path_),
+ true));
}
void Firefox2Importer::ImportHomepage() {
- GURL home_page = GetHomepage(source_path_);
- if (home_page.is_valid() && !IsDefaultHomepage(home_page, app_path_)) {
- bridge_->AddHomePage(home_page);
+ GURL homepage = GetHomepage(source_path_);
+ if (homepage.is_valid() && !IsDefaultHomepage(homepage, app_path_)) {
+ main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
+ &ProfileWriter::AddHomepage, homepage));
}
}