Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2564 if (!permissions->GetString(i, &permission_str)) { | 2564 if (!permissions->GetString(i, &permission_str)) { |
| 2565 *error = ExtensionErrorUtils::FormatErrorMessage( | 2565 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 2566 errors::kInvalidPermission, base::IntToString(i)); | 2566 errors::kInvalidPermission, base::IntToString(i)); |
| 2567 return false; | 2567 return false; |
| 2568 } | 2568 } |
| 2569 | 2569 |
| 2570 ExtensionAPIPermission* permission = | 2570 ExtensionAPIPermission* permission = |
| 2571 ExtensionPermissionsInfo::GetInstance()->GetByName(permission_str); | 2571 ExtensionPermissionsInfo::GetInstance()->GetByName(permission_str); |
| 2572 | 2572 |
| 2573 if (permission != NULL) { | 2573 if (permission != NULL) { |
| 2574 if (!CanSpecifyAPIPermission(permission, error)) | 2574 if (CanSpecifyAPIPermission(permission, error)) |
| 2575 api_permissions->insert(permission->id()); | |
| 2576 if (!error->empty()) | |
|
jstritar
2011/10/31 19:16:19
nit: I think you can make this 'else if', but it d
| |
| 2575 return false; | 2577 return false; |
| 2576 api_permissions->insert(permission->id()); | |
| 2577 continue; | 2578 continue; |
| 2578 } | 2579 } |
| 2579 | 2580 |
| 2580 // Check if it's a host pattern permission. | 2581 // Check if it's a host pattern permission. |
| 2581 URLPattern pattern = URLPattern(CanExecuteScriptEverywhere() ? | 2582 URLPattern pattern = URLPattern(CanExecuteScriptEverywhere() ? |
| 2582 URLPattern::SCHEME_ALL : kValidHostPermissionSchemes); | 2583 URLPattern::SCHEME_ALL : kValidHostPermissionSchemes); |
| 2583 | 2584 |
| 2584 URLPattern::ParseResult parse_result = pattern.Parse(permission_str, | 2585 URLPattern::ParseResult parse_result = pattern.Parse(permission_str, |
| 2585 parse_strictness); | 2586 parse_strictness); |
| 2586 if (parse_result == URLPattern::PARSE_SUCCESS) { | 2587 if (parse_result == URLPattern::PARSE_SUCCESS) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2801 | 2802 |
| 2802 if (permission->id() == ExtensionAPIPermission::kExperimental) { | 2803 if (permission->id() == ExtensionAPIPermission::kExperimental) { |
| 2803 if (!CanSpecifyExperimentalPermission()) { | 2804 if (!CanSpecifyExperimentalPermission()) { |
| 2804 *error = errors::kExperimentalFlagRequired; | 2805 *error = errors::kExperimentalFlagRequired; |
| 2805 return false; | 2806 return false; |
| 2806 } | 2807 } |
| 2807 } | 2808 } |
| 2808 | 2809 |
| 2809 if (is_hosted_app()) { | 2810 if (is_hosted_app()) { |
| 2810 if (!CanSpecifyPermissionForHostedApp(permission)) { | 2811 if (!CanSpecifyPermissionForHostedApp(permission)) { |
| 2811 *error = ExtensionErrorUtils::FormatErrorMessage( | 2812 // Some old versions of Chrome did not return errors here and we ended up |
| 2812 errors::kPermissionNotAllowed, permission->name()); | 2813 // with extensions in the store containing bad data: crbug.com/101993. |
| 2814 // | |
| 2815 // TODO(aa): Consider just being a lot looser when loading and installing | |
| 2816 // extensions. We can be strict when packing and in development mode. Then | |
| 2817 // we won't have to maintain all these tricky backward compat issues: | |
| 2818 // crbug.com/102328. | |
| 2819 if (creation_flags_ & STRICT_ERROR_CHECKS) { | |
| 2820 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 2821 errors::kPermissionNotAllowed, permission->name()); | |
| 2822 } | |
| 2813 return false; | 2823 return false; |
| 2814 } | 2824 } |
| 2815 } | 2825 } |
| 2816 | 2826 |
| 2817 return true; | 2827 return true; |
| 2818 } | 2828 } |
| 2819 | 2829 |
| 2820 bool Extension::CanSpecifyComponentOnlyPermission() const { | 2830 bool Extension::CanSpecifyComponentOnlyPermission() const { |
| 2821 // Only COMPONENT extensions can use private APIs. | 2831 // Only COMPONENT extensions can use private APIs. |
| 2822 // TODO(asargent) - We want a more general purpose mechanism for this, | 2832 // TODO(asargent) - We want a more general purpose mechanism for this, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3003 already_disabled(false), | 3013 already_disabled(false), |
| 3004 extension(extension) {} | 3014 extension(extension) {} |
| 3005 | 3015 |
| 3006 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3016 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3007 const Extension* extension, | 3017 const Extension* extension, |
| 3008 const ExtensionPermissionSet* permissions, | 3018 const ExtensionPermissionSet* permissions, |
| 3009 Reason reason) | 3019 Reason reason) |
| 3010 : reason(reason), | 3020 : reason(reason), |
| 3011 extension(extension), | 3021 extension(extension), |
| 3012 permissions(permissions) {} | 3022 permissions(permissions) {} |
| OLD | NEW |