| 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_engines| is a pointer to a vector, which is filled with the imported |
| 42 // 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::SearchEngineInfo>* search_engines, |
| 47 std::vector<ImportedFaviconUsage>* favicons); | 52 std::vector<ImportedFaviconUsage>* favicons); |
| 48 | 53 |
| 54 // Returns true if |url| should be imported as a search engine, i.e. because it |
| 55 // has replacement terms. Chrome treats such bookmarks as search engines rather |
| 56 // than true bookmarks. |
| 57 bool CanImportURLAsSearchEngine(const GURL& url, |
| 58 std::string* search_engine_url); |
| 59 |
| 49 namespace internal { | 60 namespace internal { |
| 50 | 61 |
| 51 // The file format that BookmarkHTMLReader parses starts with a heading | 62 // The file format that BookmarkHTMLReader parses starts with a heading |
| 52 // tag, which contains its title. All bookmarks and sub-folders follow, | 63 // tag, which contains its title. All bookmarks and sub-folders follow, |
| 53 // bracketed by a <DL> tag: | 64 // bracketed by a <DL> tag: |
| 54 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> | 65 // <DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ...>title</H3> |
| 55 // <DL><p> | 66 // <DL><p> |
| 56 // ... container ... | 67 // ... container ... |
| 57 // </DL><p> | 68 // </DL><p> |
| 58 // And a bookmark is presented by a <A> tag: | 69 // And a bookmark is presented by a <A> tag: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 88 bool ParseMinimumBookmarkFromLine(const std::string& line, | 99 bool ParseMinimumBookmarkFromLine(const std::string& line, |
| 89 const std::string& charset, | 100 const std::string& charset, |
| 90 base::string16* title, | 101 base::string16* title, |
| 91 GURL* url); | 102 GURL* url); |
| 92 | 103 |
| 93 } // namespace internal | 104 } // namespace internal |
| 94 | 105 |
| 95 } // namespace bookmark_html_reader | 106 } // namespace bookmark_html_reader |
| 96 | 107 |
| 97 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ | 108 #endif // CHROME_UTILITY_IMPORTER_BOOKMARK_HTML_READER_H_ |
| OLD | NEW |