| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void ContentSecurityPolicy::bindToExecutionContext(ExecutionContext* executionCo
ntext) | 144 void ContentSecurityPolicy::bindToExecutionContext(ExecutionContext* executionCo
ntext) |
| 145 { | 145 { |
| 146 m_executionContext = executionContext; | 146 m_executionContext = executionContext; |
| 147 applyPolicySideEffectsToExecutionContext(); | 147 applyPolicySideEffectsToExecutionContext(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext() | 150 void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext() |
| 151 { | 151 { |
| 152 ASSERT(m_executionContext); | 152 ASSERT(m_executionContext); |
| 153 // Ensure that 'self' processes correctly. | 153 // Ensure that 'self' processes correctly. |
| 154 m_selfSource = adoptPtr(new CSPSource(this, securityOrigin()->protocol(), se
curityOrigin()->host(), securityOrigin()->port(), String(), CSPSource::NoWildcar
d, CSPSource::NoWildcard)); | 154 m_selfSource = adoptPtr(new CSPSource(this, securityOrigin()->protocol(), se
curityOrigin()->host(), securityOrigin()->port(), String(), false, false)); |
| 155 | 155 |
| 156 // If we're in a Document, set the referrer policy and sandbox flags, then d
ump all the | 156 // If we're in a Document, set the referrer policy and sandbox flags, then d
ump all the |
| 157 // parsing error messages, then poke at histograms. | 157 // parsing error messages, then poke at histograms. |
| 158 if (Document* document = this->document()) { | 158 if (Document* document = this->document()) { |
| 159 document->enforceSandboxFlags(m_sandboxMask); | 159 document->enforceSandboxFlags(m_sandboxMask); |
| 160 if (didSetReferrerPolicy()) | 160 if (didSetReferrerPolicy()) |
| 161 document->setReferrerPolicy(m_referrerPolicy); | 161 document->setReferrerPolicy(m_referrerPolicy); |
| 162 | 162 |
| 163 for (ConsoleMessageVector::const_iterator iter = m_consoleMessages.begin
(); iter != m_consoleMessages.end(); ++iter) | 163 for (ConsoleMessageVector::const_iterator iter = m_consoleMessages.begin
(); iter != m_consoleMessages.end(); ++iter) |
| 164 m_executionContext->addConsoleMessage(*iter); | 164 m_executionContext->addConsoleMessage(*iter); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 { | 255 { |
| 256 m_overrideInlineStyleAllowed = value; | 256 m_overrideInlineStyleAllowed = value; |
| 257 } | 257 } |
| 258 | 258 |
| 259 void ContentSecurityPolicy::setOverrideURLForSelf(const KURL& url) | 259 void ContentSecurityPolicy::setOverrideURLForSelf(const KURL& url) |
| 260 { | 260 { |
| 261 // Create a temporary CSPSource so that 'self' expressions can be resolved b
efore we bind to | 261 // Create a temporary CSPSource so that 'self' expressions can be resolved b
efore we bind to |
| 262 // an execution context (for 'frame-ancestor' resolution, for example). This
CSPSource will | 262 // an execution context (for 'frame-ancestor' resolution, for example). This
CSPSource will |
| 263 // be overwritten when we bind this object to an execution context. | 263 // be overwritten when we bind this object to an execution context. |
| 264 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url); | 264 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url); |
| 265 m_selfSource = adoptPtr(new CSPSource(this, origin->protocol(), origin->host
(), origin->port(), String(), CSPSource::NoWildcard, CSPSource::NoWildcard)); | 265 m_selfSource = adoptPtr(new CSPSource(this, origin->protocol(), origin->host
(), origin->port(), String(), false, false)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 const String& ContentSecurityPolicy::deprecatedHeader() const | 268 const String& ContentSecurityPolicy::deprecatedHeader() const |
| 269 { | 269 { |
| 270 return m_policies.isEmpty() ? emptyString() : m_policies[0]->header(); | 270 return m_policies.isEmpty() ? emptyString() : m_policies[0]->header(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 ContentSecurityPolicyHeaderType ContentSecurityPolicy::deprecatedHeaderType() co
nst | 273 ContentSecurityPolicyHeaderType ContentSecurityPolicy::deprecatedHeaderType() co
nst |
| 274 { | 274 { |
| 275 return m_policies.isEmpty() ? ContentSecurityPolicyHeaderTypeEnforce : m_pol
icies[0]->headerType(); | 275 return m_policies.isEmpty() ? ContentSecurityPolicyHeaderTypeEnforce : m_pol
icies[0]->headerType(); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. | 853 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. |
| 854 return !m_violationReportsSent.contains(report.impl()->hash()); | 854 return !m_violationReportsSent.contains(report.impl()->hash()); |
| 855 } | 855 } |
| 856 | 856 |
| 857 void ContentSecurityPolicy::didSendViolationReport(const String& report) | 857 void ContentSecurityPolicy::didSendViolationReport(const String& report) |
| 858 { | 858 { |
| 859 m_violationReportsSent.add(report.impl()->hash()); | 859 m_violationReportsSent.add(report.impl()->hash()); |
| 860 } | 860 } |
| 861 | 861 |
| 862 } // namespace blink | 862 } // namespace blink |
| OLD | NEW |