| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
| 6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // the directory already exists. | 102 // the directory already exists. |
| 103 bool CreateOfflineURLDirectory(const GURL& url); | 103 bool CreateOfflineURLDirectory(const GURL& url); |
| 104 // Saves the |data| for image at |imageURL| to disk, for main URL |url|; | 104 // Saves the |data| for image at |imageURL| to disk, for main URL |url|; |
| 105 // puts path of saved file in |path| and returns whether save was successful. | 105 // puts path of saved file in |path| and returns whether save was successful. |
| 106 bool SaveImage(const GURL& url, | 106 bool SaveImage(const GURL& url, |
| 107 const GURL& imageURL, | 107 const GURL& imageURL, |
| 108 const std::string& data, | 108 const std::string& data, |
| 109 std::string* image_name); | 109 std::string* image_name); |
| 110 // Saves images in |images| array to disk and replaces references in |html| to | 110 // Saves images in |images| array to disk and replaces references in |html| to |
| 111 // local path. Returns updated html. | 111 // local path. Returns updated html. |
| 112 // If some images could not be saved, returns an empty string. It is the |
| 113 // responsibility of the caller to clean the partial processing. |
| 112 std::string SaveAndReplaceImagesInHTML( | 114 std::string SaveAndReplaceImagesInHTML( |
| 113 const GURL& url, | 115 const GURL& url, |
| 114 const std::string& html, | 116 const std::string& html, |
| 115 const std::vector<dom_distiller::DistillerViewerInterface::ImageInfo>& | 117 const std::vector<dom_distiller::DistillerViewerInterface::ImageInfo>& |
| 116 images); | 118 images); |
| 117 // Saves |html| to disk in the correct location for |url|; returns success. | 119 // Saves |html| to disk in the correct location for |url|; returns success. |
| 118 bool SaveHTMLForURL(std::string html, const GURL& url); | 120 bool SaveHTMLForURL(std::string html, const GURL& url); |
| 119 // Downloads |url|, depending on |offlineURLExists| state. | 121 // Downloads |url|, depending on |offlineURLExists| state. |
| 120 virtual void DownloadURL(GURL url, bool offlineURLExists); | 122 virtual void DownloadURL(GURL url, bool offlineURLExists); |
| 121 // Saves distilled html to disk, including saving images and main file. | 123 // Saves distilled html to disk, including saving images and main file. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 144 bool working_; | 146 bool working_; |
| 145 base::FilePath base_directory_; | 147 base::FilePath base_directory_; |
| 146 GURL distilled_url_; | 148 GURL distilled_url_; |
| 147 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; | 149 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; |
| 148 base::CancelableTaskTracker task_tracker_; | 150 base::CancelableTaskTracker task_tracker_; |
| 149 | 151 |
| 150 DISALLOW_COPY_AND_ASSIGN(URLDownloader); | 152 DISALLOW_COPY_AND_ASSIGN(URLDownloader); |
| 151 }; | 153 }; |
| 152 | 154 |
| 153 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ | 155 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ |
| OLD | NEW |