| Index: chrome/browser/importer/firefox3_importer.cc
|
| diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc
|
| index 2cab2caee68c69bc92f1a311925e57e945ab2ea2..31cb6ff3df649f7a1a78341986fd3ef8c82e48fc 100644
|
| --- a/chrome/browser/importer/firefox3_importer.cc
|
| +++ b/chrome/browser/importer/firefox3_importer.cc
|
| @@ -12,9 +12,10 @@
|
| #include "base/stl_util.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| +#include "chrome/browser/bookmarks/bookmark_html_reader.h"
|
| +#include "chrome/browser/bookmarks/imported_bookmark_entry.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/history/history_types.h"
|
| -#include "chrome/browser/importer/firefox2_importer.h"
|
| #include "chrome/browser/importer/firefox_importer_utils.h"
|
| #include "chrome/browser/importer/importer_bridge.h"
|
| #include "chrome/browser/importer/importer_util.h"
|
| @@ -41,6 +42,39 @@ enum BookmarkItemType {
|
| TYPE_DYNAMIC_CONTAINER = 4
|
| };
|
|
|
| +// Creates a TemplateURL with the |keyword| and |url|. |title| may be empty.
|
| +// This function transfers ownership of the created TemplateURL to the caller.
|
| +TemplateURL* CreateTemplateURL(const string16& title,
|
| + const string16& keyword,
|
| + const GURL& url) {
|
| + // Skip if the keyword or url is invalid.
|
| + if (keyword.empty() || !url.is_valid())
|
| + return NULL;
|
| +
|
| + TemplateURLData data;
|
| + // We set short name by using the title if it exists.
|
| + // Otherwise, we use the shortcut.
|
| + data.short_name = title.empty() ? keyword : title;
|
| + data.SetKeyword(keyword);
|
| + data.SetURL(TemplateURLRef::DisplayURLToURLRef(UTF8ToUTF16(url.spec())));
|
| + return new TemplateURL(NULL, data);
|
| +}
|
| +
|
| +// Loads the default bookmarks in the Firefox installed at |app_path|,
|
| +// and stores their locations in |urls|.
|
| +void LoadDefaultBookmarks(const base::FilePath& app_path,
|
| + std::set<GURL>* urls) {
|
| + base::FilePath file = app_path.AppendASCII("defaults")
|
| + .AppendASCII("profile")
|
| + .AppendASCII("bookmarks.html");
|
| + urls->clear();
|
| +
|
| + std::vector<ImportedBookmarkEntry> bookmarks;
|
| + bookmark_html_reader::ImportBookmarksFile(NULL, NULL, file, &bookmarks, NULL);
|
| + for (size_t i = 0; i < bookmarks.size(); ++i)
|
| + urls->insert(bookmarks[i].url);
|
| +}
|
| +
|
| } // namespace
|
|
|
| struct Firefox3Importer::BookmarkItem {
|
| @@ -171,9 +205,9 @@ void Firefox3Importer::ImportBookmarks() {
|
| std::set<int> livemark_id;
|
| LoadLivemarkIDs(&db, &livemark_id);
|
|
|
| - // Load the default bookmarks. Its storage is the same as Firefox 2.
|
| + // Load the default bookmarks.
|
| std::set<GURL> default_urls;
|
| - Firefox2Importer::LoadDefaultBookmarks(app_path_, &default_urls);
|
| + LoadDefaultBookmarks(app_path_, &default_urls);
|
|
|
| BookmarkList list;
|
| GetTopBookmarkFolder(&db, toolbar_folder_id, &list);
|
| @@ -183,7 +217,7 @@ void Firefox3Importer::ImportBookmarks() {
|
| for (size_t i = 0; i < count; ++i)
|
| GetWholeBookmarkFolder(&db, &list, i, NULL);
|
|
|
| - std::vector<ProfileWriter::BookmarkEntry> bookmarks;
|
| + std::vector<ImportedBookmarkEntry> bookmarks;
|
| std::vector<TemplateURL*> template_urls;
|
| FaviconMap favicon_map;
|
|
|
| @@ -258,7 +292,7 @@ void Firefox3Importer::ImportBookmarks() {
|
| if (!found_path)
|
| continue;
|
|
|
| - ProfileWriter::BookmarkEntry entry;
|
| + ImportedBookmarkEntry entry;
|
| entry.creation_time = item->date_added;
|
| entry.title = item->title;
|
| entry.url = item->url;
|
| @@ -273,7 +307,7 @@ void Firefox3Importer::ImportBookmarks() {
|
| favicon_map[item->favicon].insert(item->url);
|
|
|
| // This bookmark has a keyword, we import it to our TemplateURL model.
|
| - TemplateURL* t_url = Firefox2Importer::CreateTemplateURL(
|
| + TemplateURL* t_url = CreateTemplateURL(
|
| item->title, UTF8ToUTF16(item->keyword), item->url);
|
| if (t_url)
|
| template_urls.push_back(t_url);
|
|
|