| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // model->SavePage(url, std::move(archiver), callback); | 41 // model->SavePage(url, std::move(archiver), callback); |
| 42 // } | 42 // } |
| 43 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { | 43 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { |
| 44 public: | 44 public: |
| 45 | 45 |
| 46 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); | 46 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); |
| 47 ~OfflinePageMHTMLArchiver() override; | 47 ~OfflinePageMHTMLArchiver() override; |
| 48 | 48 |
| 49 // OfflinePageArchiver implementation: | 49 // OfflinePageArchiver implementation: |
| 50 void CreateArchive(const base::FilePath& archives_dir, | 50 void CreateArchive(const base::FilePath& archives_dir, |
| 51 int64_t archive_id, | 51 const CreateArchiveParams& create_archive_params, |
| 52 const CreateArchiveCallback& callback) override; | 52 const CreateArchiveCallback& callback) override; |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 // Allows to overload the archiver for testing. | 55 // Allows to overload the archiver for testing. |
| 56 OfflinePageMHTMLArchiver(); | 56 OfflinePageMHTMLArchiver(); |
| 57 | 57 |
| 58 // Try to generate MHTML. | 58 // Try to generate MHTML. |
| 59 // Might be overridden for testing purpose. | 59 // Might be overridden for testing purpose. |
| 60 virtual void GenerateMHTML(const base::FilePath& archives_dir, | 60 virtual void GenerateMHTML(const base::FilePath& archives_dir, |
| 61 int64_t archive_id); | 61 const CreateArchiveParams& create_archive_params); |
| 62 | 62 |
| 63 // Callback for Generating MHTML. | 63 // Callback for Generating MHTML. |
| 64 void OnGenerateMHTMLDone(const GURL& url, | 64 void OnGenerateMHTMLDone(const GURL& url, |
| 65 const base::FilePath& file_path, | 65 const base::FilePath& file_path, |
| 66 const base::string16& title, | 66 const base::string16& title, |
| 67 int64_t file_size); | 67 int64_t file_size); |
| 68 | 68 |
| 69 // Checks whether the page to be saved has security error when loaded over | 69 // Checks whether the page to be saved has security error when loaded over |
| 70 // HTTPS. Saving a page will fail if that is the case. HTTP connections are | 70 // HTTPS. Saving a page will fail if that is the case. HTTP connections are |
| 71 // not affected. | 71 // not affected. |
| 72 virtual bool HasConnectionSecurityError(); | 72 virtual bool HasConnectionSecurityError(); |
| 73 | 73 |
| 74 // Reports failure to create archive a page to the client that requested it. | 74 // Reports failure to create archive a page to the client that requested it. |
| 75 void ReportFailure(ArchiverResult result); | 75 void ReportFailure(ArchiverResult result); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Contents of the web page to be serialized. Not owned. | 78 // Contents of the web page to be serialized. Not owned. |
| 79 content::WebContents* web_contents_; | 79 content::WebContents* web_contents_; |
| 80 | 80 |
| 81 CreateArchiveCallback callback_; | 81 CreateArchiveCallback callback_; |
| 82 | 82 |
| 83 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; | 83 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); | 85 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace offline_pages | 88 } // namespace offline_pages |
| 89 | 89 |
| 90 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 90 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| OLD | NEW |