OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebPageSerializer_h | 31 #ifndef WebPageSerializer_h |
32 #define WebPageSerializer_h | 32 #define WebPageSerializer_h |
33 | 33 |
34 #include "../platform/WebCString.h" | 34 #include "../platform/WebCString.h" |
35 #include "../platform/WebCommon.h" | 35 #include "../platform/WebCommon.h" |
36 #include "../platform/WebData.h" | |
37 #include "../platform/WebString.h" | |
36 #include "../platform/WebURL.h" | 38 #include "../platform/WebURL.h" |
37 #include "WebFrame.h" | 39 #include "../platform/WebVector.h" |
40 | |
41 #include <utility> | |
38 | 42 |
39 namespace blink { | 43 namespace blink { |
40 | 44 |
41 class WebPageSerializerClient; | 45 class WebPageSerializerClient; |
42 class WebString; | 46 class WebFrame; |
43 class WebView; | 47 class WebLocalFrame; |
44 template <typename T> class WebVector; | 48 template <typename T> class WebVector; |
45 | 49 |
46 // Get html data by serializing all frames of current page with lists | 50 // Serialization of frame contents into html or mhtml. |
47 // which contain all resource links that have local copy. | 51 // TODO(lukasza): Rename this class to WebFrameSerializer? |
ncarter (slow)
2015/12/04 22:54:48
This rename sounds like a good idea.
Łukasz Anforowicz
2015/12/05 00:18:39
Acknowledged.
| |
48 class WebPageSerializer { | 52 class WebPageSerializer { |
49 public: | 53 public: |
50 // Serializes the WebView contents to a MHTML representation. | 54 // Generates a random/unique boundary that can be used as a separator of |
51 BLINK_EXPORT static WebCString serializeToMHTML(WebView*); | 55 // MHTML parts. |
56 BLINK_EXPORT static WebString generateMHTMLBoundary(); | |
52 | 57 |
53 // Similar to serializeToMHTML but uses binary encoding for the MHTML parts. | 58 // Generates and returns an MHTML header. |
54 // This results in a smaller MHTML file but it might not be supported by oth er browsers. | 59 // |
55 BLINK_EXPORT static WebCString serializeToMHTMLUsingBinaryEncoding(WebView*) ; | 60 // Contents of the header (i.e. title and mime type) will be based |
61 // on |topLevelFrame|. | |
62 // | |
63 // Same |boundary| needs to used for all generateMHTMLHeader and | |
64 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
65 // MHTML document (see also generateMHTMLBoundary method). | |
66 BLINK_EXPORT static WebData generateMHTMLHeader( | |
67 const WebString& boundary, WebLocalFrame* topLevelFrame); | |
68 | |
69 // Generates and returns MHTML parts for the given frame and all the | |
70 // savable resources underneath. | |
71 // | |
72 // Same |boundary| needs to used for all generateMHTMLHeader and | |
73 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
74 // MHTML document (see also generateMHTMLBoundary method). | |
75 // | |
76 // |frameToContentID| is used for 1) emitting cid: scheme uri links for | |
77 // subframes and 2) emitting MIME Content-ID headers. | |
78 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs". | |
79 // Format note - |frameToContentID| should contain strings of the form | |
80 // "<foo@bar.com>" (i.e. the strings should include the angle brackets). | |
81 BLINK_EXPORT static WebData generateMHTMLParts( | |
82 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding, | |
83 const WebVector<std::pair<WebFrame*, WebString>>& frameToContentID); | |
84 | |
85 // Generates and returns an MHTML footer. | |
86 // | |
87 // Same |boundary| needs to used for all generateMHTMLHeader and | |
88 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
89 // MHTML document (see also generateMHTMLBoundary method). | |
90 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); | |
56 | 91 |
57 // IMPORTANT: | 92 // IMPORTANT: |
58 // The API below is an older implementation of a pageserialization that | 93 // The API below is an older implementation of a pageserialization that |
59 // will be removed soon. | 94 // will be removed soon. |
60 | 95 |
61 // This function will serialize the specified frame to HTML data. | 96 // This function will serialize the specified frame to HTML data. |
62 // We have a data buffer to temporary saving generated html data. We will | 97 // We have a data buffer to temporary saving generated html data. We will |
63 // sequentially call WebPageSeriazlierClient once the data buffer is full. | 98 // sequentially call WebPageSeriazlierClient once the data buffer is full. |
64 // | 99 // |
65 // Return false means if no data has been serialized (i.e. because | 100 // Return false means if no data has been serialized (i.e. because |
(...skipping 22 matching lines...) Expand all Loading... | |
88 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset); | 123 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset); |
89 // Generate the MOTW declaration. | 124 // Generate the MOTW declaration. |
90 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; | 125 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; |
91 // Generate the default base tag declaration. | 126 // Generate the default base tag declaration. |
92 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); | 127 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); |
93 }; | 128 }; |
94 | 129 |
95 } // namespace blink | 130 } // namespace blink |
96 | 131 |
97 #endif | 132 #endif |
OLD | NEW |