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 the frame passed as an argument (which typically should be |
| 58 // the main, top-level frame). |
| 59 // |
| 60 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 61 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 62 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| 63 BLINK_EXPORT static WebData generateMHTMLHeader( |
| 64 const WebString& boundary, WebLocalFrame*); |
52 | 65 |
53 // Similar to serializeToMHTML but uses binary encoding for the MHTML parts. | 66 // 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. | 67 // savable resources underneath. |
55 BLINK_EXPORT static WebCString serializeToMHTMLUsingBinaryEncoding(WebView*)
; | 68 // |
| 69 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 70 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 71 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| 72 // |
| 73 // |frameToContentID| is used for 1) emitting cid: scheme uri links for |
| 74 // subframes and 2) emitting MIME Content-ID headers. |
| 75 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URLs". |
| 76 // Format note - |frameToContentID| should contain strings of the form |
| 77 // "<foo@bar.com>" (i.e. the strings should include the angle brackets). |
| 78 BLINK_EXPORT static WebData generateMHTMLParts( |
| 79 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding, |
| 80 const WebVector<std::pair<WebFrame*, WebString>>& frameToContentID); |
| 81 |
| 82 // Generates and returns an MHTML footer. |
| 83 // |
| 84 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 85 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 86 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| 87 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); |
56 | 88 |
57 // IMPORTANT: | 89 // IMPORTANT: |
58 // The API below is an older implementation of a pageserialization that | 90 // The API below is an older implementation of a pageserialization that |
59 // will be removed soon. | 91 // will be removed soon. |
60 | 92 |
61 // This function will serialize the specified frame to HTML data. | 93 // This function will serialize the specified frame to HTML data. |
62 // We have a data buffer to temporary saving generated html data. We will | 94 // We have a data buffer to temporary saving generated html data. We will |
63 // sequentially call WebPageSeriazlierClient once the data buffer is full. | 95 // sequentially call WebPageSeriazlierClient once the data buffer is full. |
64 // | 96 // |
65 // Return false means if no data has been serialized (i.e. because | 97 // Return false means if no data has been serialized (i.e. because |
(...skipping 17 matching lines...) Expand all Loading... |
83 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); | 115 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); |
84 // Generate the MOTW declaration. | 116 // Generate the MOTW declaration. |
85 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; | 117 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; |
86 // Generate the default base tag declaration. | 118 // Generate the default base tag declaration. |
87 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); | 119 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); |
88 }; | 120 }; |
89 | 121 |
90 } // namespace blink | 122 } // namespace blink |
91 | 123 |
92 #endif | 124 #endif |
OLD | NEW |