| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const CreateArchiveParams& create_archive_params, | 51 const CreateArchiveParams& create_archive_params, |
| 52 const std::string& signal_data, |
| 52 const CreateArchiveCallback& callback) override; | 53 const CreateArchiveCallback& callback) override; |
| 53 | 54 |
| 54 protected: | 55 protected: |
| 55 // Allows to overload the archiver for testing. | 56 // Allows to overload the archiver for testing. |
| 56 OfflinePageMHTMLArchiver(); | 57 OfflinePageMHTMLArchiver(); |
| 57 | 58 |
| 58 // Try to generate MHTML. | 59 // Try to generate MHTML. |
| 59 // Might be overridden for testing purpose. | 60 // Might be overridden for testing purpose. |
| 60 virtual void GenerateMHTML(const base::FilePath& archives_dir, | 61 virtual void GenerateMHTML(const base::FilePath& archives_dir, |
| 61 const CreateArchiveParams& create_archive_params); | 62 const CreateArchiveParams& create_archive_params); |
| 62 | 63 |
| 63 // Callback for Generating MHTML. | 64 // Callback for Generating MHTML. |
| 64 void OnGenerateMHTMLDone(const GURL& url, | 65 void OnGenerateMHTMLDone(const GURL& url, |
| 65 const base::FilePath& file_path, | 66 const base::FilePath& file_path, |
| 66 const base::string16& title, | 67 const base::string16& title, |
| 67 int64_t file_size); | 68 int64_t file_size); |
| 68 | 69 |
| 69 // Checks whether the page to be saved has security error when loaded over | 70 // 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 | 71 // HTTPS. Saving a page will fail if that is the case. HTTP connections are |
| 71 // not affected. | 72 // not affected. |
| 72 virtual bool HasConnectionSecurityError(); | 73 virtual bool HasConnectionSecurityError(); |
| 73 | 74 |
| 74 // Reports failure to create archive a page to the client that requested it. | 75 // Reports failure to create archive a page to the client that requested it. |
| 75 void ReportFailure(ArchiverResult result); | 76 void ReportFailure(ArchiverResult result); |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 // Contents of the web page to be serialized. Not owned. | 79 // Contents of the web page to be serialized. Not owned. |
| 79 content::WebContents* web_contents_; | 80 content::WebContents* web_contents_; |
| 80 | 81 |
| 82 // Saved signal data corresponding to this page load. This is a way of logging |
| 83 // signals that have been received as of the time of the page capture to help |
| 84 // training a recognizer for when to take a snapshot. |
| 85 std::string signal_data_; |
| 86 |
| 81 CreateArchiveCallback callback_; | 87 CreateArchiveCallback callback_; |
| 82 | 88 |
| 83 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; | 89 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; |
| 84 | 90 |
| 85 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); | 91 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); |
| 86 }; | 92 }; |
| 87 | 93 |
| 88 } // namespace offline_pages | 94 } // namespace offline_pages |
| 89 | 95 |
| 90 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 96 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| OLD | NEW |