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

Unified Diff: extensions/browser/extension_prefs.cc

Issue 1349613003: [Extensions] Un-refcount PermissionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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: extensions/browser/extension_prefs.cc
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index c7a5aea5122827c08f6cfa344b3e2970e9893457..51074f92a2f7c5929e8c9be15ee594f85c8526ac 100644
--- a/extensions/browser/extension_prefs.cc
+++ b/extensions/browser/extension_prefs.cc
@@ -556,7 +556,7 @@ bool ExtensionPrefs::ReadPrefAsBooleanAndReturn(
return ReadPrefAsBoolean(extension_id, pref_key, &out_value) && out_value;
}
-scoped_refptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
+scoped_ptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
const std::string& extension_id,
const std::string& pref_key) const {
if (!GetExtensionPref(extension_id))
@@ -597,8 +597,8 @@ scoped_refptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
extension_id, JoinPrefs(pref_key, kPrefScriptableHosts),
&scriptable_hosts, UserScript::ValidUserScriptSchemes());
- return make_scoped_refptr(new PermissionSet(
- apis, manifest_permissions, explicit_hosts, scriptable_hosts));
+ return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
// Set the API or Manifest permissions.
@@ -1014,7 +1014,7 @@ void ExtensionPrefs::MigrateDisableReasons(
}
}
-scoped_refptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
+scoped_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
const std::string& extension_id) const {
CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions);
@@ -1026,14 +1026,14 @@ void ExtensionPrefs::AddGrantedPermissions(
CHECK(crx_file::id_util::IdIsValid(extension_id));
DCHECK(permissions);
- scoped_refptr<const PermissionSet> granted =
- GetGrantedPermissions(extension_id);
- granted = granted.get() ? PermissionSet::CreateUnion(*permissions, *granted)
- : permissions;
+ scoped_ptr<const PermissionSet> granted = GetGrantedPermissions(extension_id);
+ scoped_ptr<const PermissionSet> union_set;
+ if (granted)
+ union_set = PermissionSet::CreateUnion(*permissions, *granted);
// The new granted permissions are the union of the already granted
// permissions and the newly granted permissions.
SetExtensionPrefPermissionSet(extension_id, kPrefGrantedPermissions,
- granted.get());
+ union_set ? union_set.get() : permissions);
}
void ExtensionPrefs::RemoveGrantedPermissions(
@@ -1050,7 +1050,7 @@ void ExtensionPrefs::RemoveGrantedPermissions(
.get());
}
-scoped_refptr<const PermissionSet> ExtensionPrefs::GetActivePermissions(
+scoped_ptr<const PermissionSet> ExtensionPrefs::GetActivePermissions(
const std::string& extension_id) const {
CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions);

Powered by Google App Engine
This is Rietveld 408576698