Chromium Code Reviews| Index: third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp |
| diff --git a/third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp b/third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp |
| index 61fffb76c38d0e9c1df10853f420fd77231001a6..4c4f2e322835f13c54644ed1d2b5053fa2dcaff0 100644 |
| --- a/third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp |
| +++ b/third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp |
| @@ -126,6 +126,8 @@ SecurityOrigin::SecurityOrigin(const KURL& url) |
| , m_universalAccess(false) |
| , m_domainWasSetInDOM(false) |
| , m_blockLocalAccessFromLocalOrigin(false) |
| + , m_isUniqueOriginPotentiallyTrustworthy(false) |
| + , m_uniqueOriginShouldBypassSecureContextCheck(false) |
| { |
| // Suborigins are serialized into the host, so extract it if necessary. |
| String suboriginName; |
| @@ -154,6 +156,8 @@ SecurityOrigin::SecurityOrigin() |
| , m_domainWasSetInDOM(false) |
| , m_canLoadLocalResources(false) |
| , m_blockLocalAccessFromLocalOrigin(false) |
| + , m_isUniqueOriginPotentiallyTrustworthy(false) |
| + , m_uniqueOriginShouldBypassSecureContextCheck(false) |
| { |
| } |
| @@ -169,6 +173,8 @@ SecurityOrigin::SecurityOrigin(const SecurityOrigin* other) |
| , m_domainWasSetInDOM(other->m_domainWasSetInDOM) |
| , m_canLoadLocalResources(other->m_canLoadLocalResources) |
| , m_blockLocalAccessFromLocalOrigin(other->m_blockLocalAccessFromLocalOrigin) |
| + , m_isUniqueOriginPotentiallyTrustworthy(other->m_isUniqueOriginPotentiallyTrustworthy) |
| + , m_uniqueOriginShouldBypassSecureContextCheck(other->m_uniqueOriginShouldBypassSecureContextCheck) |
| { |
| } |
| @@ -188,13 +194,20 @@ PassRefPtr<SecurityOrigin> SecurityOrigin::create(const KURL& url) |
| return adoptRef(new SecurityOrigin(url)); |
| } |
| -PassRefPtr<SecurityOrigin> SecurityOrigin::createUnique() |
| +PassRefPtr<SecurityOrigin> SecurityOrigin::createUnique(bool isPotentiallyTrustworthy, bool bypassSecureContextCheck) |
| { |
| RefPtr<SecurityOrigin> origin = adoptRef(new SecurityOrigin()); |
| ASSERT(origin->isUnique()); |
| + origin->m_isUniqueOriginPotentiallyTrustworthy = isPotentiallyTrustworthy; |
| + origin->m_uniqueOriginShouldBypassSecureContextCheck = bypassSecureContextCheck; |
| return origin.release(); |
| } |
| +PassRefPtr<SecurityOrigin> SecurityOrigin::createUnique() |
| +{ |
| + return createUnique(false, false); |
| +} |
| + |
| void SecurityOrigin::addSuborigin(const String& suborigin) |
| { |
| ASSERT(RuntimeEnabledFeatures::suboriginsEnabled()); |
| @@ -356,6 +369,10 @@ bool SecurityOrigin::canDisplay(const KURL& url) const |
| bool SecurityOrigin::isPotentiallyTrustworthy() const |
| { |
| ASSERT(m_protocol != "data"); |
| + |
| + if (isUnique()) |
| + return m_isUniqueOriginPotentiallyTrustworthy; |
| + |
| if (SchemeRegistry::shouldTreatURLSchemeAsSecure(m_protocol) || isLocal() || isLocalhost()) |
| return true; |
| @@ -371,6 +388,19 @@ String SecurityOrigin::isPotentiallyTrustworthyErrorMessage() |
| return "Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)."; |
| } |
| +void SecurityOrigin::setIsPotentiallyTrustworthySandboxedOrigin() |
| +{ |
| + ASSERT(isUnique()); |
| + m_isUniqueOriginPotentiallyTrustworthy = true; |
| +} |
| + |
| +bool SecurityOrigin::bypassSecureContextCheck() const |
|
alexmos
2016/03/01 23:32:33
nit: bypassesSecureContextCheck or shouldBypassSec
|
| +{ |
| + if (isUnique()) |
| + return m_uniqueOriginShouldBypassSecureContextCheck; |
| + return SchemeRegistry::schemeShouldBypassSecureContextCheck(protocol()); |
| +} |
| + |
| void SecurityOrigin::grantLoadLocalResources() |
| { |
| // Granting privileges to some, but not all, documents in a SecurityOrigin |