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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // plays nicely with srcset. | 81 // plays nicely with srcset. |
82 return attribute.localName() == HTMLNames::srcsetAttr; | 82 return attribute.localName() == HTMLNames::srcsetAttr; |
83 } | 83 } |
84 | 84 |
85 } // namespace | 85 } // namespace |
86 | 86 |
87 static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::E
ncodingPolicy encodingPolicy) | 87 static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::E
ncodingPolicy encodingPolicy) |
88 { | 88 { |
89 Vector<SerializedResource> resources; | 89 Vector<SerializedResource> resources; |
90 PageSerializer serializer(&resources, adoptPtr(new MHTMLPageSerializerDelega
te)); | 90 PageSerializer serializer(&resources, adoptPtr(new MHTMLPageSerializerDelega
te)); |
91 serializer.serialize(page); | 91 |
| 92 RefPtr<SharedBuffer> output = SharedBuffer::create(); |
| 93 String boundary = MHTMLArchive::generateMHTMLBoundary(); |
| 94 |
92 Document* document = page->deprecatedLocalMainFrame()->document(); | 95 Document* document = page->deprecatedLocalMainFrame()->document(); |
93 return MHTMLArchive::generateMHTMLData(resources, encodingPolicy, document->
title(), document->suggestedMIMEType()); | 96 MHTMLArchive::generateMHTMLHeader( |
| 97 boundary, document->title(), document->suggestedMIMEType(), *output); |
| 98 |
| 99 for (Frame* frame = page->deprecatedLocalMainFrame(); frame; frame = frame->
tree().traverseNext()) { |
| 100 // TODO(lukasza): This causes incomplete MHTML for OOPIFs. |
| 101 // (crbug.com/538766) |
| 102 if (!frame->isLocalFrame()) |
| 103 continue; |
| 104 |
| 105 resources.clear(); |
| 106 serializer.serializeFrame(*toLocalFrame(frame)); |
| 107 |
| 108 for (const auto& resource : resources) { |
| 109 MHTMLArchive::generateMHTMLPart( |
| 110 boundary, encodingPolicy, resource, *output); |
| 111 } |
| 112 } |
| 113 |
| 114 MHTMLArchive::generateMHTMLFooter(boundary, *output); |
| 115 return output.release(); |
94 } | 116 } |
95 | 117 |
96 WebCString WebPageSerializer::serializeToMHTML(WebView* view) | 118 WebCString WebPageSerializer::serializeToMHTML(WebView* view) |
97 { | 119 { |
98 RefPtr<SharedBuffer> mhtml = serializePageToMHTML(toWebViewImpl(view)->page(
), MHTMLArchive::UseDefaultEncoding); | 120 RefPtr<SharedBuffer> mhtml = serializePageToMHTML(toWebViewImpl(view)->page(
), MHTMLArchive::UseDefaultEncoding); |
99 // FIXME: we are copying all the data here. Idealy we would have a WebShared
Data(). | 121 // FIXME: we are copying all the data here. Idealy we would have a WebShared
Data(). |
100 return WebCString(mhtml->data(), mhtml->size()); | 122 return WebCString(mhtml->data(), mhtml->size()); |
101 } | 123 } |
102 | 124 |
103 WebCString WebPageSerializer::serializeToMHTMLUsingBinaryEncoding(WebView* view) | 125 WebCString WebPageSerializer::serializeToMHTMLUsingBinaryEncoding(WebView* view) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) | 159 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) |
138 { | 160 { |
139 // TODO(yosin) We should call |PageSerializer::baseTagDeclarationOf()|. | 161 // TODO(yosin) We should call |PageSerializer::baseTagDeclarationOf()|. |
140 if (baseTarget.isEmpty()) | 162 if (baseTarget.isEmpty()) |
141 return String("<base href=\".\">"); | 163 return String("<base href=\".\">"); |
142 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; | 164 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; |
143 return baseString; | 165 return baseString; |
144 } | 166 } |
145 | 167 |
146 } // namespace blink | 168 } // namespace blink |
OLD | NEW |