| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
| 16 #include "components/favicon_base/favicon_types.h" | 16 #include "components/favicon_base/favicon_types.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 | 19 |
| 20 class Profile; |
| 21 |
| 22 namespace bookmarks { |
| 20 class BookmarkNode; | 23 class BookmarkNode; |
| 21 class Profile; | 24 } |
| 22 | 25 |
| 23 namespace chrome { | 26 namespace chrome { |
| 24 struct FaviconRawBitmapResult; | 27 struct FaviconRawBitmapResult; |
| 25 } | 28 } |
| 26 | 29 |
| 27 // Observer for bookmark html output. Used only in tests. | 30 // Observer for bookmark html output. Used only in tests. |
| 28 class BookmarksExportObserver { | 31 class BookmarksExportObserver { |
| 29 public: | 32 public: |
| 30 // Is invoked on the IO thread. | 33 // Is invoked on the IO thread. |
| 31 virtual void OnExportFinished() = 0; | 34 virtual void OnExportFinished() = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 // Executes bookmark export process. | 54 // Executes bookmark export process. |
| 52 void ExportBookmarks(); | 55 void ExportBookmarks(); |
| 53 | 56 |
| 54 // content::NotificationObserver implementation. | 57 // content::NotificationObserver implementation. |
| 55 void Observe(int type, | 58 void Observe(int type, |
| 56 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
| 57 const content::NotificationDetails& details) override; | 60 const content::NotificationDetails& details) override; |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 // Recursively extracts URLs from bookmarks. | 63 // Recursively extracts URLs from bookmarks. |
| 61 void ExtractUrls(const BookmarkNode* node); | 64 void ExtractUrls(const bookmarks::BookmarkNode* node); |
| 62 | 65 |
| 63 // Executes Writer task that writes bookmarks data to html file. | 66 // Executes Writer task that writes bookmarks data to html file. |
| 64 void ExecuteWriter(); | 67 void ExecuteWriter(); |
| 65 | 68 |
| 66 // Starts async fetch for the next bookmark favicon. | 69 // Starts async fetch for the next bookmark favicon. |
| 67 // Takes single url from bookmark_urls_ and removes it from the list. | 70 // Takes single url from bookmark_urls_ and removes it from the list. |
| 68 // Returns true if there are more favicons to extract. | 71 // Returns true if there are more favicons to extract. |
| 69 bool FetchNextFavicon(); | 72 bool FetchNextFavicon(); |
| 70 | 73 |
| 71 // Favicon fetch callback. After all favicons are fetched executes | 74 // Favicon fetch callback. After all favicons are fetched executes |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // thread is used. | 106 // thread is used. |
| 104 // Before writing to the file favicons are fetched on the main thread. | 107 // Before writing to the file favicons are fetched on the main thread. |
| 105 // TODO(sky): need a callback on failure. | 108 // TODO(sky): need a callback on failure. |
| 106 void WriteBookmarks(Profile* profile, | 109 void WriteBookmarks(Profile* profile, |
| 107 const base::FilePath& path, | 110 const base::FilePath& path, |
| 108 BookmarksExportObserver* observer); | 111 BookmarksExportObserver* observer); |
| 109 | 112 |
| 110 } // namespace bookmark_html_writer | 113 } // namespace bookmark_html_writer |
| 111 | 114 |
| 112 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ | 115 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_HTML_WRITER_H_ |
| OLD | NEW |