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