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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | |
12 | 13 |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "components/offline_pages/core/offline_page_archiver.h" | 18 #include "components/offline_pages/core/offline_page_archiver.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class FilePath; | 21 class FilePath; |
21 } // namespace base | 22 } // namespace base |
(...skipping 20 matching lines...) Expand all Loading... | |
42 // } | 43 // } |
43 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { | 44 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { |
44 public: | 45 public: |
45 | 46 |
46 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); | 47 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); |
47 ~OfflinePageMHTMLArchiver() override; | 48 ~OfflinePageMHTMLArchiver() override; |
48 | 49 |
49 // OfflinePageArchiver implementation: | 50 // OfflinePageArchiver implementation: |
50 void CreateArchive(const base::FilePath& archives_dir, | 51 void CreateArchive(const base::FilePath& archives_dir, |
51 const CreateArchiveParams& create_archive_params, | 52 const CreateArchiveParams& create_archive_params, |
53 const std::vector<std::string>& signal_data, | |
52 const CreateArchiveCallback& callback) override; | 54 const CreateArchiveCallback& callback) override; |
53 | 55 |
54 protected: | 56 protected: |
55 // Allows to overload the archiver for testing. | 57 // Allows to overload the archiver for testing. |
56 OfflinePageMHTMLArchiver(); | 58 OfflinePageMHTMLArchiver(); |
57 | 59 |
58 // Try to generate MHTML. | 60 // Try to generate MHTML. |
59 // Might be overridden for testing purpose. | 61 // Might be overridden for testing purpose. |
60 virtual void GenerateMHTML(const base::FilePath& archives_dir, | 62 virtual void GenerateMHTML(const base::FilePath& archives_dir, |
61 const CreateArchiveParams& create_archive_params); | 63 const CreateArchiveParams& create_archive_params); |
62 | 64 |
63 // Callback for Generating MHTML. | 65 // Callback for Generating MHTML. |
64 void OnGenerateMHTMLDone(const GURL& url, | 66 void OnGenerateMHTMLDone(const GURL& url, |
65 const base::FilePath& file_path, | 67 const base::FilePath& file_path, |
66 const base::string16& title, | 68 const base::string16& title, |
67 int64_t file_size); | 69 int64_t file_size); |
68 | 70 |
69 // Checks whether the page to be saved has security error when loaded over | 71 // 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 | 72 // HTTPS. Saving a page will fail if that is the case. HTTP connections are |
71 // not affected. | 73 // not affected. |
72 virtual bool HasConnectionSecurityError(); | 74 virtual bool HasConnectionSecurityError(); |
73 | 75 |
74 // Reports failure to create archive a page to the client that requested it. | 76 // Reports failure to create archive a page to the client that requested it. |
75 void ReportFailure(ArchiverResult result); | 77 void ReportFailure(ArchiverResult result); |
76 | 78 |
77 private: | 79 private: |
78 // Contents of the web page to be serialized. Not owned. | 80 // Contents of the web page to be serialized. Not owned. |
79 content::WebContents* web_contents_; | 81 content::WebContents* web_contents_; |
80 | 82 |
83 // Saved signal data corresponding to this page load. This is a way of logging | |
84 // signals that have been received as of the time of the page capture to help | |
85 // training a recognizer for when to take a snapshot. | |
fgorski
2017/02/07 22:06:07
s/training a recognizer/improving a component/
| |
86 std::vector<std::string> signal_data_; | |
87 | |
81 CreateArchiveCallback callback_; | 88 CreateArchiveCallback callback_; |
82 | 89 |
83 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; | 90 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; |
84 | 91 |
85 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); | 92 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); |
86 }; | 93 }; |
87 | 94 |
88 } // namespace offline_pages | 95 } // namespace offline_pages |
89 | 96 |
90 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 97 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
OLD | NEW |