summaryrefslogtreecommitdiffstats
path: root/extensions/common/manifest_handlers
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-09-24 15:35:49 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-24 22:36:35 +0000
commite2d0fd0ad14bfd0cd82e0093b1488103af532c8e (patch)
treec44c2f971ace4bdfcfcc65df42eb629b74cdc40a /extensions/common/manifest_handlers
parent8723a2c2a90e060006d1b45a6ce58bacf17bb9d8 (diff)
downloadchromium_src-e2d0fd0ad14bfd0cd82e0093b1488103af532c8e.zip
chromium_src-e2d0fd0ad14bfd0cd82e0093b1488103af532c8e.tar.gz
chromium_src-e2d0fd0ad14bfd0cd82e0093b1488103af532c8e.tar.bz2
[Extensions] Un-refcount PermissionSet
PermissionSet represents a set of permissions, and for some reason, it's been refcounted. There's really no reason to have it, and it makes everything more costly and difficult to reason about. Remove the refcounting. Note: This is part 1 of a 2-part series. This removes the ref-counting. In a followup, I'll go through and update many of the places that use const PermissionSet* and convert to const &. BUG=455414 TBR=thestig@chromium.org (misc chrome files with ptr conversion) TBR=nasko@chromium.org (extension messages - not actually changing any IPC messages) Review URL: https://codereview.chromium.org/1349613003 Cr-Commit-Position: refs/heads/master@{#350684}
Diffstat (limited to 'extensions/common/manifest_handlers')
-rw-r--r--extensions/common/manifest_handlers/permissions_parser.cc40
-rw-r--r--extensions/common/manifest_handlers/permissions_parser.h4
2 files changed, 22 insertions, 22 deletions
diff --git a/extensions/common/manifest_handlers/permissions_parser.cc b/extensions/common/manifest_handlers/permissions_parser.cc
index e221ed3..1aa2e60 100644
--- a/extensions/common/manifest_handlers/permissions_parser.cc
+++ b/extensions/common/manifest_handlers/permissions_parser.cc
@@ -32,16 +32,15 @@ namespace keys = manifest_keys;
namespace errors = manifest_errors;
struct ManifestPermissions : public Extension::ManifestData {
- ManifestPermissions(scoped_refptr<const PermissionSet> permissions);
+ ManifestPermissions(scoped_ptr<const PermissionSet> permissions);
~ManifestPermissions() override;
- scoped_refptr<const PermissionSet> permissions;
+ scoped_ptr<const PermissionSet> permissions;
};
ManifestPermissions::ManifestPermissions(
- scoped_refptr<const PermissionSet> permissions)
- : permissions(permissions) {
-}
+ scoped_ptr<const PermissionSet> permissions)
+ : permissions(permissions.Pass()) {}
ManifestPermissions::~ManifestPermissions() {
}
@@ -267,21 +266,21 @@ void PermissionsParser::Finalize(Extension* extension) {
ManifestHandler::AddExtensionInitialRequiredPermissions(
extension, &initial_required_permissions_->manifest_permissions);
- scoped_refptr<const PermissionSet> required_permissions(
+ scoped_ptr<const PermissionSet> required_permissions(
new PermissionSet(initial_required_permissions_->api_permissions,
initial_required_permissions_->manifest_permissions,
initial_required_permissions_->host_permissions,
initial_required_permissions_->scriptable_hosts));
- extension->SetManifestData(keys::kPermissions,
- new ManifestPermissions(required_permissions));
-
- scoped_refptr<const PermissionSet> optional_permissions(
- new PermissionSet(initial_optional_permissions_->api_permissions,
- initial_optional_permissions_->manifest_permissions,
- initial_optional_permissions_->host_permissions,
- URLPatternSet()));
- extension->SetManifestData(keys::kOptionalPermissions,
- new ManifestPermissions(optional_permissions));
+ extension->SetManifestData(
+ keys::kPermissions, new ManifestPermissions(required_permissions.Pass()));
+
+ scoped_ptr<const PermissionSet> optional_permissions(new PermissionSet(
+ initial_optional_permissions_->api_permissions,
+ initial_optional_permissions_->manifest_permissions,
+ initial_optional_permissions_->host_permissions, URLPatternSet()));
+ extension->SetManifestData(
+ keys::kOptionalPermissions,
+ new ManifestPermissions(optional_permissions.Pass()));
}
// static
@@ -319,20 +318,21 @@ void PermissionsParser::SetScriptableHosts(
}
// static
-scoped_refptr<const PermissionSet> PermissionsParser::GetRequiredPermissions(
+const PermissionSet* PermissionsParser::GetRequiredPermissions(
const Extension* extension) {
DCHECK(extension->GetManifestData(keys::kPermissions));
return static_cast<const ManifestPermissions*>(
- extension->GetManifestData(keys::kPermissions))->permissions;
+ extension->GetManifestData(keys::kPermissions))
+ ->permissions.get();
}
// static
-scoped_refptr<const PermissionSet> PermissionsParser::GetOptionalPermissions(
+const PermissionSet* PermissionsParser::GetOptionalPermissions(
const Extension* extension) {
DCHECK(extension->GetManifestData(keys::kOptionalPermissions));
return static_cast<const ManifestPermissions*>(
extension->GetManifestData(keys::kOptionalPermissions))
- ->permissions;
+ ->permissions.get();
}
} // namespace extensions
diff --git a/extensions/common/manifest_handlers/permissions_parser.h b/extensions/common/manifest_handlers/permissions_parser.h
index 81ffe0e..645017d1b 100644
--- a/extensions/common/manifest_handlers/permissions_parser.h
+++ b/extensions/common/manifest_handlers/permissions_parser.h
@@ -45,9 +45,9 @@ class PermissionsParser {
// Return the extension's manifest-specified permissions. In no cases should
// these permissions be used to determine if an action is allowed. Instead,
// use PermissionsData.
- static scoped_refptr<const PermissionSet> GetRequiredPermissions(
+ static const PermissionSet* GetRequiredPermissions(
const Extension* extension);
- static scoped_refptr<const PermissionSet> GetOptionalPermissions(
+ static const PermissionSet* GetOptionalPermissions(
const Extension* extension);
private: