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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Contents of the header (i.e. title and mime type) will be based | 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 | 57 // on the frame passed as an argument (which typically should be |
58 // the main, top-level frame). | 58 // the main, top-level frame). |
59 // | 59 // |
60 // Same |boundary| needs to used for all generateMHTMLHeader and | 60 // Same |boundary| needs to used for all generateMHTMLHeader and |
61 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 61 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
62 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 62 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
63 BLINK_EXPORT static WebData generateMHTMLHeader( | 63 BLINK_EXPORT static WebData generateMHTMLHeader( |
64 const WebString& boundary, WebLocalFrame*); | 64 const WebString& boundary, WebLocalFrame*); |
65 | 65 |
66 // Generates and returns MHTML parts for the given frame and all the | 66 // Delegate for controling the behavior of generateMHTMLParts method. |
| 67 class MHTMLPartsGenerationDelegate { |
| 68 public: |
| 69 // Tells whether to skip serialization of a subresource with a given URI
. |
| 70 // Used to deduplicate resources across multiple frames. |
| 71 virtual bool shouldSkipResource(const WebURL&) = 0; |
| 72 |
| 73 // Returns a Content-ID to be used for the given frame. |
| 74 // See rfc2557 - section 8.3 - "Use of the Content-ID header and CID URL
s". |
| 75 // Format note - the returned string should be of the form "<foo@bar.com
>" |
| 76 // (i.e. the strings should include the angle brackets). |
| 77 virtual WebString getContentID(const WebFrame&) = 0; |
| 78 }; |
| 79 |
| 80 // Generates and returns MHTML parts for the given frame and the |
67 // savable resources underneath. | 81 // savable resources underneath. |
68 // | 82 // |
69 // Same |boundary| needs to used for all generateMHTMLHeader and | 83 // Same |boundary| needs to used for all generateMHTMLHeader and |
70 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 84 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
71 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 85 // 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( | 86 BLINK_EXPORT static WebData generateMHTMLParts( |
79 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding, | 87 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding, |
80 const WebVector<std::pair<WebFrame*, WebString>>& frameToContentID); | 88 MHTMLPartsGenerationDelegate&); |
81 | 89 |
82 // Generates and returns an MHTML footer. | 90 // Generates and returns an MHTML footer. |
83 // | 91 // |
84 // Same |boundary| needs to used for all generateMHTMLHeader and | 92 // Same |boundary| needs to used for all generateMHTMLHeader and |
85 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 93 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
86 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 94 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
87 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); | 95 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); |
88 | 96 |
89 // IMPORTANT: | 97 // IMPORTANT: |
90 // The API below is an older implementation of a pageserialization that | 98 // The API below is an older implementation of a pageserialization that |
91 // will be removed soon. | 99 // will be removed soon. |
92 | 100 |
93 // This function will serialize the specified frame to HTML data. | 101 // This function will serialize the specified frame to HTML data. |
94 // We have a data buffer to temporary saving generated html data. We will | 102 // We have a data buffer to temporary saving generated html data. We will |
95 // sequentially call WebPageSeriazlierClient once the data buffer is full. | 103 // sequentially call WebPageSerializerClient once the data buffer is full. |
96 // | 104 // |
97 // Return false means if no data has been serialized (i.e. because | 105 // Return false means if no data has been serialized (i.e. because |
98 // the target frame didn't have a valid url). | 106 // the target frame didn't have a valid url). |
99 // | 107 // |
100 // The parameter frame specifies which frame need to be serialized. | 108 // The parameter frame specifies which frame need to be serialized. |
101 // The parameter client specifies the pointer of interface | 109 // The parameter client specifies the pointer of interface |
102 // WebPageSerializerClient providing a sink interface to receive the | 110 // WebPageSerializerClient providing a sink interface to receive the |
103 // individual chunks of data to be saved. | 111 // individual chunks of data to be saved. |
104 // The parameter urlsToLocalPaths contains a mapping between original URLs | 112 // The parameter urlsToLocalPaths contains a mapping between original URLs |
105 // of saved resources and corresponding local file paths. | 113 // of saved resources and corresponding local file paths. |
106 BLINK_EXPORT static bool serialize( | 114 BLINK_EXPORT static bool serialize( |
107 WebLocalFrame*, | 115 WebLocalFrame*, |
108 WebPageSerializerClient*, | 116 WebPageSerializerClient*, |
109 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths); | 117 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths); |
110 | 118 |
111 // FIXME: The following are here for unit testing purposes. Consider | 119 // FIXME: The following are here for unit testing purposes. Consider |
112 // changing the unit tests instead. | 120 // changing the unit tests instead. |
113 | 121 |
114 // Generate the META for charset declaration. | 122 // Generate the META for charset declaration. |
115 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); | 123 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); |
116 // Generate the MOTW declaration. | 124 // Generate the MOTW declaration. |
117 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; | 125 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; |
118 // Generate the default base tag declaration. | 126 // Generate the default base tag declaration. |
119 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); | 127 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); |
120 }; | 128 }; |
121 | 129 |
122 } // namespace blink | 130 } // namespace blink |
123 | 131 |
124 #endif | 132 #endif |
OLD | NEW |