OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/csp_validator.h" | 5 #include "extensions/common/csp_validator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "content/public/common/url_constants.h" |
| 13 #include "extensions/common/constants.h" |
12 | 14 |
13 namespace extensions { | 15 namespace extensions { |
14 | 16 |
15 namespace csp_validator { | 17 namespace csp_validator { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 const char kDefaultSrc[] = "default-src"; | 21 const char kDefaultSrc[] = "default-src"; |
20 const char kScriptSrc[] = "script-src"; | 22 const char kScriptSrc[] = "script-src"; |
21 const char kObjectSrc[] = "object-src"; | 23 const char kObjectSrc[] = "object-src"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (source == "'self'" || | 66 if (source == "'self'" || |
65 source == "'none'" || | 67 source == "'none'" || |
66 source == "http://127.0.0.1" || | 68 source == "http://127.0.0.1" || |
67 LowerCaseEqualsASCII(source, "blob:") || | 69 LowerCaseEqualsASCII(source, "blob:") || |
68 LowerCaseEqualsASCII(source, "filesystem:") || | 70 LowerCaseEqualsASCII(source, "filesystem:") || |
69 LowerCaseEqualsASCII(source, "http://localhost") || | 71 LowerCaseEqualsASCII(source, "http://localhost") || |
70 StartsWithASCII(source, "http://127.0.0.1:", false) || | 72 StartsWithASCII(source, "http://127.0.0.1:", false) || |
71 StartsWithASCII(source, "http://localhost:", false) || | 73 StartsWithASCII(source, "http://localhost:", false) || |
72 StartsWithASCII(source, "https://", true) || | 74 StartsWithASCII(source, "https://", true) || |
73 StartsWithASCII(source, "chrome://", true) || | 75 StartsWithASCII(source, "chrome://", true) || |
74 StartsWithASCII(source, "chrome-extension://", true) || | 76 StartsWithASCII(source, std::string(extensions::kExtensionScheme) + |
| 77 content::kStandardSchemeSeparator, true) || |
75 StartsWithASCII(source, "chrome-extension-resource:", true)) { | 78 StartsWithASCII(source, "chrome-extension-resource:", true)) { |
76 continue; | 79 continue; |
77 } | 80 } |
78 | 81 |
79 // crbug.com/146487 | 82 // crbug.com/146487 |
80 if (type == Manifest::TYPE_EXTENSION || | 83 if (type == Manifest::TYPE_EXTENSION || |
81 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { | 84 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { |
82 if (source == "'unsafe-eval'") | 85 if (source == "'unsafe-eval'") |
83 continue; | 86 continue; |
84 } | 87 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 196 } |
194 } | 197 } |
195 } | 198 } |
196 | 199 |
197 return seen_sandbox; | 200 return seen_sandbox; |
198 } | 201 } |
199 | 202 |
200 } // namespace csp_validator | 203 } // namespace csp_validator |
201 | 204 |
202 } // namespace extensions | 205 } // namespace extensions |
OLD | NEW |