| OLD | NEW |
| 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 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // The ordering here is important: 'Upgrade' overrides 'DoNotUpgrade'. | 53 // The ordering here is important: 'Upgrade' overrides 'DoNotUpgrade'. |
| 54 enum InsecureRequestsPolicy { | 54 enum InsecureRequestsPolicy { |
| 55 InsecureRequestsDoNotUpgrade = 0, | 55 InsecureRequestsDoNotUpgrade = 0, |
| 56 InsecureRequestsUpgrade | 56 InsecureRequestsUpgrade |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } | 59 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } |
| 60 ContentSecurityPolicy* contentSecurityPolicy() const { return m_contentSecur
ityPolicy.get(); } | 60 ContentSecurityPolicy* contentSecurityPolicy() const { return m_contentSecur
ityPolicy.get(); } |
| 61 | 61 |
| 62 bool isSecureTransitionTo(const KURL&) const; | |
| 63 | |
| 64 // Explicitly override the security origin for this security context. | 62 // Explicitly override the security origin for this security context. |
| 65 // Note: It is dangerous to change the security origin of a script context | 63 // Note: It is dangerous to change the security origin of a script context |
| 66 // that already contains content. | 64 // that already contains content. |
| 67 void setSecurityOrigin(PassRefPtr<SecurityOrigin>); | 65 void setSecurityOrigin(PassRefPtr<SecurityOrigin>); |
| 68 virtual void didUpdateSecurityOrigin() = 0; | 66 virtual void didUpdateSecurityOrigin() = 0; |
| 69 | 67 |
| 70 SandboxFlags getSandboxFlags() const { return m_sandboxFlags; } | 68 SandboxFlags getSandboxFlags() const { return m_sandboxFlags; } |
| 71 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; } | 69 bool isSandboxed(SandboxFlags mask) const { return m_sandboxFlags & mask; } |
| 72 void enforceSandboxFlags(SandboxFlags mask); | 70 void enforceSandboxFlags(SandboxFlags mask); |
| 73 | 71 |
| 74 void setHostedInReservedIPRange() { m_hostedInReservedIPRange = true; } | 72 void setHostedInReservedIPRange() { m_hostedInReservedIPRange = true; } |
| 75 bool isHostedInReservedIPRange() const { return m_hostedInReservedIPRange; } | 73 bool isHostedInReservedIPRange() const { return m_hostedInReservedIPRange; } |
| 76 | 74 |
| 77 void setInsecureRequestsPolicy(InsecureRequestsPolicy policy) { m_insecureRe
questsPolicy = policy; } | 75 void setInsecureRequestsPolicy(InsecureRequestsPolicy policy) { m_insecureRe
questsPolicy = policy; } |
| 78 InsecureRequestsPolicy getInsecureRequestsPolicy() const { return m_insecure
RequestsPolicy; } | 76 InsecureRequestsPolicy getInsecureRequestsPolicy() const { return m_insecure
RequestsPolicy; } |
| 79 | 77 |
| 80 void addInsecureNavigationUpgrade(unsigned hashedHost) { m_insecureNavigatio
nsToUpgrade.add(hashedHost); } | 78 void addInsecureNavigationUpgrade(unsigned hashedHost) { m_insecureNavigatio
nsToUpgrade.add(hashedHost); } |
| 81 InsecureNavigationsSet* insecureNavigationsToUpgrade() { return &m_insecureN
avigationsToUpgrade; } | 79 InsecureNavigationsSet* insecureNavigationsToUpgrade() { return &m_insecureN
avigationsToUpgrade; } |
| 82 | 80 |
| 83 void setShouldEnforceStrictMixedContentChecking(bool shouldEnforce) { m_enfo
rceStrictMixedContentChecking = shouldEnforce; } | 81 void setShouldEnforceStrictMixedContentChecking(bool shouldEnforce) { m_enfo
rceStrictMixedContentChecking = shouldEnforce; } |
| 84 bool shouldEnforceStrictMixedContentChecking() { return m_enforceStrictMixed
ContentChecking; } | 82 bool shouldEnforceStrictMixedContentChecking() { return m_enforceStrictMixed
ContentChecking; } |
| 85 | 83 |
| 86 protected: | 84 protected: |
| 87 SecurityContext(); | 85 SecurityContext(); |
| 88 virtual ~SecurityContext(); | 86 virtual ~SecurityContext(); |
| 89 | 87 |
| 90 void setContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityPolicy>)
; | 88 void setContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityPolicy>)
; |
| 91 | 89 |
| 92 void didFailToInitializeSecurityOrigin() { m_haveInitializedSecurityOrigin =
false; } | |
| 93 bool haveInitializedSecurityOrigin() const { return m_haveInitializedSecurit
yOrigin; } | |
| 94 | |
| 95 private: | 90 private: |
| 96 bool m_haveInitializedSecurityOrigin; | |
| 97 RefPtr<SecurityOrigin> m_securityOrigin; | 91 RefPtr<SecurityOrigin> m_securityOrigin; |
| 98 RefPtrWillBeMember<ContentSecurityPolicy> m_contentSecurityPolicy; | 92 RefPtrWillBeMember<ContentSecurityPolicy> m_contentSecurityPolicy; |
| 99 | 93 |
| 100 SandboxFlags m_sandboxFlags; | 94 SandboxFlags m_sandboxFlags; |
| 101 | 95 |
| 102 bool m_hostedInReservedIPRange; | 96 bool m_hostedInReservedIPRange; |
| 103 InsecureRequestsPolicy m_insecureRequestsPolicy; | 97 InsecureRequestsPolicy m_insecureRequestsPolicy; |
| 104 InsecureNavigationsSet m_insecureNavigationsToUpgrade; | 98 InsecureNavigationsSet m_insecureNavigationsToUpgrade; |
| 105 bool m_enforceStrictMixedContentChecking; | 99 bool m_enforceStrictMixedContentChecking; |
| 106 }; | 100 }; |
| 107 | 101 |
| 108 } // namespace blink | 102 } // namespace blink |
| 109 | 103 |
| 110 #endif // SecurityContext_h | 104 #endif // SecurityContext_h |
| OLD | NEW |