Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #ifndef WebFrameSerializer_h | 31 #ifndef WebFrameSerializer_h |
| 32 #define WebFrameSerializer_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> | |
| 42 | |
| 43 namespace blink { | 41 namespace blink { |
| 44 | 42 |
| 45 class WebFrameSerializerClient; | 43 class WebFrameSerializerClient; |
| 46 class WebFrame; | 44 class WebFrame; |
| 47 class WebLocalFrame; | 45 class WebLocalFrame; |
| 48 template <typename T> class WebVector; | 46 template <typename T> class WebVector; |
| 49 | 47 |
| 50 // Serialization of frame contents into html or mhtml. | 48 // Serialization of frame contents into html or mhtml. |
| 51 class WebFrameSerializer { | 49 class WebFrameSerializer { |
| 52 public: | 50 public: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // | 88 // |
| 91 // Same |boundary| needs to used for all generateMHTMLHeader and | 89 // Same |boundary| needs to used for all generateMHTMLHeader and |
| 92 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same | 90 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same |
| 93 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). | 91 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description). |
| 94 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); | 92 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary); |
| 95 | 93 |
| 96 // IMPORTANT: | 94 // IMPORTANT: |
| 97 // The API below is an older implementation of frame serialization that | 95 // The API below is an older implementation of frame serialization that |
| 98 // will be removed soon. | 96 // will be removed soon. |
| 99 | 97 |
| 98 class LinkRewritingDelegate { | |
| 99 public: | |
| 100 // Method allowing the delegate control which URLs are written into the | |
| 101 // generated html document. | |
| 102 // | |
| 103 // When URL of the given frame needs to be rewritten, this method should | |
| 104 // return true and populate |rewrittenLink| with a desired value of the | |
| 105 // html attribute value to be used in place of the original link (i.e. | |
| 106 // in place of the original iframe.src or object.data attribute value). | |
| 107 // | |
| 108 // If no link rewriting is desired, this method should return false. | |
| 109 virtual bool rewriteLink(const WebFrame&, WebString* rewrittenLink) = 0; | |
|
dcheng
2016/01/12 00:10:47
Let's distinguish the method names: how about rewr
Łukasz Anforowicz
2016/01/13 22:32:23
Done.
| |
| 110 | |
| 111 // Method allowing the delegate control which URLs are written into the | |
| 112 // generated html document. | |
| 113 // | |
| 114 // When the given URL needs to be rewritten, this method should | |
| 115 // return true and populate |rewrittenLink| with a desired value of the | |
| 116 // html attribute value to be used in place of the original link (i.e. | |
| 117 // in place of the original img.src or blockquote.cite attribute value). | |
| 118 // | |
| 119 // If no link rewriting is desired, this method should return false. | |
| 120 virtual bool rewriteLink(const WebURL&, WebString* rewrittenLink) = 0; | |
| 121 }; | |
| 122 | |
| 100 // This function will serialize the specified frame to HTML data. | 123 // This function will serialize the specified frame to HTML data. |
| 101 // We have a data buffer to temporary saving generated html data. We will | 124 // We have a data buffer to temporary saving generated html data. We will |
| 102 // sequentially call WebFrameSerializerClient once the data buffer is full. | 125 // sequentially call WebFrameSerializerClient once the data buffer is full. |
| 103 // | 126 // |
| 104 // Return false means if no data has been serialized (i.e. because | 127 // False is returned if no data has been serialized (i.e. because |
| 105 // the target frame didn't have a valid url). | 128 // the target frame didn't have a valid url). |
| 106 // | |
| 107 // The parameter frame specifies which frame need to be serialized. | |
| 108 // The parameter client specifies the pointer of interface | |
| 109 // WebFrameSerializerClient providing a sink interface to receive the | |
| 110 // individual chunks of data to be saved. | |
| 111 // The parameter urlsToLocalPaths contains a mapping between original URLs | |
| 112 // of saved resources and corresponding local file paths. | |
| 113 BLINK_EXPORT static bool serialize( | 129 BLINK_EXPORT static bool serialize( |
| 114 WebLocalFrame*, | 130 WebLocalFrame*, |
| 115 WebFrameSerializerClient*, | 131 WebFrameSerializerClient*, |
| 116 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths); | 132 LinkRewritingDelegate*); |
| 117 | 133 |
| 118 // FIXME: The following are here for unit testing purposes. Consider | 134 // FIXME: The following are here for unit testing purposes. Consider |
| 119 // changing the unit tests instead. | 135 // changing the unit tests instead. |
| 120 | 136 |
| 121 // Generate the META for charset declaration. | 137 // Generate the META for charset declaration. |
| 122 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset); | 138 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset); |
| 123 // Generate the MOTW declaration. | 139 // Generate the MOTW declaration. |
| 124 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; | 140 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ; |
| 125 // Generate the default base tag declaration. | 141 // Generate the default base tag declaration. |
| 126 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); | 142 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget); |
| 127 }; | 143 }; |
| 128 | 144 |
| 129 } // namespace blink | 145 } // namespace blink |
| 130 | 146 |
| 131 #endif | 147 #endif |
| OLD | NEW |