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

Side by Side Diff: third_party/WebKit/Source/web/WebPageSerializer.cpp

Issue 1436683002: Making PageSerializer operate on single frames only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-removing-unused-code
Patch Set: Rebasing... Created 5 years, 1 month 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
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp ('k') | third_party/WebKit/Source/web/tests/MHTMLTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698