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 securityContext->setContentSecurityPolicy(ContentSecurityPolicy::create()); | |
dcheng
2014/11/18 23:31:40
I'd probably move lines 23-30 to the constructor a
alexmos
2014/11/19 00:33:04
Done.
| |
31 | |
32 // TODO(alexmos): Document::initSecurityContext has a few other things we | |
33 // may eventually want here, such as enforcing a setting to | |
34 // grantUniversalAccess(). | |
35 | |
36 return securityContext.release(); | |
37 } | |
38 | |
39 void RemoteSecurityContext::setReplicatedOrigin(PassRefPtr<SecurityOrigin> origi n) | |
40 { | |
41 // FIXME(alexmos): currently, replicated security origins are passed only | |
42 // at RemoteFrame creation time. Eventually, this class will also need to | |
43 // handle origin updates to handle cases like setting document.domain, but | |
44 // for now, check that this is the first and only time we are setting the | |
45 // origin. | |
46 ASSERT(!haveInitializedSecurityOrigin()); | |
47 setSecurityOrigin(origin); | |
48 } | |
49 | |
50 | |
51 } // namespace blink | |
OLD | NEW |