OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2288 return NULL; | 2288 return NULL; |
2289 } | 2289 } |
2290 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 2290 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
2291 std::string filter; | 2291 std::string filter; |
2292 if (!list_value->GetString(i, &filter)) { | 2292 if (!list_value->GetString(i, &filter)) { |
2293 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2293 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
2294 errors::kInvalidFileFilterValue, base::IntToString(i)); | 2294 errors::kInvalidFileFilterValue, base::IntToString(i)); |
2295 return NULL; | 2295 return NULL; |
2296 } | 2296 } |
2297 StringToLowerASCII(&filter); | 2297 StringToLowerASCII(&filter); |
2298 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); | 2298 if (!StartsWithASCII(filter, |
| 2299 std::string(chrome::kFileSystemScheme) + ':', |
| 2300 true)) { |
| 2301 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2302 errors::kInvalidURLPatternError, filter); |
| 2303 return NULL; |
| 2304 } |
| 2305 // The user inputs filesystem:*; we don't actually implement scheme |
| 2306 // wildcards in URLPattern, so transform to what will match correctly. |
| 2307 filter.replace(0, 11, "chrome-extension://*/"); |
| 2308 URLPattern pattern(URLPattern::SCHEME_EXTENSION); |
| 2309 pattern.set_partial_filesystem_support_hack(true); |
2299 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { | 2310 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { |
2300 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2311 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
2301 errors::kInvalidURLPatternError, filter); | 2312 errors::kInvalidURLPatternError, filter); |
2302 return NULL; | 2313 return NULL; |
2303 } | 2314 } |
2304 std::string path = pattern.path(); | 2315 std::string path = pattern.path(); |
2305 bool allowed = path == "*" || path == "*.*" || | 2316 bool allowed = path == "/*" || path == "/*.*" || |
2306 (path.compare(0, 2, "*.") == 0 && | 2317 (path.compare(0, 3, "/*.") == 0 && |
2307 path.find_first_of('*', 2) == std::string::npos); | 2318 path.find_first_of('*', 3) == std::string::npos); |
2308 if (!allowed) { | 2319 if (!allowed) { |
2309 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2320 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
2310 errors::kInvalidURLPatternError, filter); | 2321 errors::kInvalidURLPatternError, filter); |
2311 return NULL; | 2322 return NULL; |
2312 } | 2323 } |
2313 result->AddPattern(pattern); | 2324 result->AddPattern(pattern); |
2314 } | 2325 } |
2315 | 2326 |
2316 std::string default_icon; | 2327 std::string default_icon; |
2317 // Read the file browser action |default_icon| (optional). | 2328 // Read the file browser action |default_icon| (optional). |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3498 already_disabled(false), | 3509 already_disabled(false), |
3499 extension(extension) {} | 3510 extension(extension) {} |
3500 | 3511 |
3501 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3512 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3502 const Extension* extension, | 3513 const Extension* extension, |
3503 const ExtensionPermissionSet* permissions, | 3514 const ExtensionPermissionSet* permissions, |
3504 Reason reason) | 3515 Reason reason) |
3505 : reason(reason), | 3516 : reason(reason), |
3506 extension(extension), | 3517 extension(extension), |
3507 permissions(permissions) {} | 3518 permissions(permissions) {} |
OLD | NEW |