| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 return false; | 384 return false; |
| 385 } | 385 } |
| 386 return true; | 386 return true; |
| 387 } | 387 } |
| 388 | 388 |
| 389 bool ContentSecurityPolicy::allowScriptFromSource(const KURL& url, ContentSecuri
tyPolicy::ReportingStatus reportingStatus) const | 389 bool ContentSecurityPolicy::allowScriptFromSource(const KURL& url, ContentSecuri
tyPolicy::ReportingStatus reportingStatus) const |
| 390 { | 390 { |
| 391 return isAllowedByAllWithURL<&CSPDirectiveList::allowScriptFromSource>(m_pol
icies, url, reportingStatus); | 391 return isAllowedByAllWithURL<&CSPDirectiveList::allowScriptFromSource>(m_pol
icies, url, reportingStatus); |
| 392 } | 392 } |
| 393 | 393 |
| 394 bool ContentSecurityPolicy::allowScriptNonce(const String& nonce) const | 394 bool ContentSecurityPolicy::allowScriptWithNonce(const String& nonce) const |
| 395 { | 395 { |
| 396 return isAllowedByAllWithNonce<&CSPDirectiveList::allowScriptNonce>(m_polici
es, nonce); | 396 return isAllowedByAllWithNonce<&CSPDirectiveList::allowScriptNonce>(m_polici
es, nonce); |
| 397 } | 397 } |
| 398 | 398 |
| 399 bool ContentSecurityPolicy::allowStyleNonce(const String& nonce) const | 399 bool ContentSecurityPolicy::allowStyleWithNonce(const String& nonce) const |
| 400 { | 400 { |
| 401 return isAllowedByAllWithNonce<&CSPDirectiveList::allowStyleNonce>(m_policie
s, nonce); | 401 return isAllowedByAllWithNonce<&CSPDirectiveList::allowStyleNonce>(m_policie
s, nonce); |
| 402 } | 402 } |
| 403 | 403 |
| 404 bool ContentSecurityPolicy::allowScriptHash(const String& source) const | 404 bool ContentSecurityPolicy::allowScriptWithHash(const String& source) const |
| 405 { | 405 { |
| 406 return checkDigest<&CSPDirectiveList::allowScriptHash>(source, m_scriptHashA
lgorithmsUsed, m_policies); | 406 return checkDigest<&CSPDirectiveList::allowScriptHash>(source, m_scriptHashA
lgorithmsUsed, m_policies); |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool ContentSecurityPolicy::allowStyleHash(const String& source) const | 409 bool ContentSecurityPolicy::allowStyleWithHash(const String& source) const |
| 410 { | 410 { |
| 411 return checkDigest<&CSPDirectiveList::allowStyleHash>(source, m_styleHashAlg
orithmsUsed, m_policies); | 411 return checkDigest<&CSPDirectiveList::allowStyleHash>(source, m_styleHashAlg
orithmsUsed, m_policies); |
| 412 } | 412 } |
| 413 | 413 |
| 414 void ContentSecurityPolicy::usesScriptHashAlgorithms(uint8_t algorithms) | 414 void ContentSecurityPolicy::usesScriptHashAlgorithms(uint8_t algorithms) |
| 415 { | 415 { |
| 416 m_scriptHashAlgorithmsUsed |= algorithms; | 416 m_scriptHashAlgorithmsUsed |= algorithms; |
| 417 } | 417 } |
| 418 | 418 |
| 419 void ContentSecurityPolicy::usesStyleHashAlgorithms(uint8_t algorithms) | 419 void ContentSecurityPolicy::usesStyleHashAlgorithms(uint8_t algorithms) |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 bool ContentSecurityPolicy::experimentalFeaturesEnabled() const | 764 bool ContentSecurityPolicy::experimentalFeaturesEnabled() const |
| 765 { | 765 { |
| 766 return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnab
led(); | 766 return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnab
led(); |
| 767 } | 767 } |
| 768 | 768 |
| 769 bool ContentSecurityPolicy::shouldBypassMainWorld(ExecutionContext* context) | 769 bool ContentSecurityPolicy::shouldBypassMainWorld(ExecutionContext* context) |
| 770 { | 770 { |
| 771 if (context && context->isDocument()) { | 771 if (context && context->isDocument()) { |
| 772 Document* document = toDocument(context); | 772 Document* document = toDocument(context); |
| 773 if (document->frame()) | 773 if (document->frame()) |
| 774 return document->frame()->script().shouldBypassMainWorldContentSecur
ityPolicy(); | 774 return document->frame()->script().shouldBypassMainWorldCSP(); |
| 775 } | 775 } |
| 776 return false; | 776 return false; |
| 777 } | 777 } |
| 778 | 778 |
| 779 bool ContentSecurityPolicy::shouldSendViolationReport(const String& report) cons
t | 779 bool ContentSecurityPolicy::shouldSendViolationReport(const String& report) cons
t |
| 780 { | 780 { |
| 781 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. | 781 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. |
| 782 return !m_violationReportsSent.contains(report.impl()->hash()); | 782 return !m_violationReportsSent.contains(report.impl()->hash()); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void ContentSecurityPolicy::didSendViolationReport(const String& report) | 785 void ContentSecurityPolicy::didSendViolationReport(const String& report) |
| 786 { | 786 { |
| 787 m_violationReportsSent.add(report.impl()->hash()); | 787 m_violationReportsSent.add(report.impl()->hash()); |
| 788 } | 788 } |
| 789 | 789 |
| 790 } // namespace WebCore | 790 } // namespace WebCore |
| OLD | NEW |