Chromium Code Reviews| 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 2817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2828 | 2828 |
| 2829 bool Extension::ImplicitlyDelaysNetworkStartup() const { | 2829 bool Extension::ImplicitlyDelaysNetworkStartup() const { |
| 2830 // Network requests should be deferred until any extensions that might want | 2830 // Network requests should be deferred until any extensions that might want |
| 2831 // to observe and modify them are loaded. | 2831 // to observe and modify them are loaded. |
| 2832 return HasAPIPermission(ExtensionAPIPermission::kWebRequestBlocking); | 2832 return HasAPIPermission(ExtensionAPIPermission::kWebRequestBlocking); |
| 2833 } | 2833 } |
| 2834 | 2834 |
| 2835 bool Extension::CanSpecifyAPIPermission( | 2835 bool Extension::CanSpecifyAPIPermission( |
| 2836 const ExtensionAPIPermission* permission, | 2836 const ExtensionAPIPermission* permission, |
| 2837 string16* error) const { | 2837 string16* error) const { |
| 2838 if (permission->is_component_only()) { | 2838 if ((permission->is_component_only() && location_ != COMPONENT) || |
|
Aaron Boodman
2012/02/02 18:17:31
I think this logic should be:
if (permission->is_
| |
| 2839 if (!CanSpecifyComponentOnlyPermission()) { | 2839 (permission->HasWhitelist() && !permission->IsWhitelisted(id_))) { |
| 2840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2841 errors::kPermissionNotAllowed, permission->name()); | 2841 errors::kPermissionNotAllowed, permission->name()); |
| 2842 return false; | 2842 return false; |
| 2843 } | |
| 2844 } | 2843 } |
| 2845 | 2844 |
| 2846 if (permission->id() == ExtensionAPIPermission::kExperimental) { | 2845 if (permission->id() == ExtensionAPIPermission::kExperimental) { |
| 2847 if (!CanSpecifyExperimentalPermission()) { | 2846 if (!CanSpecifyExperimentalPermission()) { |
| 2848 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired); | 2847 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired); |
| 2849 return false; | 2848 return false; |
| 2850 } | 2849 } |
| 2851 } | 2850 } |
| 2852 | 2851 |
| 2853 if (location_ == Extension::COMPONENT) | 2852 if (location_ == Extension::COMPONENT) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2885 if (!is_hosted_app() || creation_flags_ & STRICT_ERROR_CHECKS) { | 2884 if (!is_hosted_app() || creation_flags_ & STRICT_ERROR_CHECKS) { |
| 2886 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2885 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2887 errors::kPermissionNotAllowed, permission->name()); | 2886 errors::kPermissionNotAllowed, permission->name()); |
| 2888 } | 2887 } |
| 2889 return false; | 2888 return false; |
| 2890 } | 2889 } |
| 2891 | 2890 |
| 2892 return true; | 2891 return true; |
| 2893 } | 2892 } |
| 2894 | 2893 |
| 2895 bool Extension::CanSpecifyComponentOnlyPermission() const { | |
| 2896 // Only COMPONENT extensions can use private APIs. | |
| 2897 // TODO(asargent) - We want a more general purpose mechanism for this, | |
| 2898 // and better error messages. (http://crbug.com/54013) | |
| 2899 return location_ == Extension::COMPONENT; | |
| 2900 } | |
| 2901 | |
| 2902 bool Extension::CanSpecifyExperimentalPermission() const { | 2894 bool Extension::CanSpecifyExperimentalPermission() const { |
| 2903 if (location_ == Extension::COMPONENT) | 2895 if (location_ == Extension::COMPONENT) |
| 2904 return true; | 2896 return true; |
| 2905 | 2897 |
| 2906 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2898 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2907 switches::kEnableExperimentalExtensionApis)) { | 2899 switches::kEnableExperimentalExtensionApis)) { |
| 2908 return true; | 2900 return true; |
| 2909 } | 2901 } |
| 2910 | 2902 |
| 2911 // We rely on the webstore to check access to experimental. This way we can | 2903 // We rely on the webstore to check access to experimental. This way we can |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3047 already_disabled(false), | 3039 already_disabled(false), |
| 3048 extension(extension) {} | 3040 extension(extension) {} |
| 3049 | 3041 |
| 3050 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3042 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3051 const Extension* extension, | 3043 const Extension* extension, |
| 3052 const ExtensionPermissionSet* permissions, | 3044 const ExtensionPermissionSet* permissions, |
| 3053 Reason reason) | 3045 Reason reason) |
| 3054 : reason(reason), | 3046 : reason(reason), |
| 3055 extension(extension), | 3047 extension(extension), |
| 3056 permissions(permissions) {} | 3048 permissions(permissions) {} |
| OLD | NEW |