Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1358)

Unified Diff: chrome/common/extensions/extension.cc

Issue 9317013: Add a centralized mechanism for whitelisting access to extension permissions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: comments Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 04475081a52ddc8d892092fde25f1caeb48a4a19..84a10c9e1843a89684e5067d74c983ca55e9df16 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -2835,12 +2835,11 @@ bool Extension::ImplicitlyDelaysNetworkStartup() const {
bool Extension::CanSpecifyAPIPermission(
const ExtensionAPIPermission* permission,
string16* error) const {
- if (permission->is_component_only()) {
- if (!CanSpecifyComponentOnlyPermission()) {
- *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
- errors::kPermissionNotAllowed, permission->name());
- return false;
- }
+ if ((permission->is_component_only() && location_ != COMPONENT) ||
Aaron Boodman 2012/02/02 18:17:31 I think this logic should be: if (permission->is_
+ (permission->HasWhitelist() && !permission->IsWhitelisted(id_))) {
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kPermissionNotAllowed, permission->name());
+ return false;
}
if (permission->id() == ExtensionAPIPermission::kExperimental) {
@@ -2892,13 +2891,6 @@ bool Extension::CanSpecifyAPIPermission(
return true;
}
-bool Extension::CanSpecifyComponentOnlyPermission() const {
- // Only COMPONENT extensions can use private APIs.
- // TODO(asargent) - We want a more general purpose mechanism for this,
- // and better error messages. (http://crbug.com/54013)
- return location_ == Extension::COMPONENT;
-}
-
bool Extension::CanSpecifyExperimentalPermission() const {
if (location_ == Extension::COMPONENT)
return true;

Powered by Google App Engine
This is Rietveld 408576698