| Index: chrome/utility/importer/firefox_places_factory.h
|
| diff --git a/chrome/utility/importer/firefox_places_factory.h b/chrome/utility/importer/firefox_places_factory.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a5a734629fb97f4296955b1d9fbd8e3b002c7bcf
|
| --- /dev/null
|
| +++ b/chrome/utility/importer/firefox_places_factory.h
|
| @@ -0,0 +1,105 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_UTILITY_IMPORTER_FIREFOX_PLACES_FACTORY_H_
|
| +#define CHROME_UTILITY_IMPORTER_FIREFOX_PLACES_FACTORY_H_
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/files/file_enumerator.h"
|
| +#include "base/files/file_path.h"
|
| +#include "base/files/file_util.h"
|
| +#include "chrome/common/importer/importer_url_row.h"
|
| +#include "components/favicon_base/favicon_usage_data.h"
|
| +#include "sql/connection.h"
|
| +#include "sql/statement.h"
|
| +
|
| +// Original definition is in http://mxr.mozilla.org/firefox/source/toolkit/
|
| +// components/places/public/nsINavBookmarksService.idl
|
| +enum BookmarkItemType {
|
| + TYPE_BOOKMARK = 1,
|
| + TYPE_FOLDER = 2,
|
| + TYPE_SEPARATOR = 3,
|
| + TYPE_DYNAMIC_CONTAINER = 4
|
| +};
|
| +
|
| +// The struct stores the information about a bookmark item.
|
| +struct BookmarkItem {
|
| + int parent;
|
| + int id;
|
| + GURL url;
|
| + base::string16 title;
|
| + BookmarkItemType type;
|
| + std::string keyword;
|
| + base::Time date_added;
|
| + int64_t favicon;
|
| + bool empty_folder;
|
| +};
|
| +
|
| +typedef std::vector<BookmarkItem*> BookmarkList;
|
| +typedef std::set<int> PostKeywordIds;
|
| +typedef std::set<int> LivemarkIds;
|
| +typedef std::map<int64_t, std::set<GURL>> FaviconMap;
|
| +
|
| +class FirefoxPlaces {
|
| + public:
|
| + enum class FolderType { ROOT, MENU, TOOLBAR, TAGS, UNSORTED };
|
| + FirefoxPlaces(const base::FilePath& places_path);
|
| + virtual bool LoadBookmarks(BookmarkList* bookmarks);
|
| + virtual bool LoadHistory(std::vector<ImporterURLRow>* history);
|
| + virtual bool LoadPostKeywordIds(PostKeywordIds* post_keyword_ids);
|
| + virtual bool LoadLivemarkIds(LivemarkIds* livemark_ids);
|
| + virtual int GetFolderId(FolderType folder_type);
|
| +
|
| + // Loads the favicons given in the map from the database, loads the data,
|
| + // and converts it into FaviconUsage structures.
|
| + virtual bool LoadFavicons(const FaviconMap& favicon_map,
|
| + favicon_base::FaviconUsageDataList* favicons);
|
| +
|
| + virtual ~FirefoxPlaces() {}
|
| +
|
| + protected:
|
| + base::FilePath places_path_;
|
| + sql::Connection db_;
|
| +
|
| + // Gets the bookmark folder with given ID, and adds the entry in |list|
|
| + // if successful.
|
| + virtual void GetTopBookmarkFolder(int folder_id, BookmarkList* list);
|
| +
|
| + // Loads all children of the given folder, and appends them to the |list|.
|
| + virtual void GetWholeBookmarkFolder(BookmarkList* list,
|
| + size_t position,
|
| + bool* empty_folder);
|
| +};
|
| +
|
| +class FirefoxPlacesV11 : public FirefoxPlaces {
|
| + public:
|
| + FirefoxPlacesV11(const base::FilePath& places_path);
|
| + int GetFolderId(FolderType folder_type) override;
|
| +
|
| + private:
|
| + // Gets the specific ID of a root node with given name from |db|.
|
| + // Returns -1 if not found.
|
| + int FirefoxPlacesV11::LoadNodeIDByName(const std::string& name);
|
| +};
|
| +class FirefoxPlacesV25 : public FirefoxPlaces {
|
| + public:
|
| + FirefoxPlacesV25(const base::FilePath& places_path);
|
| + int GetFolderId(FolderType folder_type) override;
|
| +
|
| + private:
|
| + // Gets the specific ID of a bookmark node with given GUID from |db|.
|
| + // Returns -1 if not found.
|
| + int LoadNodeIDByGUID(const std::string& GUID);
|
| +};
|
| +
|
| +class FirefoxPlacesFactory {
|
| + public:
|
| + static std::unique_ptr<FirefoxPlaces> GetForProfile(
|
| + const base::FilePath& profile_path);
|
| +};
|
| +
|
| +#endif CHROME_UTILITY_IMPORTER_FIREFOX_PLACES_FACTORY_H_
|
|
|