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

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

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleaner 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
(Empty)
1 // Copyright (c) 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_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_
6 #define CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_
7
8 #include <set>
tfarina 2013/05/07 01:03:19 looks like you can remove this include.
Avi (use Gerrit) 2013/05/07 03:11:28 Yes! Good catch.
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "chrome/browser/importer/importer.h"
16 #include "chrome/browser/importer/profile_writer.h"
17
18 class GURL;
19
20 namespace base {
21 class FilePath;
22 }
23
24 namespace history {
25 struct ImportedFaviconUsage;
26 }
27
28 // Importer for bookmarks files.
29 class BookmarksFileImporter : public Importer {
30 public:
31 BookmarksFileImporter();
32
33 // Importer:
34 virtual void StartImport(const importer::SourceProfile& source_profile,
35 uint16 items,
36 ImporterBridge* bridge) OVERRIDE;
37
38 // Imports the bookmarks from the specified file. |favicons| may be null, in
39 // which case favicons are not parsed. |cancellation_callback| is polled to
40 // query if the import should be cancelled; if it returns |true| at any time
41 // the import will be cancelled. If |cancellation_callback| is NULL the
42 // import will run to completion.
43 static void ImportBookmarksFile(
44 const base::FilePath& file_path,
45 base::Callback<bool(void)>* cancellation_callback,
46 std::vector<ProfileWriter::BookmarkEntry>* bookmarks,
47 std::vector<history::ImportedFaviconUsage>* favicons);
48
49 private:
50 FRIEND_TEST_ALL_PREFIXES(BookmarksFileImporterTest, ParseTests);
51
52 virtual ~BookmarksFileImporter();
53
54 // Helper methods exposed for testing.
55
56 // The file format that BookmarksFileImporter parses starts with a heading
57 // tag, which contains its title. All bookmarks and sub-folders follow,
58 // bracketed by a <DL> tag:
59 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3>
60 // <DL><p>
61 // ... container ...
62 // </DL><p>
63 // And a bookmark is presented by a <A> tag:
64 // <DT><A HREF="url" SHORTCUTURL="shortcut" ADD_DATE="11213014"...>name</A>
65 // Reference: http://kb.mozillazine.org/Bookmarks.html
66
67 static bool ParseCharsetFromLine(const std::string& line,
68 std::string* charset);
69 static bool ParseFolderNameFromLine(const std::string& line,
70 const std::string& charset,
71 string16* folder_name,
72 bool* is_toolbar_folder,
73 base::Time* add_date);
74 // See above, this will also put the data: URL of the favicon into |*favicon|
75 // if there is a favicon given. |post_data| is set for POST base keywords to
76 // the contents of the actual POST (with %s for the search term).
77 static bool ParseBookmarkFromLine(const std::string& line,
78 const std::string& charset,
79 string16* title,
80 GURL* url,
81 GURL* favicon,
82 string16* shortcut,
83 base::Time* add_date,
84 string16* post_data);
85 // Save bookmarks imported from browsers with Firefox 2 compatible bookmark
86 // systems such as Epiphany. This bookmark format is the same as that of the
87 // basic Firefox 2 bookmark, but it misses additional properties and uses
88 // lower-case tag:
89 // ...<h1>Bookmarks</h1><dl>
90 // <dt><a href="url">name</a></dt>
91 // <dt><a href="url">name</a></dt>
92 // </dl>
93 static bool ParseMinimumBookmarkFromLine(const std::string& line,
94 const std::string& charset,
95 string16* title,
96 GURL* url);
97
98 DISALLOW_COPY_AND_ASSIGN(BookmarksFileImporter);
99 };
100
101 #endif // CHROME_BROWSER_IMPORTER_BOOKMARKS_FILE_IMPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698