Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: chrome/browser/importer/safari_importer.h

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test cleanup Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_IMPORTER_SAFARI_IMPORTER_H_ 5 #ifndef CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_
6 #define CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_ 6 #define CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "chrome/browser/history/history_types.h"
16 #include "chrome/browser/importer/importer.h" 17 #include "chrome/browser/importer/importer.h"
17 #include "chrome/browser/importer/profile_writer.h"
18 18
19 #if __OBJC__ 19 #if __OBJC__
20 @class NSDictionary; 20 @class NSDictionary;
21 @class NSString; 21 @class NSString;
22 #else 22 #else
23 class NSDictionary; 23 class NSDictionary;
24 class NSString; 24 class NSString;
25 #endif 25 #endif
26 26
27 class GURL; 27 class GURL;
28 struct ImportedBookmarkEntry;
29 struct ImportedFaviconUsage;
28 30
29 namespace history { 31 namespace history {
30 class URLRow; 32 class URLRow;
31 struct ImportedFaviconUsage;
32 } 33 }
33 34
34 namespace sql { 35 namespace sql {
35 class Connection; 36 class Connection;
36 } 37 }
37 38
38 // Importer for Safari on OS X. 39 // Importer for Safari on OS X.
39 class SafariImporter : public Importer { 40 class SafariImporter : public Importer {
40 public: 41 public:
41 // |library_dir| is the full path to the ~/Library directory, 42 // |library_dir| is the full path to the ~/Library directory,
(...skipping 24 matching lines...) Expand all
66 // of URLs -> IconIDs that we load as a temporary step before 67 // of URLs -> IconIDs that we load as a temporary step before
67 // actually loading the icons. 68 // actually loading the icons.
68 typedef std::map<int64, std::set<GURL> > FaviconMap; 69 typedef std::map<int64, std::set<GURL> > FaviconMap;
69 70
70 void ImportBookmarks(); 71 void ImportBookmarks();
71 void ImportPasswords(); 72 void ImportPasswords();
72 void ImportHistory(); 73 void ImportHistory();
73 74
74 // Parse Safari's stored bookmarks. 75 // Parse Safari's stored bookmarks.
75 void ParseBookmarks(const string16& toolbar_name, 76 void ParseBookmarks(const string16& toolbar_name,
76 std::vector<ProfileWriter::BookmarkEntry>* bookmarks); 77 std::vector<ImportedBookmarkEntry>* bookmarks);
77 78
78 // Function to recursively read Bookmarks out of Safari plist. 79 // Function to recursively read Bookmarks out of Safari plist.
79 // |bookmark_folder| The dictionary containing a folder to parse. 80 // |bookmark_folder| The dictionary containing a folder to parse.
80 // |parent_path_elements| Path elements up to this point. 81 // |parent_path_elements| Path elements up to this point.
81 // |is_in_toolbar| Is this folder in the toolbar. 82 // |is_in_toolbar| Is this folder in the toolbar.
82 // |out_bookmarks| BookMark element array to write into. 83 // |out_bookmarks| BookMark element array to write into.
83 void RecursiveReadBookmarksFolder( 84 void RecursiveReadBookmarksFolder(
84 NSDictionary* bookmark_folder, 85 NSDictionary* bookmark_folder,
85 const std::vector<string16>& parent_path_elements, 86 const std::vector<string16>& parent_path_elements,
86 bool is_in_toolbar, 87 bool is_in_toolbar,
87 const string16& toolbar_name, 88 const string16& toolbar_name,
88 std::vector<ProfileWriter::BookmarkEntry>* out_bookmarks); 89 std::vector<ImportedBookmarkEntry>* out_bookmarks);
89 90
90 // Converts history time stored by Safari as a double serialized as a string, 91 // Converts history time stored by Safari as a double serialized as a string,
91 // to seconds-since-UNIX-Ephoch-format used by Chrome. 92 // to seconds-since-UNIX-Ephoch-format used by Chrome.
92 double HistoryTimeToEpochTime(NSString* history_time); 93 double HistoryTimeToEpochTime(NSString* history_time);
93 94
94 // Parses Safari's history and loads it into the input array. 95 // Parses Safari's history and loads it into the input array.
95 void ParseHistoryItems(history::URLRows* history_items); 96 void ParseHistoryItems(history::URLRows* history_items);
96 97
97 // Opens the favicon database file. 98 // Opens the favicon database file.
98 bool OpenDatabase(sql::Connection* db); 99 bool OpenDatabase(sql::Connection* db);
99 100
100 // Loads the urls associated with the favicons into favicon_map; 101 // Loads the urls associated with the favicons into favicon_map;
101 void ImportFaviconURLs(sql::Connection* db, FaviconMap* favicon_map); 102 void ImportFaviconURLs(sql::Connection* db, FaviconMap* favicon_map);
102 103
103 // Loads and reencodes the individual favicons. 104 // Loads and reencodes the individual favicons.
104 void LoadFaviconData(sql::Connection* db, 105 void LoadFaviconData(sql::Connection* db,
105 const FaviconMap& favicon_map, 106 const FaviconMap& favicon_map,
106 std::vector<history::ImportedFaviconUsage>* favicons); 107 std::vector<ImportedFaviconUsage>* favicons);
107 108
108 base::FilePath library_dir_; 109 base::FilePath library_dir_;
109 110
110 DISALLOW_COPY_AND_ASSIGN(SafariImporter); 111 DISALLOW_COPY_AND_ASSIGN(SafariImporter);
111 }; 112 };
112 113
113 #endif // CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_ 114 #endif // CHROME_BROWSER_IMPORTER_SAFARI_IMPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698