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

Side by Side Diff: Source/core/dom/SecurityContext.h

Issue 793493003: Prepare to replicate sandbox flags for OOPIF (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #ifndef SecurityContext_h 27 #ifndef SecurityContext_h
28 #define SecurityContext_h 28 #define SecurityContext_h
29 29
30 #include "core/dom/SandboxFlags.h"
30 #include "wtf/PassRefPtr.h" 31 #include "wtf/PassRefPtr.h"
31 #include "wtf/RefPtr.h" 32 #include "wtf/RefPtr.h"
32 #include "wtf/text/WTFString.h" 33 #include "wtf/text/WTFString.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
36 class SecurityOrigin; 37 class SecurityOrigin;
37 class ContentSecurityPolicy; 38 class ContentSecurityPolicy;
38 class KURL; 39 class KURL;
39 40
40 class SecurityContext { 41 class SecurityContext {
41 public: 42 public:
42 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } 43 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
43 ContentSecurityPolicy* contentSecurityPolicy() const { return m_contentSecur ityPolicy.get(); } 44 ContentSecurityPolicy* contentSecurityPolicy() const { return m_contentSecur ityPolicy.get(); }
44 45
45 bool isSecureTransitionTo(const KURL&) const; 46 bool isSecureTransitionTo(const KURL&) const;
46 47
47 // Explicitly override the security origin for this security context. 48 // Explicitly override the security origin for this security context.
48 // Note: It is dangerous to change the security origin of a script context 49 // Note: It is dangerous to change the security origin of a script context
49 // that already contains content. 50 // that already contains content.
50 void setSecurityOrigin(PassRefPtr<SecurityOrigin>); 51 void setSecurityOrigin(PassRefPtr<SecurityOrigin>);
52 virtual void didUpdateSecurityOrigin() = 0;
53
54 SandboxFlags sandboxFlags() const { return m_sandboxFlags; }
55 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; }
56 void enforceSandboxFlags(SandboxFlags mask);
51 57
52 protected: 58 protected:
53 SecurityContext(); 59 SecurityContext();
54 virtual ~SecurityContext(); 60 virtual ~SecurityContext();
55 61
56 void setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy>); 62 void setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy>);
57 63
58 void didFailToInitializeSecurityOrigin() { m_haveInitializedSecurityOrigin = false; } 64 void didFailToInitializeSecurityOrigin() { m_haveInitializedSecurityOrigin = false; }
59 bool haveInitializedSecurityOrigin() const { return m_haveInitializedSecurit yOrigin; } 65 bool haveInitializedSecurityOrigin() const { return m_haveInitializedSecurit yOrigin; }
60 66
61 private: 67 private:
62 bool m_haveInitializedSecurityOrigin; 68 bool m_haveInitializedSecurityOrigin;
63 RefPtr<SecurityOrigin> m_securityOrigin; 69 RefPtr<SecurityOrigin> m_securityOrigin;
64 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy; 70 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy;
71
72 SandboxFlags m_sandboxFlags;
65 }; 73 };
66 74
67 } // namespace blink 75 } // namespace blink
68 76
69 #endif // SecurityContext_h 77 #endif // SecurityContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698