Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // |search_engine_keywords| is a pointer to a vector, which is filled with the | |
| 42 // imported keywords that will be imported as search engines. | |
|
Peter Kasting
2014/10/07 23:17:38
Nit: "filled with the imported search engines". (
Tapu Ghose
2014/10/12 00:58:21
Rephrased as you suggested.
However, I meant to s
| |
| 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>* search_engine_keywords, | |
| 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 | |
|
Peter Kasting
2014/10/07 23:17:38
Wait, so |url| is known to be invalid when this fu
Tapu Ghose
2014/10/12 00:58:20
After looking at the flow in chrome/utility/import
| |
| 55 // engine. Scans |url| to check if there is any replacement term, %s. If yes | |
| 56 // then substitutes the replacement term(s) with an arbitrary value. Returns | |
| 57 // true if the resulting url is a valid one. | |
|
Peter Kasting
2014/10/07 23:17:38
This is describing more what the implementation do
Tapu Ghose
2014/10/12 00:58:21
Acknowledged.
| |
| 58 // |search_engine_info| holds search engine data which is composed of |title|, | |
| 59 // |keyword| and decoded url derived from |url|. | |
|
Peter Kasting
2014/10/07 23:17:38
This is mostly a description of the structure defi
Tapu Ghose
2014/10/12 00:58:20
Acknowledged.
| |
| 60 bool CanImportURLAsSearchEngine(const GURL& url, | |
| 61 const base::string16& keyword, | |
| 62 const base::string16& title, | |
| 63 importer::URLKeywordInfo* search_engine_info); | |
|
Ilya Sherman
2014/10/07 22:08:22
nit: Please leave a blank line after this one.
Tapu Ghose
2014/10/12 00:58:20
Done.
| |
| 49 namespace internal { | 64 namespace internal { |
| 50 | 65 |
| 51 // The file format that BookmarkHTMLReader parses starts with a heading | 66 // The file format that BookmarkHTMLReader parses starts with a heading |
| 52 // tag, which contains its title. All bookmarks and sub-folders follow, | 67 // tag, which contains its title. All bookmarks and sub-folders follow, |
| 53 // bracketed by a <DL> tag: | 68 // bracketed by a <DL> tag: |
| 54 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> | 69 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> |
| 55 // <DL><p> | 70 // <DL><p> |
| 56 // ... container ... | 71 // ... container ... |
| 57 // </DL><p> | 72 // </DL><p> |
| 58 // And a bookmark is presented by a <A> tag: | 73 // And a bookmark is presented by a <A> tag: |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 88 bool ParseMinimumBookmarkFromLine(const std::string& line, | 103 bool ParseMinimumBookmarkFromLine(const std::string& line, |
| 89 const std::string& charset, | 104 const std::string& charset, |
| 90 base::string16* title, | 105 base::string16* title, |
| 91 GURL* url); | 106 GURL* url); |
| 92 | 107 |
| 93 } // namespace internal | 108 } // namespace internal |
| 94 | 109 |
| 95 } // namespace bookmark_html_reader | 110 } // namespace bookmark_html_reader |
| 96 | 111 |
| 97 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ | 112 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ |
| OLD | NEW |