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? |
48 class WebPageSerializer { | 52 class WebPageSerializer { |
49 public: | 53 public: |
50 // Serializes the WebView contents to a MHTML representation. | 54 // Generates and returns an MHTML header. |
51 BLINK_EXPORT static WebCString serializeToMHTML(WebView*); | 55 // |
56 // Contents of the header (i.e. title and mime type) will be based | |
57 // on |topLevelFrame|. | |
58 // | |
59 // Same |boundary| needs to used for all generateMHTMLHeader and | |
60 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
61 // MHTML document (see also generateMHTMLBoundary method). | |
62 BLINK_EXPORT static WebData generateMHTMLHeader( | |
63 const WebString& boundary, WebLocalFrame* topLevelFrame); | |
dcheng
2015/12/09 08:02:37
Omit topLevelFrame here: I mostly find it confusin
Łukasz Anforowicz
2015/12/09 17:33:57
Done. OTOH, I've expanded the doc comment to expl
| |
52 | 64 |
53 // Similar to serializeToMHTML but uses binary encoding for the MHTML parts. | 65 // Generates and returns MHTML parts for the given frame and all the |
54 // This results in a smaller MHTML file but it might not be supported by oth er browsers. | 66 // savable resources underneath. |
55 BLINK_EXPORT static WebCString serializeToMHTMLUsingBinaryEncoding(WebView*) ; | 67 // |
68 // Same |boundary| needs to used for all generateMHTMLHeader and | |
69 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
70 // MHTML document (see also generateMHTMLBoundary method). | |
71 // | |
72 // |frameToContentID| is used for 1) emitting cid: scheme uri links for | |
73 // subframes and 2) emitting MIME Content-ID headers. | |
74 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs". | |
75 // Format note - |frameToContentID| should contain strings of the form | |
76 // "<foo@bar.com>" (i.e. the strings should include the angle brackets). | |
77 BLINK_EXPORT static WebData generateMHTMLParts( | |
78 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding, | |
79 const WebVector<std::pair<WebFrame*, WebString>>& frameToContentID); | |
80 | |
81 // Generates and returns an MHTML footer. | |
82 // | |
83 // Same |boundary| needs to used for all generateMHTMLHeader and | |
84 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | |
85 // MHTML document (see also generateMHTMLBoundary method). | |
86 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); | |
56 | 87 |
57 // IMPORTANT: | 88 // IMPORTANT: |
58 // The API below is an older implementation of a pageserialization that | 89 // The API below is an older implementation of a pageserialization that |
59 // will be removed soon. | 90 // will be removed soon. |
60 | 91 |
61 // This function will serialize the specified frame to HTML data. | 92 // This function will serialize the specified frame to HTML data. |
62 // We have a data buffer to temporary saving generated html data. We will | 93 // We have a data buffer to temporary saving generated html data. We will |
63 // sequentially call WebPageSeriazlierClient once the data buffer is full. | 94 // sequentially call WebPageSeriazlierClient once the data buffer is full. |
64 // | 95 // |
65 // Return false means if no data has been serialized (i.e. because | 96 // 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); | 119 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset); |
89 // Generate the MOTW declaration. | 120 // Generate the MOTW declaration. |
90 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; | 121 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; |
91 // Generate the default base tag declaration. | 122 // Generate the default base tag declaration. |
92 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); | 123 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); |
93 }; | 124 }; |
94 | 125 |
95 } // namespace blink | 126 } // namespace blink |
96 | 127 |
97 #endif | 128 #endif |
OLD | NEW |