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

Unified Diff: third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp

Issue 1839473002: Centralize the setting of Accept headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp b/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp
index 1abd498d7d7b5c721779a22e58424781e228c51f..4f352d888641d9a4c754037b8857351bab4c3911 100644
--- a/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp
@@ -35,10 +35,22 @@
namespace blink {
+static void applyXSLRequestProperties(ResourceRequest& request)
+{
+ request.setRequestContext(WebURLRequest::RequestContextXSLT);
+ // TODO(japhet): Accept: headers can be set manually on XHRs from script,
+ // in the browser process, and... here. The browser process can't tell the
+ // difference between an XSL stylesheet and a CSS stylesheet, so it assumes
+ // stylesheets are all CSS unless they already have an Accept: header set.
+ // Should we teach the browser process the difference?
+ DEFINE_STATIC_LOCAL(const AtomicString, acceptXSLT, ("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml"));
+ request.setHTTPAccept(acceptXSLT);
+}
+
XSLStyleSheetResource* XSLStyleSheetResource::fetchSynchronously(FetchRequest& request, ResourceFetcher* fetcher)
{
+ applyXSLRequestProperties(request.mutableResourceRequest());
request.mutableResourceRequest().setTimeoutInterval(10);
- request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestContextXSLT);
ResourceLoaderOptions options(request.options());
options.synchronousPolicy = RequestSynchronously;
request.setOptions(options);
@@ -51,19 +63,13 @@ XSLStyleSheetResource* XSLStyleSheetResource::fetchSynchronously(FetchRequest& r
XSLStyleSheetResource* XSLStyleSheetResource::fetch(FetchRequest& request, ResourceFetcher* fetcher)
{
ASSERT(RuntimeEnabledFeatures::xsltEnabled());
- request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestContextXSLT);
+ applyXSLRequestProperties(request.mutableResourceRequest());
return toXSLStyleSheetResource(fetcher->requestResource(request, XSLStyleSheetResourceFactory()));
}
XSLStyleSheetResource::XSLStyleSheetResource(const ResourceRequest& resourceRequest, const ResourceLoaderOptions& options, const String& charset)
: StyleSheetResource(resourceRequest, XSLStyleSheet, options, "text/xsl", charset)
{
- ASSERT(RuntimeEnabledFeatures::xsltEnabled());
- DEFINE_STATIC_LOCAL(const AtomicString, acceptXSLT, ("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml"));
-
- // It's XML we want.
- // FIXME: This should accept more general xml formats */*+xml, image/svg+xml for example.
- setAccept(acceptXSLT);
}
void XSLStyleSheetResource::didAddClient(ResourceClient* c)
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ScriptResource.cpp ('k') | third_party/WebKit/Source/core/loader/LinkLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698