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