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

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

Issue 1947263004: Introduces a new MHTML generation parameter specifying different behvaior for cache-control headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto origin/master. Created 4 years, 7 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
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 29 matching lines...) Expand all
40 #include "core/html/HTMLAllCollection.h" 40 #include "core/html/HTMLAllCollection.h"
41 #include "core/html/HTMLFrameElementBase.h" 41 #include "core/html/HTMLFrameElementBase.h"
42 #include "core/html/HTMLFrameOwnerElement.h" 42 #include "core/html/HTMLFrameOwnerElement.h"
43 #include "core/html/HTMLInputElement.h" 43 #include "core/html/HTMLInputElement.h"
44 #include "core/html/HTMLTableElement.h" 44 #include "core/html/HTMLTableElement.h"
45 #include "core/loader/DocumentLoader.h" 45 #include "core/loader/DocumentLoader.h"
46 #include "platform/SerializedResource.h" 46 #include "platform/SerializedResource.h"
47 #include "platform/SharedBuffer.h" 47 #include "platform/SharedBuffer.h"
48 #include "platform/mhtml/MHTMLArchive.h" 48 #include "platform/mhtml/MHTMLArchive.h"
49 #include "platform/mhtml/MHTMLParser.h" 49 #include "platform/mhtml/MHTMLParser.h"
50 #include "platform/network/ResourceResponse.h"
50 #include "platform/weborigin/KURL.h" 51 #include "platform/weborigin/KURL.h"
51 #include "public/platform/WebString.h" 52 #include "public/platform/WebString.h"
52 #include "public/platform/WebURL.h" 53 #include "public/platform/WebURL.h"
54 #include "public/platform/WebURLResponse.h"
53 #include "public/platform/WebVector.h" 55 #include "public/platform/WebVector.h"
56 #include "public/web/WebDataSource.h"
54 #include "public/web/WebDocument.h" 57 #include "public/web/WebDocument.h"
55 #include "public/web/WebFrame.h" 58 #include "public/web/WebFrame.h"
59 #include "public/web/WebFrameSerializerCacheControlPolicy.h"
56 #include "public/web/WebFrameSerializerClient.h" 60 #include "public/web/WebFrameSerializerClient.h"
57 #include "web/WebFrameSerializerImpl.h" 61 #include "web/WebFrameSerializerImpl.h"
58 #include "web/WebLocalFrameImpl.h" 62 #include "web/WebLocalFrameImpl.h"
59 #include "web/WebRemoteFrameImpl.h" 63 #include "web/WebRemoteFrameImpl.h"
60 #include "wtf/Assertions.h" 64 #include "wtf/Assertions.h"
61 #include "wtf/HashMap.h" 65 #include "wtf/HashMap.h"
62 #include "wtf/HashSet.h" 66 #include "wtf/HashSet.h"
63 #include "wtf/Noncopyable.h" 67 #include "wtf/Noncopyable.h"
64 #include "wtf/Vector.h" 68 #include "wtf/Vector.h"
65 #include "wtf/text/StringConcatenate.h" 69 #include "wtf/text/StringConcatenate.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return false; 135 return false;
132 } 136 }
133 137
134 bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url) 138 bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url)
135 { 139 {
136 return m_webDelegate.shouldSkipResource(url); 140 return m_webDelegate.shouldSkipResource(url);
137 } 141 }
138 142
139 } // namespace 143 } // namespace
140 144
141 WebData WebFrameSerializer::generateMHTMLHeader( 145 bool WebFrameSerializer::generateMHTMLHeader(
142 const WebString& boundary, WebLocalFrame* frame) 146 const WebString& boundary, WebFrameSerializerCacheControlPolicy cacheControl Policy,
147 WebLocalFrame* frame, WebData* data)
143 { 148 {
144 Document* document = toWebLocalFrameImpl(frame)->frame()->document(); 149 WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame);
150 DCHECK(webLocalFrameImpl);
151
152 if (cacheControlPolicy == WebFrameSerializerCacheControlPolicy::FailForNoSto reMainFrame) {
153 const ResourceResponse& response = webLocalFrameImpl->dataSource()->resp onse().toResourceResponse();
154 if (response.cacheControlContainsNoStore())
155 return false;
156 }
157
158 Document* document = webLocalFrameImpl->frame()->document();
145 159
146 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); 160 RefPtr<SharedBuffer> buffer = SharedBuffer::create();
147 MHTMLArchive::generateMHTMLHeader( 161 MHTMLArchive::generateMHTMLHeader(
148 boundary, document->title(), document->suggestedMIMEType(), 162 boundary, document->title(), document->suggestedMIMEType(),
149 *buffer); 163 *buffer);
150 return buffer.release(); 164 *data = buffer.release();
165 return true;
151 } 166 }
152 167
153 WebData WebFrameSerializer::generateMHTMLParts( 168 WebData WebFrameSerializer::generateMHTMLParts(
154 const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding, 169 const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding,
155 MHTMLPartsGenerationDelegate* webDelegate) 170 MHTMLPartsGenerationDelegate* webDelegate)
156 { 171 {
157 DCHECK(webFrame); 172 DCHECK(webFrame);
158 DCHECK(webDelegate); 173 DCHECK(webDelegate);
159 174
160 // Translate arguments from public to internal blink APIs. 175 // Translate arguments from public to internal blink APIs.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget) 238 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget)
224 { 239 {
225 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. 240 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|.
226 if (baseTarget.isEmpty()) 241 if (baseTarget.isEmpty())
227 return String("<base href=\".\">"); 242 return String("<base href=\".\">");
228 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">"; 243 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">";
229 return baseString; 244 return baseString;
230 } 245 }
231 246
232 } // namespace blink 247 } // namespace blink
OLDNEW
« no previous file with comments | « content/test/data/nostore.html.mock-http-headers ('k') | third_party/WebKit/public/web/WebFrameSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698