| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ |
| 6 #define CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ | 6 #define CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #include "chrome/utility/importer/importer.h" | 21 #include "chrome/utility/importer/importer.h" |
| 21 #include "components/favicon_base/favicon_usage_data.h" | 22 #include "components/favicon_base/favicon_usage_data.h" |
| 22 | 23 |
| 23 class GURL; | 24 class GURL; |
| 24 | 25 |
| 25 namespace sql { | 26 namespace sql { |
| 26 class Connection; | 27 class Connection; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // Importer for Mozilla Firefox 3 and later. | 30 // Importer for Mozilla Firefox 3 and later. |
| 30 // Firefox stores its persistent information in a system called places. | 31 // Firefox stores its persistent information in a system called places. |
| 31 // http://wiki.mozilla.org/Places | 32 // http://wiki.mozilla.org/Places |
| 32 class FirefoxImporter : public Importer { | 33 class FirefoxImporter : public Importer { |
| 33 public: | 34 public: |
| 34 FirefoxImporter(); | 35 FirefoxImporter(); |
| 36 ~FirefoxImporter() override; |
| 35 | 37 |
| 36 // Importer: | 38 // Importer: |
| 37 void StartImport(const importer::SourceProfile& source_profile, | 39 void StartImport(const importer::SourceProfile& source_profile, |
| 38 uint16_t items, | 40 uint16_t items, |
| 39 ImporterBridge* bridge) override; | 41 ImporterBridge* bridge) override; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 typedef std::map<int64_t, std::set<GURL>> FaviconMap; | 44 FRIEND_TEST_ALL_PREFIXES(FirefoxImporterTest, ImportBookmarksV25); |
| 43 | |
| 44 ~FirefoxImporter() override; | |
| 45 | |
| 46 void ImportBookmarks(); | 45 void ImportBookmarks(); |
| 47 void ImportPasswords(); | 46 void ImportPasswords(); |
| 48 void ImportHistory(); | 47 void ImportHistory(); |
| 49 void ImportSearchEngines(); | 48 void ImportSearchEngines(); |
| 50 // Import the user's home page, unless it is set to default home page as | 49 // Import the user's home page, unless it is set to default home page as |
| 51 // defined in browserconfig.properties. | 50 // defined in browserconfig.properties. |
| 52 void ImportHomepage(); | 51 void ImportHomepage(); |
| 53 void ImportAutofillFormData(); | 52 void ImportAutofillFormData(); |
| 54 void GetSearchEnginesXMLData(std::vector<std::string>* search_engine_data); | 53 void GetSearchEnginesXMLData(std::vector<std::string>* search_engine_data); |
| 55 void GetSearchEnginesXMLDataFromJSON( | 54 void GetSearchEnginesXMLDataFromJSON( |
| 56 std::vector<std::string>* search_engine_data); | 55 std::vector<std::string>* search_engine_data); |
| 57 | 56 |
| 58 // The struct stores the information about a bookmark item. | |
| 59 struct BookmarkItem; | |
| 60 typedef std::vector<BookmarkItem*> BookmarkList; | |
| 61 | |
| 62 // Gets the specific IDs of bookmark root node from |db|. | |
| 63 void LoadRootNodeID(sql::Connection* db, int* toolbar_folder_id, | |
| 64 int* menu_folder_id, int* unsorted_folder_id); | |
| 65 | |
| 66 // Loads all livemark IDs from database |db|. | |
| 67 void LoadLivemarkIDs(sql::Connection* db, std::set<int>* livemark); | |
| 68 | |
| 69 // Gets the bookmark folder with given ID, and adds the entry in |list| | |
| 70 // if successful. | |
| 71 void GetTopBookmarkFolder(sql::Connection* db, | |
| 72 int folder_id, | |
| 73 BookmarkList* list); | |
| 74 | |
| 75 // Loads all children of the given folder, and appends them to the |list|. | |
| 76 void GetWholeBookmarkFolder(sql::Connection* db, BookmarkList* list, | |
| 77 size_t position, bool* empty_folder); | |
| 78 | |
| 79 // Loads the favicons given in the map from the database, loads the data, | |
| 80 // and converts it into FaviconUsage structures. | |
| 81 void LoadFavicons(sql::Connection* db, | |
| 82 const FaviconMap& favicon_map, | |
| 83 favicon_base::FaviconUsageDataList* favicons); | |
| 84 | |
| 85 base::FilePath source_path_; | 57 base::FilePath source_path_; |
| 86 base::FilePath app_path_; | 58 base::FilePath app_path_; |
| 87 | 59 |
| 88 #if defined(OS_POSIX) | 60 #if defined(OS_POSIX) |
| 89 // Stored because we can only access it from the UI thread. | 61 // Stored because we can only access it from the UI thread. |
| 90 std::string locale_; | 62 std::string locale_; |
| 91 #endif | 63 #endif |
| 92 | 64 |
| 93 DISALLOW_COPY_AND_ASSIGN(FirefoxImporter); | 65 DISALLOW_COPY_AND_ASSIGN(FirefoxImporter); |
| 94 }; | 66 }; |
| 95 | 67 |
| 96 #endif // CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ | 68 #endif // CHROME_UTILITY_IMPORTER_FIREFOX_IMPORTER_H_ |
| OLD | NEW |