| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/dom/SecurityContext.h" | 27 #include "core/dom/SecurityContext.h" |
| 28 | 28 |
| 29 #include "core/frame/csp/ContentSecurityPolicy.h" | 29 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/weborigin/SecurityOrigin.h" | 31 #include "platform/weborigin/SecurityOrigin.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 SecurityContext::SecurityContext() | 35 SecurityContext::SecurityContext() |
| 36 : m_sandboxFlags(SandboxNone) | 36 : m_sandboxFlags(SandboxNone) |
| 37 , m_hostedInReservedIPRange(false) | 37 , m_addressSpace(WebURLRequest::AddressSpacePublic) |
| 38 , m_insecureRequestsPolicy(InsecureRequestsDoNotUpgrade) | 38 , m_insecureRequestsPolicy(InsecureRequestsDoNotUpgrade) |
| 39 , m_enforceStrictMixedContentChecking(false) | 39 , m_enforceStrictMixedContentChecking(false) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 SecurityContext::~SecurityContext() | 43 SecurityContext::~SecurityContext() |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 DEFINE_TRACE(SecurityContext) | 47 DEFINE_TRACE(SecurityContext) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 void SecurityContext::enforceSandboxFlags(SandboxFlags mask) | 62 void SecurityContext::enforceSandboxFlags(SandboxFlags mask) |
| 63 { | 63 { |
| 64 m_sandboxFlags |= mask; | 64 m_sandboxFlags |= mask; |
| 65 | 65 |
| 66 if (isSandboxed(SandboxOrigin) && securityOrigin() && !securityOrigin()->isU
nique()) { | 66 if (isSandboxed(SandboxOrigin) && securityOrigin() && !securityOrigin()->isU
nique()) { |
| 67 setSecurityOrigin(SecurityOrigin::createUnique()); | 67 setSecurityOrigin(SecurityOrigin::createUnique()); |
| 68 didUpdateSecurityOrigin(); | 68 didUpdateSecurityOrigin(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 WebURLRequest::AddressSpace SecurityContext::addressSpace() const | 72 String SecurityContext::addressSpaceForBindings() const |
| 73 { | 73 { |
| 74 if (m_hostedInReservedIPRange) | 74 switch (m_addressSpace) { |
| 75 return securityOrigin()->isLocalhost() ? WebURLRequest::AddressSpaceLoca
l : WebURLRequest::AddressSpacePrivate; | 75 case WebURLRequest::AddressSpacePublic: |
| 76 return "public"; |
| 76 | 77 |
| 77 return WebURLRequest::AddressSpacePublic; | 78 case WebURLRequest::AddressSpacePrivate: |
| 79 return "private"; |
| 80 |
| 81 case WebURLRequest::AddressSpaceLocal: |
| 82 return "local"; |
| 83 } |
| 84 ASSERT_NOT_REACHED(); |
| 85 return "public"; |
| 78 } | 86 } |
| 79 | 87 |
| 80 bool SecurityContext::hasSuborigin() | 88 bool SecurityContext::hasSuborigin() |
| 81 { | 89 { |
| 82 ASSERT(m_securityOrigin.get()); | 90 ASSERT(m_securityOrigin.get()); |
| 83 return m_securityOrigin->hasSuborigin(); | 91 return m_securityOrigin->hasSuborigin(); |
| 84 } | 92 } |
| 85 | 93 |
| 86 String SecurityContext::suboriginName() | 94 String SecurityContext::suboriginName() |
| 87 { | 95 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 102 return; | 110 return; |
| 103 ASSERT(!name.isEmpty()); | 111 ASSERT(!name.isEmpty()); |
| 104 ASSERT(RuntimeEnabledFeatures::suboriginsEnabled()); | 112 ASSERT(RuntimeEnabledFeatures::suboriginsEnabled()); |
| 105 ASSERT(m_securityOrigin.get()); | 113 ASSERT(m_securityOrigin.get()); |
| 106 ASSERT(!m_securityOrigin->hasSuborigin() || m_securityOrigin->suboriginName(
) == name); | 114 ASSERT(!m_securityOrigin->hasSuborigin() || m_securityOrigin->suboriginName(
) == name); |
| 107 m_securityOrigin->addSuborigin(name); | 115 m_securityOrigin->addSuborigin(name); |
| 108 didUpdateSecurityOrigin(); | 116 didUpdateSecurityOrigin(); |
| 109 } | 117 } |
| 110 | 118 |
| 111 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |