Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebFrameSerializer.cpp |
| diff --git a/third_party/WebKit/Source/web/WebFrameSerializer.cpp b/third_party/WebKit/Source/web/WebFrameSerializer.cpp |
| index 09fab010910923bea9bed94a704d40d0052a75d2..5349d4f5b1e1dd6e13837621961f6cdd748b3a67 100644 |
| --- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp |
| +++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp |
| @@ -47,10 +47,13 @@ |
| #include "platform/SharedBuffer.h" |
| #include "platform/mhtml/MHTMLArchive.h" |
| #include "platform/mhtml/MHTMLParser.h" |
| +#include "platform/network/ResourceResponse.h" |
| #include "platform/weborigin/KURL.h" |
| #include "public/platform/WebString.h" |
| #include "public/platform/WebURL.h" |
| +#include "public/platform/WebURLResponse.h" |
| #include "public/platform/WebVector.h" |
| +#include "public/web/WebDataSource.h" |
| #include "public/web/WebDocument.h" |
| #include "public/web/WebFrame.h" |
| #include "public/web/WebFrameSerializerClient.h" |
| @@ -136,18 +139,37 @@ bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url) |
| return m_webDelegate.shouldSkipResource(url); |
| } |
| +bool resourceResponseContainsNoStore(const ResourceResponse& response) |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, cacheControlHeader, ("cache-control")); |
| + DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma")); |
| + |
| + return parseCacheControlDirectives( |
| + response.httpHeaderField(cacheControlHeader), |
| + response.httpHeaderField(pragmaHeader)).containsNoStore; |
|
Łukasz Anforowicz
2016/05/12 18:56:49
Could this be written as:
return response.cacheCon
dewittj
2016/05/12 22:58:01
No, that method is not const, since it caches the
Łukasz Anforowicz
2016/05/12 23:56:27
Oh, indeed - thanks for the explanation. And I se
dcheng
2016/05/13 17:48:33
+toyoshim, +hiroshige: any ideas on how to improve
hiroshige
2016/05/13 18:01:52
How about making ResourceResponse::cacheControlCon
|
| +} |
| + |
| } // namespace |
| -WebData WebFrameSerializer::generateMHTMLHeader( |
| - const WebString& boundary, WebLocalFrame* frame) |
| +bool WebFrameSerializer::generateMHTMLHeader( |
| + const WebString& boundary, CacheControlPolicy cacheControlPolicy, |
| + WebLocalFrame* frame, WebData* data) |
| { |
| - Document* document = toWebLocalFrameImpl(frame)->frame()->document(); |
| + WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame); |
| + DCHECK(webLocalFrameImpl); |
| + |
| + const ResourceResponse& response = webLocalFrameImpl->dataSource()->response().toResourceResponse(); |
| + if (cacheControlPolicy == CacheControlPolicyFailForNoStoreMainFrame && resourceResponseContainsNoStore(response)) |
| + return false; |
| + |
| + Document* document = webLocalFrameImpl->frame()->document(); |
| RefPtr<SharedBuffer> buffer = SharedBuffer::create(); |
| MHTMLArchive::generateMHTMLHeader( |
| boundary, document->title(), document->suggestedMIMEType(), |
| *buffer); |
| - return buffer.release(); |
| + *data = buffer.release(); |
| + return true; |
| } |
| WebData WebFrameSerializer::generateMHTMLParts( |