Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: third_party/WebKit/public/web/WebPageSerializer.h

Issue 1541463002: Rename [Web]PageSerializer[Test|Client|Impl] to ...FrameSerializer... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-deduplication-of-resources
Patch Set: Rebasing... Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #ifndef WebPageSerializer_h
32 #define WebPageSerializer_h
33
34 #include "../platform/WebCString.h"
35 #include "../platform/WebCommon.h"
36 #include "../platform/WebData.h"
37 #include "../platform/WebString.h"
38 #include "../platform/WebURL.h"
39 #include "../platform/WebVector.h"
40
41 #include <utility>
42
43 namespace blink {
44
45 class WebPageSerializerClient;
46 class WebFrame;
47 class WebLocalFrame;
48 template <typename T> class WebVector;
49
50 // Serialization of frame contents into html or mhtml.
51 // TODO(lukasza): Rename this class to WebFrameSerializer?
52 class WebPageSerializer {
53 public:
54 // Generates and returns an MHTML header.
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*);
65
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
81 // savable resources underneath.
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 rfc1341, section 7.2.1, "boundary" description).
86 BLINK_EXPORT static WebData generateMHTMLParts(
87 const WebString& boundary, WebLocalFrame*, bool useBinaryEncoding,
88 MHTMLPartsGenerationDelegate*);
89
90 // Generates and returns an MHTML footer.
91 //
92 // Same |boundary| needs to used for all generateMHTMLHeader and
93 // generateMHTMLParts and generateMHTMLFooter calls that belong to the same
94 // MHTML document (see also rfc1341, section 7.2.1, "boundary" description).
95 BLINK_EXPORT static WebData generateMHTMLFooter(const WebString& boundary);
96
97 // IMPORTANT:
98 // The API below is an older implementation of a pageserialization that
99 // will be removed soon.
100
101 // This function will serialize the specified frame to HTML data.
102 // We have a data buffer to temporary saving generated html data. We will
103 // sequentially call WebPageSerializerClient once the data buffer is full.
104 //
105 // Return false means if no data has been serialized (i.e. because
106 // the target frame didn't have a valid url).
107 //
108 // The parameter frame specifies which frame need to be serialized.
109 // The parameter client specifies the pointer of interface
110 // WebPageSerializerClient providing a sink interface to receive the
111 // individual chunks of data to be saved.
112 // The parameter urlsToLocalPaths contains a mapping between original URLs
113 // of saved resources and corresponding local file paths.
114 BLINK_EXPORT static bool serialize(
115 WebLocalFrame*,
116 WebPageSerializerClient*,
117 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths);
118
119 // FIXME: The following are here for unit testing purposes. Consider
120 // changing the unit tests instead.
121
122 // Generate the META for charset declaration.
123 BLINK_EXPORT static WebString generateMetaCharsetDeclaration(const WebString & charset);
124 // Generate the MOTW declaration.
125 BLINK_EXPORT static WebString generateMarkOfTheWebDeclaration(const WebURL&) ;
126 // Generate the default base tag declaration.
127 BLINK_EXPORT static WebString generateBaseTagDeclaration(const WebString& ba seTarget);
128 };
129
130 } // namespace blink
131
132 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/public/web/WebFrameSerializerClient.h ('k') | third_party/WebKit/public/web/WebPageSerializerClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698