| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/content_security_policy/csp_context.h" | 5 #include "content/common/content_security_policy/csp_context.h" |
| 6 | 6 |
| 7 namespace content { | 7 namespace content { |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 CSPContext* context, | 57 CSPContext* context, |
| 58 bool is_redirect) { | 58 bool is_redirect) { |
| 59 // Wildcards match network schemes ('http', 'https', 'ftp', 'ws', 'wss'), and | 59 // Wildcards match network schemes ('http', 'https', 'ftp', 'ws', 'wss'), and |
| 60 // the scheme of the protected resource: | 60 // the scheme of the protected resource: |
| 61 // https://w3c.github.io/webappsec-csp/#match-url-to-source-expression. Other | 61 // https://w3c.github.io/webappsec-csp/#match-url-to-source-expression. Other |
| 62 // schemes, including custom schemes, must be explicitly listed in a source | 62 // schemes, including custom schemes, must be explicitly listed in a source |
| 63 // list. | 63 // list. |
| 64 if (source_list.allow_star) { | 64 if (source_list.allow_star) { |
| 65 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIsSuborigin() || | 65 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIsSuborigin() || |
| 66 url.SchemeIsWSOrWSS() || url.SchemeIs("ftp") || | 66 url.SchemeIsWSOrWSS() || url.SchemeIs("ftp") || |
| 67 context->ProtocolMatchesSelf(url)) | 67 context->ProtocolIsSelf(url)) |
| 68 return true; | 68 return true; |
| 69 | 69 |
| 70 return AllowFromSources(url, source_list.sources, context, is_redirect); | 70 return AllowFromSources(url, source_list.sources, context, is_redirect); |
| 71 } | 71 } |
| 72 | 72 |
| 73 const GURL effective_url = GetEffectiveURL(context, url); | 73 const GURL effective_url = GetEffectiveURL(context, url); |
| 74 | 74 |
| 75 if (source_list.allow_self && context->AllowSelf(effective_url)) | 75 if (source_list.allow_self && context->AllowSelf(effective_url)) |
| 76 return true; | 76 return true; |
| 77 | 77 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 return text.str(); | 102 return text.str(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool CSPSourceList::IsNone() const { | 105 bool CSPSourceList::IsNone() const { |
| 106 return !allow_self && !allow_star && sources.empty(); | 106 return !allow_self && !allow_star && sources.empty(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace content | 109 } // namespace content |
| OLD | NEW |