| 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 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2470 return NULL; | 2470 return NULL; |
| 2471 } | 2471 } |
| 2472 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 2472 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 2473 std::string filter; | 2473 std::string filter; |
| 2474 if (!list_value->GetString(i, &filter)) { | 2474 if (!list_value->GetString(i, &filter)) { |
| 2475 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2475 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2476 errors::kInvalidFileFilterValue, base::IntToString(i)); | 2476 errors::kInvalidFileFilterValue, base::IntToString(i)); |
| 2477 return NULL; | 2477 return NULL; |
| 2478 } | 2478 } |
| 2479 StringToLowerASCII(&filter); | 2479 StringToLowerASCII(&filter); |
| 2480 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); | 2480 if (!StartsWithASCII(filter, |
| 2481 std::string(chrome::kFileSystemScheme) + ':', |
| 2482 true)) { |
| 2483 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2484 errors::kInvalidURLPatternError, filter); |
| 2485 return NULL; |
| 2486 } |
| 2487 // The user inputs filesystem:*; we don't actually implement scheme |
| 2488 // wildcards in URLPattern, so transform to what will match correctly. |
| 2489 filter.replace(0, 11, "chrome-extension://*/"); |
| 2490 URLPattern pattern(URLPattern::SCHEME_EXTENSION); |
| 2491 pattern.set_partial_filesystem_support_hack(true); |
| 2481 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { | 2492 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { |
| 2482 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2493 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2483 errors::kInvalidURLPatternError, filter); | 2494 errors::kInvalidURLPatternError, filter); |
| 2484 return NULL; | 2495 return NULL; |
| 2485 } | 2496 } |
| 2486 std::string path = pattern.path(); | 2497 std::string path = pattern.path(); |
| 2487 bool allowed = path == "*" || path == "*.*" || | 2498 bool allowed = path == "/*" || path == "/*.*" || |
| 2488 (path.compare(0, 2, "*.") == 0 && | 2499 (path.compare(0, 3, "/*.") == 0 && |
| 2489 path.find_first_of('*', 2) == std::string::npos); | 2500 path.find_first_of('*', 3) == std::string::npos); |
| 2490 if (!allowed) { | 2501 if (!allowed) { |
| 2491 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2502 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2492 errors::kInvalidURLPatternError, filter); | 2503 errors::kInvalidURLPatternError, filter); |
| 2493 return NULL; | 2504 return NULL; |
| 2494 } | 2505 } |
| 2495 result->AddPattern(pattern); | 2506 result->AddPattern(pattern); |
| 2496 } | 2507 } |
| 2497 } | 2508 } |
| 2498 | 2509 |
| 2499 std::string default_icon; | 2510 std::string default_icon; |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3685 already_disabled(false), | 3696 already_disabled(false), |
| 3686 extension(extension) {} | 3697 extension(extension) {} |
| 3687 | 3698 |
| 3688 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3699 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3689 const Extension* extension, | 3700 const Extension* extension, |
| 3690 const ExtensionPermissionSet* permissions, | 3701 const ExtensionPermissionSet* permissions, |
| 3691 Reason reason) | 3702 Reason reason) |
| 3692 : reason(reason), | 3703 : reason(reason), |
| 3693 extension(extension), | 3704 extension(extension), |
| 3694 permissions(permissions) {} | 3705 permissions(permissions) {} |
| OLD | NEW |