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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 } | 1414 } |
1415 | 1415 |
1416 ContentSecurityPolicy::~ContentSecurityPolicy() | 1416 ContentSecurityPolicy::~ContentSecurityPolicy() |
1417 { | 1417 { |
1418 } | 1418 } |
1419 | 1419 |
1420 void ContentSecurityPolicy::copyStateFrom(const ContentSecurityPolicy* other) | 1420 void ContentSecurityPolicy::copyStateFrom(const ContentSecurityPolicy* other) |
1421 { | 1421 { |
1422 ASSERT(m_policies.isEmpty()); | 1422 ASSERT(m_policies.isEmpty()); |
1423 for (CSPDirectiveListVector::const_iterator iter = other->m_policies.begin()
; iter != other->m_policies.end(); ++iter) | 1423 for (CSPDirectiveListVector::const_iterator iter = other->m_policies.begin()
; iter != other->m_policies.end(); ++iter) |
1424 didReceiveHeader((*iter)->header(), (*iter)->headerType()); | 1424 addPolicyFromHeaderValue((*iter)->header(), (*iter)->headerType()); |
1425 } | 1425 } |
1426 | 1426 |
1427 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
pe) | 1427 void ContentSecurityPolicy::didReceiveHeader(const String& header, HeaderType ty
pe) |
1428 { | 1428 { |
| 1429 // ContentSecurityPolicy should be mutable only it has a browsing context. I
t should be immutable |
| 1430 // for Documents made by XHR or HTML Imports. |
| 1431 ASSERT(!m_scriptExecutionContext->isDocument() || toDocument(m_scriptExecuti
onContext)->frame()); |
| 1432 addPolicyFromHeaderValue(header, type); |
| 1433 } |
| 1434 |
| 1435 void ContentSecurityPolicy::addPolicyFromHeaderValue(const String& header, Heade
rType type) |
| 1436 { |
1429 if (m_scriptExecutionContext->isDocument()) { | 1437 if (m_scriptExecutionContext->isDocument()) { |
1430 Document* document = toDocument(m_scriptExecutionContext); | 1438 Document* document = toDocument(m_scriptExecutionContext); |
1431 if (type == PrefixedReport || type == PrefixedEnforce) | 1439 if (type == PrefixedReport || type == PrefixedEnforce) |
1432 UseCounter::countDeprecation(document, getUseCounterType(type)); | 1440 UseCounter::countDeprecation(document, getUseCounterType(type)); |
1433 else | 1441 else |
1434 UseCounter::count(document, getUseCounterType(type)); | 1442 UseCounter::count(document, getUseCounterType(type)); |
1435 } | 1443 } |
1436 | 1444 |
1437 Vector<UChar> characters; | 1445 Vector<UChar> characters; |
1438 header.appendTo(characters); | 1446 header.appendTo(characters); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 { | 1880 { |
1873 if (context && context->isDocument()) { | 1881 if (context && context->isDocument()) { |
1874 Document* document = toDocument(context); | 1882 Document* document = toDocument(context); |
1875 if (document->frame()) | 1883 if (document->frame()) |
1876 return document->frame()->script()->shouldBypassMainWorldContentSecu
rityPolicy(); | 1884 return document->frame()->script()->shouldBypassMainWorldContentSecu
rityPolicy(); |
1877 } | 1885 } |
1878 return false; | 1886 return false; |
1879 } | 1887 } |
1880 | 1888 |
1881 } | 1889 } |
OLD | NEW |