Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/dom/RemoteSecurityContext.h" | |
| 7 | |
| 8 #include "core/frame/csp/ContentSecurityPolicy.h" | |
| 9 #include "platform/weborigin/SecurityOrigin.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 RemoteSecurityContext::RemoteSecurityContext() | |
| 14 : SecurityContext() | |
| 15 { | |
| 16 } | |
| 17 | |
| 18 PassRefPtr<RemoteSecurityContext> RemoteSecurityContext::create() | |
| 19 { | |
| 20 RefPtr<RemoteSecurityContext> securityContext = | |
| 21 adoptRef(new RemoteSecurityContext()); | |
| 22 | |
| 23 // RemoteSecurityContext's origin is expected to stay uninitialized until | |
| 24 // we set it using replicated origin data from the browser process. | |
| 25 ASSERT(!securityContext->haveInitializedSecurityOrigin()); | |
| 26 | |
| 27 // CSP will not be replicated for RemoteSecurityContexts, as it is moving | |
| 28 // to the browser process. For now, initialize CSP to a default | |
| 29 // locked-down policy. | |
| 30 RefPtr<ContentSecurityPolicy> csp = ContentSecurityPolicy::create(); | |
| 31 securityContext->setContentSecurityPolicy(csp); | |
|
dcheng
2014/11/12 21:57:40
Nit: I would just combine these two lines, since y
alexmos
2014/11/18 18:35:17
Done.
| |
| 32 | |
| 33 // TODO(alexmos): Document::initSecurityContext has a few other things we | |
| 34 // may eventually want here, such as enforcing a setting to | |
| 35 // grantUniversalAccess(). | |
| 36 | |
| 37 return securityContext.release(); | |
| 38 } | |
| 39 | |
| 40 void RemoteSecurityContext::setReplicatedOrigin(PassRefPtr<SecurityOrigin> origi n) | |
| 41 { | |
| 42 // FIXME(alexmos): currently, replicated security origins are passed only | |
| 43 // at RemoteFrame creation time. Eventually, this class will also need to | |
| 44 // handle origin updates to handle cases like setting document.domain, but | |
| 45 // for now, check that this is the first and only time we are setting the | |
| 46 // origin. | |
| 47 ASSERT(!haveInitializedSecurityOrigin()); | |
| 48 setSecurityOrigin(origin); | |
| 49 } | |
| 50 | |
| 51 | |
| 52 } // namespace blink | |
| OLD | NEW |