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

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

Issue 1128813003: Give shared workers their own content security policies (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/workers/InProcessWorkerBase.h" 6 #include "core/workers/InProcessWorkerBase.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/events/MessageEvent.h" 9 #include "core/events/MessageEvent.h"
10 #include "core/fetch/ResourceFetcher.h" 10 #include "core/fetch/ResourceFetcher.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 bool InProcessWorkerBase::hasPendingActivity() const 73 bool InProcessWorkerBase::hasPendingActivity() const
74 { 74 {
75 // The worker context does not exist while loading, so we must ensure that t he worker object is not collected, nor are its event listeners. 75 // The worker context does not exist while loading, so we must ensure that t he worker object is not collected, nor are its event listeners.
76 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL oader; 76 return (m_contextProxy && m_contextProxy->hasPendingActivity()) || m_scriptL oader;
77 } 77 }
78 78
79 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy() 79 PassRefPtr<ContentSecurityPolicy> InProcessWorkerBase::contentSecurityPolicy()
80 { 80 {
81 return m_contentSecurityPolicy; 81 return WorkerScriptLoaderClient::contentSecurityPolicy();
82 } 82 }
83 83
84 void InProcessWorkerBase::didReceiveResponse(unsigned long identifier, const Res ourceResponse& response) 84 void InProcessWorkerBase::didReceiveResponse(unsigned long identifier, const Res ourceResponse& response)
85 { 85 {
86 if (!response.url().protocolIs("blob") && !response.url().protocolIs("file") && !response.url().protocolIs("filesystem")) { 86 processContentSecurityPolicy(response);
87 m_contentSecurityPolicy = ContentSecurityPolicy::create();
88 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
89 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponse Headers(response));
90 }
91 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), ident ifier); 87 InspectorInstrumentation::didReceiveScriptResponse(executionContext(), ident ifier);
92 } 88 }
93 89
94 void InProcessWorkerBase::notifyFinished() 90 void InProcessWorkerBase::notifyFinished()
95 { 91 {
96 if (m_scriptLoader->failed()) { 92 if (m_scriptLoader->failed()) {
97 dispatchEvent(Event::createCancelable(EventTypeNames::error)); 93 dispatchEvent(Event::createCancelable(EventTypeNames::error));
98 } else { 94 } else {
99 ASSERT(m_contextProxy); 95 ASSERT(m_contextProxy);
100 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart; 96 WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
101 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio nContext())) 97 if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executio nContext()))
102 startMode = PauseWorkerGlobalScopeOnStart; 98 startMode = PauseWorkerGlobalScopeOnStart;
103 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode) ; 99 m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionC ontext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode) ;
104 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script()); 100 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script());
105 } 101 }
106 m_scriptLoader = nullptr; 102 m_scriptLoader = nullptr;
107 } 103 }
108 104
109 DEFINE_TRACE(InProcessWorkerBase) 105 DEFINE_TRACE(InProcessWorkerBase)
110 { 106 {
111 AbstractWorker::trace(visitor); 107 AbstractWorker::trace(visitor);
112 } 108 }
113 109
114 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698