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

Unified Diff: chrome/browser/extensions/api/permissions/permissions_api.cc

Issue 10675007: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again Created 8 years, 6 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/browser/extensions/api/permissions/permissions_api.cc
diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc
index bd87039d65275560eb0d05b26377c0054d8fc85b..0e8ccb28d43fb91df6f3c62ade3f8b49adb4190a 100644
--- a/chrome/browser/extensions/api/permissions/permissions_api.cc
+++ b/chrome/browser/extensions/api/permissions/permissions_api.cc
@@ -13,10 +13,15 @@
#include "chrome/common/extensions/api/permissions.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_error_utils.h"
+#include "chrome/common/extensions/permissions/permissions_info.h"
#include "chrome/common/extensions/url_pattern_set.h"
#include "googleurl/src/gurl.h"
using extensions::api::permissions::Permissions;
+using extensions::APIPermission;
+using extensions::APIPermissionSet;
+using extensions::PermissionSet;
+using extensions::PermissionsInfo;
using extensions::PermissionsUpdater;
namespace Contains = extensions::api::permissions::Contains;
@@ -49,7 +54,7 @@ bool ignore_user_gesture_for_tests = false;
bool ContainsPermissionsFunction::RunImpl() {
scoped_ptr<Contains::Params> params(Contains::Params::Create(*args_));
- scoped_refptr<ExtensionPermissionSet> permissions =
+ scoped_refptr<PermissionSet> permissions =
helpers::UnpackPermissionSet(params->permissions, &error_);
if (!permissions.get())
return false;
@@ -70,19 +75,19 @@ bool RemovePermissionsFunction::RunImpl() {
scoped_ptr<Remove::Params> params(Remove::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- scoped_refptr<ExtensionPermissionSet> permissions =
+ scoped_refptr<PermissionSet> permissions =
helpers::UnpackPermissionSet(params->permissions, &error_);
if (!permissions.get())
return false;
const extensions::Extension* extension = GetExtension();
- ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
+ PermissionsInfo* info = PermissionsInfo::GetInstance();
// Make sure they're only trying to remove permissions supported by this API.
- ExtensionAPIPermissionSet apis = permissions->apis();
- for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
+ APIPermissionSet apis = permissions->apis();
+ for (APIPermissionSet::const_iterator i = apis.begin();
i != apis.end(); ++i) {
- const ExtensionAPIPermission* api = info->GetByID(*i);
+ const APIPermission* api = info->GetByID(*i);
if (!api->supports_optional()) {
error_ = ExtensionErrorUtils::FormatErrorMessage(
kNotWhitelistedError, api->name());
@@ -91,9 +96,9 @@ bool RemovePermissionsFunction::RunImpl() {
}
// Make sure we don't remove any required pemissions.
- const ExtensionPermissionSet* required = extension->required_permission_set();
- scoped_refptr<ExtensionPermissionSet> intersection(
- ExtensionPermissionSet::CreateIntersection(permissions.get(), required));
+ const PermissionSet* required = extension->required_permission_set();
+ scoped_refptr<PermissionSet> intersection(
+ PermissionSet::CreateIntersection(permissions.get(), required));
if (!intersection->IsEmpty()) {
error_ = kCantRemoveRequiredPermissionsError;
result_.reset(Remove::Result::Create(false));
@@ -151,14 +156,14 @@ bool RequestPermissionsFunction::RunImpl() {
if (!requested_permissions_.get())
return false;
- ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance();
+ PermissionsInfo* info = PermissionsInfo::GetInstance();
ExtensionPrefs* prefs = profile()->GetExtensionService()->extension_prefs();
// Make sure they're only requesting permissions supported by this API.
- ExtensionAPIPermissionSet apis = requested_permissions_->apis();
- for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
+ APIPermissionSet apis = requested_permissions_->apis();
+ for (APIPermissionSet::const_iterator i = apis.begin();
i != apis.end(); ++i) {
- const ExtensionAPIPermission* api = info->GetByID(*i);
+ const APIPermission* api = info->GetByID(*i);
if (!api->supports_optional()) {
error_ = ExtensionErrorUtils::FormatErrorMessage(
kNotWhitelistedError, api->name());
@@ -176,7 +181,7 @@ bool RequestPermissionsFunction::RunImpl() {
// We don't need to prompt the user if the requested permissions are a subset
// of the granted permissions set.
- scoped_refptr<const ExtensionPermissionSet> granted =
+ scoped_refptr<const PermissionSet> granted =
prefs->GetGrantedPermissions(GetExtension()->id());
if (granted.get() && granted->Contains(*requested_permissions_)) {
PermissionsUpdater perms_updater(profile());
@@ -187,7 +192,7 @@ bool RequestPermissionsFunction::RunImpl() {
}
// Filter out the granted permissions so we only prompt for new ones.
- requested_permissions_ = ExtensionPermissionSet::CreateDifference(
+ requested_permissions_ = PermissionSet::CreateDifference(
requested_permissions_.get(), granted.get());
AddRef(); // Balanced in InstallUIProceed() / InstallUIAbort().

Powered by Google App Engine
This is Rietveld 408576698