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

Side by Side Diff: chrome/utility/importer/bookmark_html_reader.h

Issue 616763002: Importing certain bookmarks from firefox and HTML file as search engines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ 5 #ifndef CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_
6 #define CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ 6 #define CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/common/importer/importer_data_types.h"
13 14
14 class GURL; 15 class GURL;
15 struct ImportedBookmarkEntry; 16 struct ImportedBookmarkEntry;
16 struct ImportedFaviconUsage; 17 struct ImportedFaviconUsage;
17 18
18 namespace base { 19 namespace base {
19 class FilePath; 20 class FilePath;
20 class Time; 21 class Time;
21 } 22 }
22 23
23 namespace bookmark_html_reader { 24 namespace bookmark_html_reader {
24 25
25 // Imports the bookmarks from the specified file. 26 // Imports the bookmarks from the specified file.
26 // 27 //
27 // |cancellation_callback| is polled to query if the import should be cancelled; 28 // |cancellation_callback| is polled to query if the import should be cancelled;
28 // if it returns |true| at any time the import will be cancelled. If 29 // if it returns |true| at any time the import will be cancelled. If
29 // |cancellation_callback| is a null callback the import will run to completion. 30 // |cancellation_callback| is a null callback the import will run to completion.
30 // 31 //
31 // |valid_url_callback| is called to determine if a specified URL is valid for 32 // |valid_url_callback| is called to determine if a specified URL is valid for
32 // import; it returns |true| if it is. If |valid_url_callback| is a null 33 // import; it returns |true| if it is. If |valid_url_callback| is a null
33 // callback, all URLs are considered to be valid. 34 // callback, all URLs are considered to be valid.
34 // 35 //
35 // |file_path| is the path of the file on disk to import. 36 // |file_path| is the path of the file on disk to import.
36 // 37 //
37 // |bookmarks| is a pointer to a vector, which is filled with the imported 38 // |bookmarks| is a pointer to a vector, which is filled with the imported
38 // bookmarks. It may not be NULL. 39 // bookmarks. It may not be NULL.
39 // 40 //
41 // |url_keywords| is a pointer toa vector, which is filled with the imported
Ilya Sherman 2014/09/30 20:54:12 nit: "toa" -> "to a"
Tapu Ghose 2014/10/07 02:02:44 Done.
42 // keywords that will be imported as search engines.
43 //
40 // |favicons| is a pointer to a vector, which is filled with the favicons of 44 // |favicons| is a pointer to a vector, which is filled with the favicons of
41 // imported bookmarks. It may be NULL, in which case favicons are not imported. 45 // imported bookmarks. It may be NULL, in which case favicons are not imported.
42 void ImportBookmarksFile( 46 void ImportBookmarksFile(
43 const base::Callback<bool(void)>& cancellation_callback, 47 const base::Callback<bool(void)>& cancellation_callback,
44 const base::Callback<bool(const GURL&)>& valid_url_callback, 48 const base::Callback<bool(const GURL&)>& valid_url_callback,
45 const base::FilePath& file_path, 49 const base::FilePath& file_path,
46 std::vector<ImportedBookmarkEntry>* bookmarks, 50 std::vector<ImportedBookmarkEntry>* bookmarks,
51 std::vector<importer::URLKeywordInfo>* url_keywords,
Peter Kasting 2014/10/01 01:02:55 "URL keyword" seems like a rather confusing name.
Tapu Ghose 2014/10/07 02:02:44 Renaming the variable to search_engine_keywords wh
47 std::vector<ImportedFaviconUsage>* favicons); 52 std::vector<ImportedFaviconUsage>* favicons);
48 53
54 // Checks if a bookmark that contains invalid |url| can be imported as search
55 // engine. Scan |url| to check if there is any replacement term, %s. If yes then
Peter Kasting 2014/10/01 01:02:55 Nit: Scan -> scans, substitute -> substitutes.
Tapu Ghose 2014/10/07 02:02:44 Done.
56 // substitute the replacement term(s) with any arbitrary value. Returns true if
Peter Kasting 2014/10/01 01:02:55 What does "with any arbitrary value" mean? Surely
Tapu Ghose 2014/10/07 02:02:44 I meant "an" here.
57 // the resulted url is a valid one.
Ilya Sherman 2014/09/30 20:54:12 nit: "resulted" -> "resulting"
Tapu Ghose 2014/10/07 02:02:44 Done.
58 // |decoded_url| holds decoded raw url of |url|.
59 bool CanImportURLAsSearchEngine(const GURL& url, base::string16* decoded_url);
60
49 namespace internal { 61 namespace internal {
50 62
51 // The file format that BookmarkHTMLReader parses starts with a heading 63 // The file format that BookmarkHTMLReader parses starts with a heading
52 // tag, which contains its title. All bookmarks and sub-folders follow, 64 // tag, which contains its title. All bookmarks and sub-folders follow,
53 // bracketed by a <DL> tag: 65 // bracketed by a <DL> tag:
54 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> 66 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3>
55 // <DL><p> 67 // <DL><p>
56 // ... container ... 68 // ... container ...
57 // </DL><p> 69 // </DL><p>
58 // And a bookmark is presented by a <A> tag: 70 // And a bookmark is presented by a <A> tag:
(...skipping 29 matching lines...) Expand all
88 bool ParseMinimumBookmarkFromLine(const std::string& line, 100 bool ParseMinimumBookmarkFromLine(const std::string& line,
89 const std::string& charset, 101 const std::string& charset,
90 base::string16* title, 102 base::string16* title,
91 GURL* url); 103 GURL* url);
92 104
93 } // namespace internal 105 } // namespace internal
94 106
95 } // namespace bookmark_html_reader 107 } // namespace bookmark_html_reader
96 108
97 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ 109 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698