| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "ContentSecurityPolicy.h" | 27 #include "ContentSecurityPolicy.h" |
| 28 | 28 |
| 29 #include "Console.h" | 29 #include "Console.h" |
| 30 #include "DOMStringList.h" | 30 #include "DOMStringList.h" |
| 31 #include "Document.h" | 31 #include "Document.h" |
| 32 #include "FeatureObserver.h" | 32 #include "UseCounter.h" |
| 33 #include "FormData.h" | 33 #include "FormData.h" |
| 34 #include "FormDataList.h" | 34 #include "FormDataList.h" |
| 35 #include "Frame.h" | 35 #include "Frame.h" |
| 36 #include "InspectorInstrumentation.h" | 36 #include "InspectorInstrumentation.h" |
| 37 #include "InspectorValues.h" | 37 #include "InspectorValues.h" |
| 38 #include "KURL.h" | 38 #include "KURL.h" |
| 39 #include "PingLoader.h" | 39 #include "PingLoader.h" |
| 40 #include "RuntimeEnabledFeatures.h" | 40 #include "RuntimeEnabledFeatures.h" |
| 41 #include "SchemeRegistry.h" | 41 #include "SchemeRegistry.h" |
| 42 #include "ScriptCallStack.h" | 42 #include "ScriptCallStack.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 || equalIgnoringCase(name, scriptSrc) | 140 || equalIgnoringCase(name, scriptSrc) |
| 141 || equalIgnoringCase(name, styleSrc) | 141 || equalIgnoringCase(name, styleSrc) |
| 142 || equalIgnoringCase(name, baseURI) | 142 || equalIgnoringCase(name, baseURI) |
| 143 || equalIgnoringCase(name, formAction) | 143 || equalIgnoringCase(name, formAction) |
| 144 || equalIgnoringCase(name, pluginTypes) | 144 || equalIgnoringCase(name, pluginTypes) |
| 145 || equalIgnoringCase(name, scriptNonce) | 145 || equalIgnoringCase(name, scriptNonce) |
| 146 || equalIgnoringCase(name, reflectedXSS) | 146 || equalIgnoringCase(name, reflectedXSS) |
| 147 ); | 147 ); |
| 148 } | 148 } |
| 149 | 149 |
| 150 FeatureObserver::Feature getFeatureObserverType(ContentSecurityPolicy::HeaderTyp
e type) | 150 UseCounter::Feature getUseCounterType(ContentSecurityPolicy::HeaderType type) |
| 151 { | 151 { |
| 152 switch (type) { | 152 switch (type) { |
| 153 case ContentSecurityPolicy::PrefixedEnforce: | 153 case ContentSecurityPolicy::PrefixedEnforce: |
| 154 return FeatureObserver::PrefixedContentSecurityPolicy; | 154 return UseCounter::PrefixedContentSecurityPolicy; |
| 155 case ContentSecurityPolicy::Enforce: | 155 case ContentSecurityPolicy::Enforce: |
| 156 return FeatureObserver::ContentSecurityPolicy; | 156 return UseCounter::ContentSecurityPolicy; |
| 157 case ContentSecurityPolicy::PrefixedReport: | 157 case ContentSecurityPolicy::PrefixedReport: |
| 158 return FeatureObserver::PrefixedContentSecurityPolicyReportOnly; | 158 return UseCounter::PrefixedContentSecurityPolicyReportOnly; |
| 159 case ContentSecurityPolicy::Report: | 159 case ContentSecurityPolicy::Report: |
| 160 return FeatureObserver::ContentSecurityPolicyReportOnly; | 160 return UseCounter::ContentSecurityPolicyReportOnly; |
| 161 } | 161 } |
| 162 ASSERT_NOT_REACHED(); | 162 ASSERT_NOT_REACHED(); |
| 163 return FeatureObserver::NumberOfFeatures; | 163 return UseCounter::NumberOfFeatures; |
| 164 } | 164 } |
| 165 | 165 |
| 166 const ScriptCallFrame& getFirstNonNativeFrame(PassRefPtr<ScriptCallStack> stack) | 166 const ScriptCallFrame& getFirstNonNativeFrame(PassRefPtr<ScriptCallStack> stack) |
| 167 { | 167 { |
| 168 int frameNumber = 0; | 168 int frameNumber = 0; |
| 169 if (!stack->at(0).lineNumber() && stack->size() > 1 && stack->at(1).lineNumb
er()) | 169 if (!stack->at(0).lineNumber() && stack->size() > 1 && stack->at(1).lineNumb
er()) |
| 170 frameNumber = 1; | 170 frameNumber = 1; |
| 171 | 171 |
| 172 return stack->at(frameNumber); | 172 return stack->at(frameNumber); |
| 173 } | 173 } |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 ASSERT(m_policies.isEmpty()); | 1451 ASSERT(m_policies.isEmpty()); |
| 1452 for (CSPDirectiveListVector::const_iterator iter = other->m_policies.begin()
; iter != other->m_policies.end(); ++iter) | 1452 for (CSPDirectiveListVector::const_iterator iter = other->m_policies.begin()
; iter != other->m_policies.end(); ++iter) |
| 1453 didReceiveHeader((*iter)->header(), (*iter)->headerType()); | 1453 didReceiveHeader((*iter)->header(), (*iter)->headerType()); |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
pe) | 1456 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
pe) |
| 1457 { | 1457 { |
| 1458 if (m_scriptExecutionContext->isDocument()) { | 1458 if (m_scriptExecutionContext->isDocument()) { |
| 1459 Document* document = toDocument(m_scriptExecutionContext); | 1459 Document* document = toDocument(m_scriptExecutionContext); |
| 1460 if (document->domWindow()) | 1460 if (document->domWindow()) |
| 1461 FeatureObserver::observe(document->domWindow(), getFeatureObserverTy
pe(type)); | 1461 UseCounter::observe(document->domWindow(), getUseCounterType(type)); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 // RFC2616, section 4.2 specifies that headers appearing multiple times can | 1464 // RFC2616, section 4.2 specifies that headers appearing multiple times can |
| 1465 // be combined with a comma. Walk the header string, and parse each comma | 1465 // be combined with a comma. Walk the header string, and parse each comma |
| 1466 // separated chunk as a separate header. | 1466 // separated chunk as a separate header. |
| 1467 const UChar* begin = header.characters(); | 1467 const UChar* begin = header.characters(); |
| 1468 const UChar* position = begin; | 1468 const UChar* position = begin; |
| 1469 const UChar* end = begin + header.length(); | 1469 const UChar* end = begin + header.length(); |
| 1470 while (position < end) { | 1470 while (position < end) { |
| 1471 skipUntil(position, end, ','); | 1471 skipUntil(position, end, ','); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 { | 1878 { |
| 1879 InspectorInstrumentation::scriptExecutionBlockedByCSP(m_scriptExecutionConte
xt, directiveText); | 1879 InspectorInstrumentation::scriptExecutionBlockedByCSP(m_scriptExecutionConte
xt, directiveText); |
| 1880 } | 1880 } |
| 1881 | 1881 |
| 1882 bool ContentSecurityPolicy::experimentalFeaturesEnabled() const | 1882 bool ContentSecurityPolicy::experimentalFeaturesEnabled() const |
| 1883 { | 1883 { |
| 1884 return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnab
led(); | 1884 return RuntimeEnabledFeatures::experimentalContentSecurityPolicyFeaturesEnab
led(); |
| 1885 } | 1885 } |
| 1886 | 1886 |
| 1887 } | 1887 } |
| OLD | NEW |