diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-11 10:03:25 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-11 10:03:25 +0100 |
commit | d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (patch) | |
tree | b318cf594dc1da2fa48224005945c9157f35bb41 /Source/WebCore/workers | |
parent | 6300a96eca9f152b379f1bcf3d9efdc5572d989a (diff) | |
download | qtwebkit-d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9.tar.gz |
Imported WebKit commit 75bb2fc5882d2e1b3d5572c2961507996cbca5e3 (http://svn.webkit.org/repository/webkit/trunk@104681)
Diffstat (limited to 'Source/WebCore/workers')
-rw-r--r-- | Source/WebCore/workers/DedicatedWorkerContext.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/workers/DedicatedWorkerContext.h | 7 | ||||
-rw-r--r-- | Source/WebCore/workers/DedicatedWorkerThread.cpp | 12 | ||||
-rw-r--r-- | Source/WebCore/workers/DedicatedWorkerThread.h | 7 | ||||
-rw-r--r-- | Source/WebCore/workers/DefaultSharedWorkerRepository.cpp | 9 | ||||
-rw-r--r-- | Source/WebCore/workers/DefaultSharedWorkerRepository.h | 3 | ||||
-rw-r--r-- | Source/WebCore/workers/SharedWorkerContext.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/workers/SharedWorkerContext.h | 7 | ||||
-rw-r--r-- | Source/WebCore/workers/SharedWorkerThread.cpp | 12 | ||||
-rw-r--r-- | Source/WebCore/workers/SharedWorkerThread.h | 7 | ||||
-rw-r--r-- | Source/WebCore/workers/WorkerContext.cpp | 6 | ||||
-rw-r--r-- | Source/WebCore/workers/WorkerContext.h | 3 | ||||
-rw-r--r-- | Source/WebCore/workers/WorkerMessagingProxy.cpp | 5 | ||||
-rw-r--r-- | Source/WebCore/workers/WorkerThread.cpp | 18 | ||||
-rw-r--r-- | Source/WebCore/workers/WorkerThread.h | 5 |
15 files changed, 62 insertions, 47 deletions
diff --git a/Source/WebCore/workers/DedicatedWorkerContext.cpp b/Source/WebCore/workers/DedicatedWorkerContext.cpp index ec3eca89b..202e29907 100644 --- a/Source/WebCore/workers/DedicatedWorkerContext.cpp +++ b/Source/WebCore/workers/DedicatedWorkerContext.cpp @@ -41,8 +41,8 @@ namespace WebCore { -DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread) - : WorkerContext(url, userAgent, thread) +DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) + : WorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType) { } diff --git a/Source/WebCore/workers/DedicatedWorkerContext.h b/Source/WebCore/workers/DedicatedWorkerContext.h index 4edf64f4f..be5befc03 100644 --- a/Source/WebCore/workers/DedicatedWorkerContext.h +++ b/Source/WebCore/workers/DedicatedWorkerContext.h @@ -33,6 +33,7 @@ #if ENABLE(WORKERS) +#include "ContentSecurityPolicy.h" #include "MessagePort.h" #include "WorkerContext.h" @@ -43,9 +44,9 @@ namespace WebCore { class DedicatedWorkerContext : public WorkerContext { public: typedef WorkerContext Base; - static PassRefPtr<DedicatedWorkerContext> create(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread) + static PassRefPtr<DedicatedWorkerContext> create(const KURL& url, const String& userAgent, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return adoptRef(new DedicatedWorkerContext(url, userAgent, thread)); + return adoptRef(new DedicatedWorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType)); } virtual bool isDedicatedWorkerContext() const { return true; } @@ -65,7 +66,7 @@ namespace WebCore { DedicatedWorkerThread* thread(); private: - DedicatedWorkerContext(const KURL&, const String&, DedicatedWorkerThread*); + DedicatedWorkerContext(const KURL&, const String& userAgent, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); }; } // namespace WebCore diff --git a/Source/WebCore/workers/DedicatedWorkerThread.cpp b/Source/WebCore/workers/DedicatedWorkerThread.cpp index bd406a241..5f60dd85e 100644 --- a/Source/WebCore/workers/DedicatedWorkerThread.cpp +++ b/Source/WebCore/workers/DedicatedWorkerThread.cpp @@ -39,13 +39,13 @@ namespace WebCore { -PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode) +PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode)); + return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)); } -DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode) - : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode) +DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) + : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType) , m_workerObjectProxy(workerObjectProxy) { } @@ -54,9 +54,9 @@ DedicatedWorkerThread::~DedicatedWorkerThread() { } -PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent) +PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return DedicatedWorkerContext::create(url, userAgent, this); + return DedicatedWorkerContext::create(url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType); } void DedicatedWorkerThread::runEventLoop() diff --git a/Source/WebCore/workers/DedicatedWorkerThread.h b/Source/WebCore/workers/DedicatedWorkerThread.h index cafffc00f..12a44da04 100644 --- a/Source/WebCore/workers/DedicatedWorkerThread.h +++ b/Source/WebCore/workers/DedicatedWorkerThread.h @@ -32,6 +32,7 @@ #if ENABLE(WORKERS) +#include "ContentSecurityPolicy.h" #include "WorkerThread.h" namespace WebCore { @@ -40,16 +41,16 @@ namespace WebCore { class DedicatedWorkerThread : public WorkerThread { public: - static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode); + static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; } ~DedicatedWorkerThread(); protected: - virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL& url, const String& userAgent); + virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); virtual void runEventLoop(); private: - DedicatedWorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode); + DedicatedWorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); WorkerObjectProxy& m_workerObjectProxy; }; diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp index 9cf5297fa..8ca4db897 100644 --- a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp +++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp @@ -319,7 +319,10 @@ void SharedWorkerScriptLoader::notifyFinished() m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true)); else { InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); - DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, m_worker->scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release()); + DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, m_worker->scriptExecutionContext()->userAgent(m_scriptLoader->url()), + m_scriptLoader->script(), m_port.release(), + m_worker->scriptExecutionContext()->contentSecurityPolicy()->policy(), + m_worker->scriptExecutionContext()->contentSecurityPolicy()->headerType()); } m_worker->unsetPendingActivity(m_worker.get()); this->deref(); // This frees this object - must be the last action in this function. @@ -331,7 +334,7 @@ DefaultSharedWorkerRepository& DefaultSharedWorkerRepository::instance() return *instance; } -void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel> port) +void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel> port, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { MutexLocker lock(m_lock); if (proxy.isClosing()) @@ -339,7 +342,7 @@ void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, // Another loader may have already started up a thread for this proxy - if so, just send a connect to the pre-existing thread. if (!proxy.thread()) { - RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy, proxy, DontPauseWorkerContextOnStart); + RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy, proxy, DontPauseWorkerContextOnStart, contentSecurityPolicy, contentSecurityPolicyType); proxy.setThread(thread); thread->start(); } diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.h b/Source/WebCore/workers/DefaultSharedWorkerRepository.h index 5d5bfe8ad..75d90e0d1 100644 --- a/Source/WebCore/workers/DefaultSharedWorkerRepository.h +++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.h @@ -33,6 +33,7 @@ #if ENABLE(SHARED_WORKERS) +#include "ContentSecurityPolicy.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/Noncopyable.h> @@ -58,7 +59,7 @@ namespace WebCore { WTF_MAKE_NONCOPYABLE(DefaultSharedWorkerRepository); WTF_MAKE_FAST_ALLOCATED; public: // Invoked once the worker script has been loaded to fire up the worker thread. - void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel>); + void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); // Internal implementation of SharedWorkerRepository::connect() void connectToWorker(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const KURL&, const String& name, ExceptionCode&); diff --git a/Source/WebCore/workers/SharedWorkerContext.cpp b/Source/WebCore/workers/SharedWorkerContext.cpp index 9c94cd8c4..72d98274b 100644 --- a/Source/WebCore/workers/SharedWorkerContext.cpp +++ b/Source/WebCore/workers/SharedWorkerContext.cpp @@ -50,8 +50,8 @@ PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> port) return event.release(); } -SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread) - : WorkerContext(url, userAgent, thread) +SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) + : WorkerContext(url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType) , m_name(name) { } diff --git a/Source/WebCore/workers/SharedWorkerContext.h b/Source/WebCore/workers/SharedWorkerContext.h index 4f2b1dfc5..79d87b924 100644 --- a/Source/WebCore/workers/SharedWorkerContext.h +++ b/Source/WebCore/workers/SharedWorkerContext.h @@ -33,6 +33,7 @@ #if ENABLE(SHARED_WORKERS) +#include "ContentSecurityPolicy.h" #include "WorkerContext.h" namespace WebCore { @@ -43,9 +44,9 @@ namespace WebCore { class SharedWorkerContext : public WorkerContext { public: typedef WorkerContext Base; - static PassRefPtr<SharedWorkerContext> create(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread) + static PassRefPtr<SharedWorkerContext> create(const String& name, const KURL& url, const String& userAgent, SharedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return adoptRef(new SharedWorkerContext(name, url, userAgent, thread)); + return adoptRef(new SharedWorkerContext(name, url, userAgent, thread, contentSecurityPolicy, contentSecurityPolicyType)); } virtual ~SharedWorkerContext(); @@ -60,7 +61,7 @@ namespace WebCore { SharedWorkerThread* thread(); private: - SharedWorkerContext(const String& name, const KURL&, const String&, SharedWorkerThread*); + SharedWorkerContext(const String& name, const KURL&, const String&, SharedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); diff --git a/Source/WebCore/workers/SharedWorkerThread.cpp b/Source/WebCore/workers/SharedWorkerThread.cpp index 917be3edc..13432ece8 100644 --- a/Source/WebCore/workers/SharedWorkerThread.cpp +++ b/Source/WebCore/workers/SharedWorkerThread.cpp @@ -38,13 +38,13 @@ namespace WebCore { -PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode) +PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode)); + return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)); } -SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode) - : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode) +SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) + : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType) , m_name(name.isolatedCopy()) { } @@ -53,9 +53,9 @@ SharedWorkerThread::~SharedWorkerThread() { } -PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent) +PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return SharedWorkerContext::create(m_name, url, userAgent, this); + return SharedWorkerContext::create(m_name, url, userAgent, this, contentSecurityPolicy, contentSecurityPolicyType); } } // namespace WebCore diff --git a/Source/WebCore/workers/SharedWorkerThread.h b/Source/WebCore/workers/SharedWorkerThread.h index d60378dee..a58230dc2 100644 --- a/Source/WebCore/workers/SharedWorkerThread.h +++ b/Source/WebCore/workers/SharedWorkerThread.h @@ -32,20 +32,21 @@ #if ENABLE(SHARED_WORKERS) +#include "ContentSecurityPolicy.h" #include "WorkerThread.h" namespace WebCore { class SharedWorkerThread : public WorkerThread { public: - static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode); + static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); ~SharedWorkerThread(); protected: - virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String&); + virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String&, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); private: - SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode); + SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); String m_name; }; diff --git a/Source/WebCore/workers/WorkerContext.cpp b/Source/WebCore/workers/WorkerContext.cpp index c284608f1..65851854f 100644 --- a/Source/WebCore/workers/WorkerContext.cpp +++ b/Source/WebCore/workers/WorkerContext.cpp @@ -108,7 +108,7 @@ public: virtual bool isCleanupTask() const { return true; } }; -WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread) +WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread, const String& policy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) : m_url(url) , m_userAgent(userAgent) , m_script(adoptPtr(new WorkerScriptController(this))) @@ -120,10 +120,8 @@ WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThr , m_eventQueue(WorkerEventQueue::create(this)) { setSecurityOrigin(SecurityOrigin::create(url)); - - // FIXME: This should probably adopt the ContentSecurityPolicy of the document - // that created this worker or use the header that came with the worker script. setContentSecurityPolicy(ContentSecurityPolicy::create(this)); + contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType); } WorkerContext::~WorkerContext() diff --git a/Source/WebCore/workers/WorkerContext.h b/Source/WebCore/workers/WorkerContext.h index c94fa0978..c1801b107 100644 --- a/Source/WebCore/workers/WorkerContext.h +++ b/Source/WebCore/workers/WorkerContext.h @@ -29,6 +29,7 @@ #if ENABLE(WORKERS) +#include "ContentSecurityPolicy.h" #include "EventListener.h" #include "EventNames.h" #include "EventTarget.h" @@ -179,7 +180,7 @@ namespace WebCore { #endif protected: - WorkerContext(const KURL&, const String&, WorkerThread*); + WorkerContext(const KURL&, const String&, WorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); void addMessageToWorkerConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp index 392a60953..e4cd796f2 100644 --- a/Source/WebCore/workers/WorkerMessagingProxy.cpp +++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp @@ -31,6 +31,7 @@ #include "WorkerMessagingProxy.h" +#include "ContentSecurityPolicy.h" #include "CrossThreadTask.h" #include "DedicatedWorkerContext.h" #include "DedicatedWorkerThread.h" @@ -270,7 +271,9 @@ WorkerMessagingProxy::~WorkerMessagingProxy() void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) { - RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode); + RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode, + m_scriptExecutionContext->contentSecurityPolicy()->policy(), + m_scriptExecutionContext->contentSecurityPolicy()->headerType()); workerThreadCreated(thread); thread->start(); } diff --git a/Source/WebCore/workers/WorkerThread.cpp b/Source/WebCore/workers/WorkerThread.cpp index 9682cd583..93ba0bfb0 100644 --- a/Source/WebCore/workers/WorkerThread.cpp +++ b/Source/WebCore/workers/WorkerThread.cpp @@ -65,32 +65,36 @@ unsigned WorkerThread::workerThreadCount() struct WorkerThreadStartupData { WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; public: - static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) + static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) { - return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode, startMode)); + return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType)); } KURL m_scriptURL; String m_userAgent; String m_sourceCode; WorkerThreadStartMode m_startMode; + String m_contentSecurityPolicy; + ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType; private: - WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode); + WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType); }; -WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) +WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) : m_scriptURL(scriptURL.copy()) , m_userAgent(userAgent.isolatedCopy()) , m_sourceCode(sourceCode.isolatedCopy()) , m_startMode(startMode) + , m_contentSecurityPolicy(contentSecurityPolicy.isolatedCopy()) + , m_contentSecurityPolicyType(contentSecurityPolicyType) { } -WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode) +WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType) : m_threadID(0) , m_workerLoaderProxy(workerLoaderProxy) , m_workerReportingProxy(workerReportingProxy) - , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode)) + , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType)) #if ENABLE(NOTIFICATIONS) , m_notificationPresenter(0) #endif @@ -128,7 +132,7 @@ void* WorkerThread::workerThread() { { MutexLocker lock(m_threadCreationMutex); - m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent); + m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType); if (m_runLoop.terminated()) { // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet, diff --git a/Source/WebCore/workers/WorkerThread.h b/Source/WebCore/workers/WorkerThread.h index 6f3b2220f..6646b1148 100644 --- a/Source/WebCore/workers/WorkerThread.h +++ b/Source/WebCore/workers/WorkerThread.h @@ -29,6 +29,7 @@ #if ENABLE(WORKERS) +#include "ContentSecurityPolicy.h" #include "WorkerRunLoop.h" #include <wtf/Forward.h> #include <wtf/OwnPtr.h> @@ -67,10 +68,10 @@ namespace WebCore { #endif protected: - WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode); + WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); // Factory method for creating a new worker context for the thread. - virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL& url, const String& userAgent) = 0; + virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType) = 0; // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop. virtual void runEventLoop(); |