Chromium Code Reviews| 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 29 matching lines...) Expand all Loading... | |
| 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" |
| 56 #include "public/web/WebFrameSerializerClient.h" | 59 #include "public/web/WebFrameSerializerClient.h" |
| 57 #include "web/WebFrameSerializerImpl.h" | 60 #include "web/WebFrameSerializerImpl.h" |
| 58 #include "web/WebLocalFrameImpl.h" | 61 #include "web/WebLocalFrameImpl.h" |
| 59 #include "web/WebRemoteFrameImpl.h" | 62 #include "web/WebRemoteFrameImpl.h" |
| 60 #include "wtf/Assertions.h" | 63 #include "wtf/Assertions.h" |
| 61 #include "wtf/HashMap.h" | 64 #include "wtf/HashMap.h" |
| 62 #include "wtf/HashSet.h" | 65 #include "wtf/HashSet.h" |
| 63 #include "wtf/Noncopyable.h" | 66 #include "wtf/Noncopyable.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 132 } |
| 130 | 133 |
| 131 return false; | 134 return false; |
| 132 } | 135 } |
| 133 | 136 |
| 134 bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url) | 137 bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url) |
| 135 { | 138 { |
| 136 return m_webDelegate.shouldSkipResource(url); | 139 return m_webDelegate.shouldSkipResource(url); |
| 137 } | 140 } |
| 138 | 141 |
| 142 bool resourceResponseContainsNoStore(const ResourceResponse& response) | |
| 143 { | |
| 144 DEFINE_STATIC_LOCAL(const AtomicString, cacheControlHeader, ("cache-control" )); | |
| 145 DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma")); | |
| 146 | |
| 147 return parseCacheControlDirectives( | |
| 148 response.httpHeaderField(cacheControlHeader), | |
| 149 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
| |
| 150 } | |
| 151 | |
| 139 } // namespace | 152 } // namespace |
| 140 | 153 |
| 141 WebData WebFrameSerializer::generateMHTMLHeader( | 154 bool WebFrameSerializer::generateMHTMLHeader( |
| 142 const WebString& boundary, WebLocalFrame* frame) | 155 const WebString& boundary, CacheControlPolicy cacheControlPolicy, |
| 156 WebLocalFrame* frame, WebData* data) | |
| 143 { | 157 { |
| 144 Document* document = toWebLocalFrameImpl(frame)->frame()->document(); | 158 WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame); |
| 159 DCHECK(webLocalFrameImpl); | |
| 160 | |
| 161 const ResourceResponse& response = webLocalFrameImpl->dataSource()->response ().toResourceResponse(); | |
| 162 if (cacheControlPolicy == CacheControlPolicyFailForNoStoreMainFrame && resou rceResponseContainsNoStore(response)) | |
| 163 return false; | |
| 164 | |
| 165 Document* document = webLocalFrameImpl->frame()->document(); | |
| 145 | 166 |
| 146 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); | 167 RefPtr<SharedBuffer> buffer = SharedBuffer::create(); |
| 147 MHTMLArchive::generateMHTMLHeader( | 168 MHTMLArchive::generateMHTMLHeader( |
| 148 boundary, document->title(), document->suggestedMIMEType(), | 169 boundary, document->title(), document->suggestedMIMEType(), |
| 149 *buffer); | 170 *buffer); |
| 150 return buffer.release(); | 171 *data = buffer.release(); |
| 172 return true; | |
| 151 } | 173 } |
| 152 | 174 |
| 153 WebData WebFrameSerializer::generateMHTMLParts( | 175 WebData WebFrameSerializer::generateMHTMLParts( |
| 154 const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding, | 176 const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding, |
| 155 MHTMLPartsGenerationDelegate* webDelegate) | 177 MHTMLPartsGenerationDelegate* webDelegate) |
| 156 { | 178 { |
| 157 DCHECK(webFrame); | 179 DCHECK(webFrame); |
| 158 DCHECK(webDelegate); | 180 DCHECK(webDelegate); |
| 159 | 181 |
| 160 // Translate arguments from public to internal blink APIs. | 182 // Translate arguments from public to internal blink APIs. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget) | 245 WebString WebFrameSerializer::generateBaseTagDeclaration(const WebString& baseTa rget) |
| 224 { | 246 { |
| 225 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 247 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 226 if (baseTarget.isEmpty()) | 248 if (baseTarget.isEmpty()) |
| 227 return String("<base href=\".\">"); | 249 return String("<base href=\".\">"); |
| 228 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">"; | 250 String baseString = "<base href=\".\" target=\"" + static_cast<const String& >(baseTarget) + "\">"; |
| 229 return baseString; | 251 return baseString; |
| 230 } | 252 } |
| 231 | 253 |
| 232 } // namespace blink | 254 } // namespace blink |
| OLD | NEW |