| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 String& rewrittenLink) | 100 String& rewrittenLink) |
| 101 { | 101 { |
| 102 if (!element.isFrameOwnerElement()) | 102 if (!element.isFrameOwnerElement()) |
| 103 return false; | 103 return false; |
| 104 | 104 |
| 105 auto* frameOwnerElement = toHTMLFrameOwnerElement(&element); | 105 auto* frameOwnerElement = toHTMLFrameOwnerElement(&element); |
| 106 Frame* frame = frameOwnerElement->contentFrame(); | 106 Frame* frame = frameOwnerElement->contentFrame(); |
| 107 if (!frame) | 107 if (!frame) |
| 108 return false; | 108 return false; |
| 109 | 109 |
| 110 WebString contentID = m_webDelegate.getContentID(*WebFrame::fromFrame(frame)
); | 110 WebString contentID = m_webDelegate.getContentID(WebFrame::fromFrame(frame))
; |
| 111 if (contentID.isNull()) | 111 if (contentID.isNull()) |
| 112 return false; | 112 return false; |
| 113 | 113 |
| 114 KURL cidURI = MHTMLParser::convertContentIDToURI(contentID); | 114 KURL cidURI = MHTMLParser::convertContentIDToURI(contentID); |
| 115 ASSERT(cidURI.isValid()); | 115 ASSERT(cidURI.isValid()); |
| 116 | 116 |
| 117 if (isHTMLFrameElementBase(&element)) { | 117 if (isHTMLFrameElementBase(&element)) { |
| 118 rewrittenLink = cidURI.string(); | 118 rewrittenLink = cidURI.string(); |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding | 164 ? MHTMLArchive::EncodingPolicy::UseBinaryEncoding |
| 165 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding; | 165 : MHTMLArchive::EncodingPolicy::UseDefaultEncoding; |
| 166 | 166 |
| 167 // Serialize. | 167 // Serialize. |
| 168 Vector<SerializedResource> resources; | 168 Vector<SerializedResource> resources; |
| 169 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); | 169 MHTMLFrameSerializerDelegate coreDelegate(*webDelegate); |
| 170 FrameSerializer serializer(resources, coreDelegate); | 170 FrameSerializer serializer(resources, coreDelegate); |
| 171 serializer.serializeFrame(*frame); | 171 serializer.serializeFrame(*frame); |
| 172 | 172 |
| 173 // Get Content-ID for the frame being serialized. | 173 // Get Content-ID for the frame being serialized. |
| 174 String frameContentID = webDelegate->getContentID(*webFrame); | 174 String frameContentID = webDelegate->getContentID(webFrame); |
| 175 | 175 |
| 176 // Encode serializer's output as MHTML. | 176 // Encode serializer's output as MHTML. |
| 177 RefPtr<SharedBuffer> output = SharedBuffer::create(); | 177 RefPtr<SharedBuffer> output = SharedBuffer::create(); |
| 178 bool isFirstResource = true; | 178 bool isFirstResource = true; |
| 179 for (const SerializedResource& resource : resources) { | 179 for (const SerializedResource& resource : resources) { |
| 180 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc | 180 // Frame is the 1st resource (see FrameSerializer::serializeFrame doc |
| 181 // comment). Frames get a Content-ID header. | 181 // comment). Frames get a Content-ID header. |
| 182 String contentID = isFirstResource ? frameContentID : String(); | 182 String contentID = isFirstResource ? frameContentID : String(); |
| 183 | 183 |
| 184 MHTMLArchive::generateMHTMLPart( | 184 MHTMLArchive::generateMHTMLPart( |
| 185 boundary, contentID, encodingPolicy, resource, *output); | 185 boundary, contentID, encodingPolicy, resource, *output); |
| 186 | 186 |
| 187 isFirstResource = false; | 187 isFirstResource = false; |
| 188 } | 188 } |
| 189 return output.release(); | 189 return output.release(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary) | 192 WebData WebFrameSerializer::generateMHTMLFooter(const WebString& boundary) |
| 193 { | 193 { |
| 194 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); | 194 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); |
| 195 MHTMLArchive::generateMHTMLFooter(boundary, *buffer); | 195 MHTMLArchive::generateMHTMLFooter(boundary, *buffer); |
| 196 return buffer.release(); | 196 return buffer.release(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool WebFrameSerializer::serialize( | 199 bool WebFrameSerializer::serialize( |
| 200 WebLocalFrame* frame, | 200 WebLocalFrame* frame, |
| 201 WebFrameSerializerClient* client, | 201 WebFrameSerializerClient* client, |
| 202 const WebVector<std::pair<WebURL, WebString>>& urlsToLocalPaths) | 202 WebFrameSerializer::LinkRewritingDelegate* delegate) |
| 203 { | 203 { |
| 204 WebFrameSerializerImpl serializerImpl(frame, client, urlsToLocalPaths); | 204 WebFrameSerializerImpl serializerImpl(frame, client, delegate); |
| 205 return serializerImpl.serialize(); | 205 return serializerImpl.serialize(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 WebString WebFrameSerializer::generateMetaCharsetDeclaration(const WebString& ch
arset) | 208 WebString WebFrameSerializer::generateMetaCharsetDeclaration(const WebString& ch
arset) |
| 209 { | 209 { |
| 210 // TODO(yosin) We should call |FrameSerializer::metaCharsetDeclarationOf()|. | 210 // TODO(yosin) We should call |FrameSerializer::metaCharsetDeclarationOf()|. |
| 211 String charsetString = "<meta http-equiv=\"Content-Type\" content=\"text/htm
l; charset=" + static_cast<const String&>(charset) + "\">"; | 211 String charsetString = "<meta http-equiv=\"Content-Type\" content=\"text/htm
l; charset=" + static_cast<const String&>(charset) + "\">"; |
| 212 return charsetString; | 212 return charsetString; |
| 213 } | 213 } |
| 214 | 214 |
| 215 WebString WebFrameSerializer::generateMarkOfTheWebDeclaration(const WebURL& url) | 215 WebString WebFrameSerializer::generateMarkOfTheWebDeclaration(const WebURL& url) |
| 216 { | 216 { |
| 217 StringBuilder builder; | 217 StringBuilder builder; |
| 218 builder.append("\n<!-- "); | 218 builder.append("\n<!-- "); |
| 219 builder.append(FrameSerializer::markOfTheWebDeclaration(url)); | 219 builder.append(FrameSerializer::markOfTheWebDeclaration(url)); |
| 220 builder.append(" -->\n"); | 220 builder.append(" -->\n"); |
| 221 return builder.toString(); | 221 return builder.toString(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa
rget) | 224 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa
rget) |
| 225 { | 225 { |
| 226 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 226 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 227 if (baseTarget.isEmpty()) | 227 if (baseTarget.isEmpty()) |
| 228 return String("<base href=\".\">"); | 228 return String("<base href=\".\">"); |
| 229 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; | 229 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; |
| 230 return baseString; | 230 return baseString; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |