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

Side by Side Diff: Source/core/workers/WorkerScriptLoader.cpp

Issue 1190493002: move processContentSecurityPolicy to WorkerScriptLoader (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: (rebase) Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/workers/WorkerScriptLoader.h" 29 #include "core/workers/WorkerScriptLoader.h"
30 30
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "core/html/parser/TextResourceDecoder.h" 32 #include "core/html/parser/TextResourceDecoder.h"
33 #include "core/loader/WorkerThreadableLoader.h" 33 #include "core/loader/WorkerThreadableLoader.h"
34 #include "core/workers/WorkerGlobalScope.h" 34 #include "core/workers/WorkerGlobalScope.h"
35 #include "core/workers/WorkerScriptLoaderClient.h" 35 #include "core/workers/WorkerScriptLoaderClient.h"
36 #include "platform/network/ContentSecurityPolicyResponseHeaders.h"
36 #include "platform/network/ResourceResponse.h" 37 #include "platform/network/ResourceResponse.h"
37 #include "public/platform/WebURLRequest.h" 38 #include "public/platform/WebURLRequest.h"
38 39
39 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
40 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
41 42
42 namespace blink { 43 namespace blink {
43 44
44 WorkerScriptLoader::WorkerScriptLoader() 45 WorkerScriptLoader::WorkerScriptLoader()
45 : m_client(nullptr) 46 : m_client(nullptr)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 113
113 void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso urceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) 114 void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso urceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle)
114 { 115 {
115 ASSERT_UNUSED(handle, !handle); 116 ASSERT_UNUSED(handle, !handle);
116 if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) { 117 if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) {
117 m_failed = true; 118 m_failed = true;
118 return; 119 return;
119 } 120 }
120 m_responseURL = response.url(); 121 m_responseURL = response.url();
121 m_responseEncoding = response.textEncodingName(); 122 m_responseEncoding = response.textEncodingName();
123 processContentSecurityPolicy(response);
122 if (m_client) 124 if (m_client)
123 m_client->didReceiveResponse(identifier, response); 125 m_client->didReceiveResponse(identifier, response);
124 } 126 }
125 127
126 void WorkerScriptLoader::didReceiveData(const char* data, unsigned len) 128 void WorkerScriptLoader::didReceiveData(const char* data, unsigned len)
127 { 129 {
128 if (m_failed) 130 if (m_failed)
129 return; 131 return;
130 132
131 if (!m_decoder) { 133 if (!m_decoder) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 192
191 void WorkerScriptLoader::notifyFinished() 193 void WorkerScriptLoader::notifyFinished()
192 { 194 {
193 if (!m_client || m_finishing) 195 if (!m_client || m_finishing)
194 return; 196 return;
195 197
196 m_finishing = true; 198 m_finishing = true;
197 m_client->notifyFinished(); 199 m_client->notifyFinished();
198 } 200 }
199 201
202 void WorkerScriptLoader::processContentSecurityPolicy(const ResourceResponse& re sponse)
203 {
204 if (!response.url().protocolIs("blob") && !response.url().protocolIs("file") && !response.url().protocolIs("filesystem")) {
205 m_contentSecurityPolicy = ContentSecurityPolicy::create();
206 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
207 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponse Headers(response));
208 }
209 }
210
200 } // namespace blink 211 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.h ('k') | Source/core/workers/WorkerScriptLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698