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

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_reader.h

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix again 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 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_BOOKMARKS_BOOKMARK_HTML_READER_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_READER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/string16.h"
13 #include "base/time.h"
tfarina 2013/05/10 19:58:30 you can also forward declare this
Avi (use Gerrit) 2013/05/10 20:29:37 Done.
14 #include "googleurl/src/gurl.h"
tfarina 2013/05/10 19:58:30 can you forward declare this or the base::Callback
Avi (use Gerrit) 2013/05/10 20:29:37 Done.
15
16 struct ImportedBookmarkEntry;
17
18 namespace base {
19 class FilePath;
20 }
21
22 namespace history {
23 struct ImportedFaviconUsage;
24 }
25
26 namespace bookmark_html_reader {
27
28 // Imports the bookmarks from the specified file.
29 //
30 // |cancellation_callback| is polled to query if the import should be cancelled;
31 // if it returns |true| at any time the import will be cancelled. If
32 // |cancellation_callback| is NULL the import will run to completion.
33 //
34 // |valid_url_callback| is called to determine if a specified URL is valid for
35 // import; it returns |true| if it is. If |valid_url_callback| is NULL, all
36 // URLs are considered to be valid.
37 //
38 // |file_path| is the path of the file on disk to import.
39 //
40 // |bookmarks| is a pointer to a vector, which is filled with the imported
41 // bookmarks. It may not be NULL.
42 //
43 // |favicons| is a pointer to a vector, which is filled with the favicons of
44 // imported bookmarks. It may be NULL, in which case favicons are not imported.
45 void ImportBookmarksFile(
46 base::Callback<bool(void)>* cancellation_callback,
47 base::Callback<bool(const GURL&)>* valid_url_callback,
48 const base::FilePath& file_path,
49 std::vector<ImportedBookmarkEntry>* bookmarks,
50 std::vector<history::ImportedFaviconUsage>* favicons);
51
52 namespace exposed_for_testing {
53
54 // The file format that BookmarkHTMLReader parses starts with a heading
55 // tag, which contains its title. All bookmarks and sub-folders follow,
56 // bracketed by a <DL> tag:
57 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3>
58 // <DL><p>
59 // ... container ...
60 // </DL><p>
61 // And a bookmark is presented by a <A> tag:
62 // <DT><A HREF="url" SHORTCUTURL="shortcut" ADD_DATE="11213014"...>name</A>
63 // Reference: http://kb.mozillazine.org/Bookmarks.html
64
65 bool ParseCharsetFromLine(const std::string& line,
66 std::string* charset);
67 bool ParseFolderNameFromLine(const std::string& line,
68 const std::string& charset,
69 base::string16* folder_name,
70 bool* is_toolbar_folder,
71 base::Time* add_date);
72 // See above, this will also put the data: URL of the favicon into |*favicon|
73 // if there is a favicon given. |post_data| is set for POST base keywords to
74 // the contents of the actual POST (with %s for the search term).
75 bool ParseBookmarkFromLine(const std::string& line,
76 const std::string& charset,
77 base::string16* title,
78 GURL* url,
79 GURL* favicon,
80 base::string16* shortcut,
81 base::Time* add_date,
82 base::string16* post_data);
83 // Save bookmarks imported from browsers with Firefox 2 compatible bookmark
84 // systems such as Epiphany. This bookmark format is the same as that of the
85 // basic Firefox 2 bookmark, but it misses additional properties and uses
86 // lower-case tag:
87 // ...<h1>Bookmarks</h1><dl>
88 // <dt><a href="url">name</a></dt>
89 // <dt><a href="url">name</a></dt>
90 // </dl>
91 bool ParseMinimumBookmarkFromLine(const std::string& line,
92 const std::string& charset,
93 base::string16* title,
94 GURL* url);
95
96 } // namespace exposed_for_testing
97
98 } // namespace bookmark_html_reader
99
100 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698