| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 WebFrameSerializer_h |
| 32 #define WebPageSerializer_h | 32 #define WebFrameSerializer_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" | 36 #include "../platform/WebData.h" |
| 37 #include "../platform/WebString.h" | 37 #include "../platform/WebString.h" |
| 38 #include "../platform/WebURL.h" | 38 #include "../platform/WebURL.h" |
| 39 #include "../platform/WebVector.h" | 39 #include "../platform/WebVector.h" |
| 40 | 40 |
| 41 #include <utility> | 41 #include <utility> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class WebPageSerializerClient; | 45 class WebFrameSerializerClient; |
| 46 class WebFrame; | 46 class WebFrame; |
| 47 class WebLocalFrame; | 47 class WebLocalFrame; |
| 48 template <typename T> class WebVector; | 48 template <typename T> class WebVector; |
| 49 | 49 |
| 50 // Serialization of frame contents into html or mhtml. | 50 // Serialization of frame contents into html or mhtml. |
| 51 // TODO(lukasza): Rename this class to WebFrameSerializer? | 51 class WebFrameSerializer { |
| 52 class WebPageSerializer { | |
| 53 public: | 52 public: |
| 54 // Generates and returns an MHTML header. | 53 // Generates and returns an MHTML header. |
| 55 // | 54 // |
| 56 // Contents of the header (i.e. title and mime type) will be based | 55 // 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 | 56 // on the frame passed as an argument (which typically should be |
| 58 // the main, top-level frame). | 57 // the main, top-level frame). |
| 59 // | 58 // |
| 60 // Same |boundary| needs to used for all generateMHTMLHeader and | 59 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 61 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 60 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 62 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 61 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| (...skipping 25 matching lines...) Expand all Loading... |
| 88 MHTMLPartsGenerationDelegate*); | 87 MHTMLPartsGenerationDelegate*); |
| 89 | 88 |
| 90 // Generates and returns an MHTML footer. | 89 // Generates and returns an MHTML footer. |
| 91 // | 90 // |
| 92 // Same |boundary| needs to used for all generateMHTMLHeader and | 91 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 93 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 92 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 94 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 93 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| 95 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); | 94 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); |
| 96 | 95 |
| 97 // IMPORTANT: | 96 // IMPORTANT: |
| 98 // The API below is an older implementation of a pageserialization that | 97 // The API below is an older implementation of frame serialization that |
| 99 // will be removed soon. | 98 // will be removed soon. |
| 100 | 99 |
| 101 // This function will serialize the specified frame to HTML data. | 100 // This function will serialize the specified frame to HTML data. |
| 102 // We have a data buffer to temporary saving generated html data. We will | 101 // We have a data buffer to temporary saving generated html data. We will |
| 103 // sequentially call WebPageSerializerClient once the data buffer is full. | 102 // sequentially call WebFrameSerializerClient once the data buffer is full. |
| 104 // | 103 // |
| 105 // Return false means if no data has been serialized (i.e. because | 104 // Return false means if no data has been serialized (i.e. because |
| 106 // the target frame didn't have a valid url). | 105 // the target frame didn't have a valid url). |
| 107 // | 106 // |
| 108 // The parameter frame specifies which frame need to be serialized. | 107 // The parameter frame specifies which frame need to be serialized. |
| 109 // The parameter client specifies the pointer of interface | 108 // The parameter client specifies the pointer of interface |
| 110 // WebPageSerializerClient providing a sink interface to receive the | 109 // WebFrameSerializerClient providing a sink interface to receive the |
| 111 // individual chunks of data to be saved. | 110 // individual chunks of data to be saved. |
| 112 // The parameter urlsToLocalPaths contains a mapping between original URLs | 111 // The parameter urlsToLocalPaths contains a mapping between original URLs |
| 113 // of saved resources and corresponding local file paths. | 112 // of saved resources and corresponding local file paths. |
| 114 BLINK_EXPORT static bool serialize( | 113 BLINK_EXPORT static bool serialize( |
| 115 WebLocalFrame*, | 114 WebLocalFrame*, |
| 116 WebPageSerializerClient*, | 115 WebFrameSerializerClient*, |
| 117 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths); | 116 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths); |
| 118 | 117 |
| 119 // FIXME: The following are here for unit testing purposes. Consider | 118 // FIXME: The following are here for unit testing purposes. Consider |
| 120 // changing the unit tests instead. | 119 // changing the unit tests instead. |
| 121 | 120 |
| 122 // Generate the META for charset declaration. | 121 // Generate the META for charset declaration. |
| 123 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); | 122 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString
& charset); |
| 124 // Generate the MOTW declaration. | 123 // Generate the MOTW declaration. |
| 125 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; | 124 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&)
; |
| 126 // Generate the default base tag declaration. | 125 // Generate the default base tag declaration. |
| 127 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); | 126 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba
seTarget); |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 } // namespace blink | 129 } // namespace blink |
| 131 | 130 |
| 132 #endif | 131 #endif |
| OLD | NEW |