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

Side by Side Diff: Source/core/xml/XSLTProcessorLibxslt.cpp

Issue 23702040: Send synchronous loads through the cache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/xml/XMLHttpRequest.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the XSL implementation. 2 * This file is part of the XSL implementation.
3 * 3 *
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved.
5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org> 5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/xml/XSLTProcessor.h" 24 #include "core/xml/XSLTProcessor.h"
25 25
26 #include "FetchInitiatorTypeNames.h"
26 #include "core/dom/Document.h" 27 #include "core/dom/Document.h"
27 #include "core/dom/TransformSource.h" 28 #include "core/dom/TransformSource.h"
28 #include "core/editing/markup.h" 29 #include "core/editing/markup.h"
30 #include "core/fetch/Resource.h"
29 #include "core/fetch/ResourceFetcher.h" 31 #include "core/fetch/ResourceFetcher.h"
30 #include "core/page/Frame.h" 32 #include "core/page/Frame.h"
31 #include "core/page/Page.h" 33 #include "core/page/Page.h"
32 #include "core/page/PageConsole.h" 34 #include "core/page/PageConsole.h"
35 #include "core/platform/SharedBuffer.h"
33 #include "core/platform/network/ResourceError.h" 36 #include "core/platform/network/ResourceError.h"
34 #include "core/platform/network/ResourceRequest.h" 37 #include "core/platform/network/ResourceRequest.h"
35 #include "core/platform/network/ResourceResponse.h" 38 #include "core/platform/network/ResourceResponse.h"
36 #include "core/xml/XSLStyleSheet.h" 39 #include "core/xml/XSLStyleSheet.h"
37 #include "core/xml/XSLTExtensions.h" 40 #include "core/xml/XSLTExtensions.h"
38 #include "core/xml/XSLTUnicodeSort.h" 41 #include "core/xml/XSLTUnicodeSort.h"
39 #include "core/xml/parser/XMLDocumentParser.h" 42 #include "core/xml/parser/XMLDocumentParser.h"
40 #include "weborigin/SecurityOrigin.h" 43 #include "weborigin/SecurityOrigin.h"
41 #include "wtf/Assertions.h" 44 #include "wtf/Assertions.h"
42 #include "wtf/Vector.h" 45 #include "wtf/Vector.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 { 93 {
91 if (!globalProcessor) 94 if (!globalProcessor)
92 return 0; 95 return 0;
93 96
94 switch (type) { 97 switch (type) {
95 case XSLT_LOAD_DOCUMENT: { 98 case XSLT_LOAD_DOCUMENT: {
96 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; 99 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt;
97 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); 100 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node);
98 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei nterpret_cast<const char*>(uri)); 101 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei nterpret_cast<const char*>(uri));
99 xmlFree(base); 102 xmlFree(base);
100 ResourceError error;
101 ResourceResponse response;
102 103
103 Vector<char> data; 104 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptio ns());
104 105 fetchOptions.requestOriginPolicy = RestrictToSameOrigin;
105 bool requestAllowed = globalResourceFetcher->frame() && globalResourceFe tcher->document()->securityOrigin()->canRequest(url); 106 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, fetchOptions);
106 if (requestAllowed) { 107 ResourcePtr<Resource> resource = globalResourceFetcher->fetchSynchronous ly(request);
107 globalResourceFetcher->fetchSynchronously(url, AllowStoredCredential s, error, response, data); 108 if (!resource || !globalProcessor)
108 requestAllowed = globalResourceFetcher->document()->securityOrigin() ->canRequest(response.url()); 109 return 0;
109 }
110 if (!requestAllowed) {
111 data.clear();
112 globalResourceFetcher->printAccessDeniedMessage(url);
113 }
114 110
115 PageConsole* console = 0; 111 PageConsole* console = 0;
116 Frame* frame = globalProcessor->xslStylesheet()->ownerDocument()->frame( ); 112 Frame* frame = globalProcessor->xslStylesheet()->ownerDocument()->frame( );
117 if (frame && frame->page()) 113 if (frame && frame->page())
118 console = &frame->page()->console(); 114 console = &frame->page()->console();
119 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc); 115 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc);
120 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc); 116 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc);
121 117
122 // We don't specify an encoding here. Neither Gecko nor WinIE respects 118 // We don't specify an encoding here. Neither Gecko nor WinIE respects
123 // the encoding specified in the HTTP headers. 119 // the encoding specified in the HTTP headers.
124 xmlDocPtr doc = xmlReadMemory(data.data(), data.size(), (const char*)uri , 0, options); 120 SharedBuffer* data = resource->resourceBuffer();
121 xmlDocPtr doc = data ? xmlReadMemory(data->data(), data->size(), (const char*)uri, 0, options) : 0;
125 122
126 xmlSetStructuredErrorFunc(0, 0); 123 xmlSetStructuredErrorFunc(0, 0);
127 xmlSetGenericErrorFunc(0, 0); 124 xmlSetGenericErrorFunc(0, 0);
128 125
129 return doc; 126 return doc;
130 } 127 }
131 case XSLT_LOAD_STYLESHEET: 128 case XSLT_LOAD_STYLESHEET:
132 return globalProcessor->xslStylesheet()->locateStylesheetSubResource(((x sltStylesheetPtr)ctxt)->doc, uri); 129 return globalProcessor->xslStylesheet()->locateStylesheetSubResource(((x sltStylesheetPtr)ctxt)->doc, uri);
133 default: 130 default:
134 break; 131 break;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 338
342 sheet->method = origMethod; 339 sheet->method = origMethod;
343 setXSLTLoadCallBack(0, 0, 0); 340 setXSLTLoadCallBack(0, 0, 0);
344 xsltFreeStylesheet(sheet); 341 xsltFreeStylesheet(sheet);
345 m_stylesheet = 0; 342 m_stylesheet = 0;
346 343
347 return success; 344 return success;
348 } 345 }
349 346
350 } // namespace WebCore 347 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/xml/XMLHttpRequest.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698