diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2015-09-30 13:19:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-30 20:20:45 +0000 |
commit | d630c304b8d53e1e068d5ef094f14b70507f4844 (patch) | |
tree | e0eb6e1a3cd07b51caedb2f2f014af5bff91c0d2 /extensions/common/permissions | |
parent | 3f38c02b4c4f4d10b7350bf492a05c9215b8b656 (diff) | |
download | chromium_src-d630c304b8d53e1e068d5ef094f14b70507f4844.zip chromium_src-d630c304b8d53e1e068d5ef094f14b70507f4844.tar.gz chromium_src-d630c304b8d53e1e068d5ef094f14b70507f4844.tar.bz2 |
[Extensions] Make const PermissionSet* const PermissionSet& where possible
Replace a bunch of pointers with const&.
TBR=pkotwicz@chromium.org (themes)
TBR=atwilson@chromium.org (background)
TBR=rogerta@chromium.org (ui/sync)
BUG=455414
Review URL: https://codereview.chromium.org/1365443003
Cr-Commit-Position: refs/heads/master@{#351631}
Diffstat (limited to 'extensions/common/permissions')
5 files changed, 27 insertions, 29 deletions
diff --git a/extensions/common/permissions/permission_message_provider.h b/extensions/common/permissions/permission_message_provider.h index 8981f80..a75b46e 100644 --- a/extensions/common/permissions/permission_message_provider.h +++ b/extensions/common/permissions/permission_message_provider.h @@ -38,10 +38,9 @@ class PermissionMessageProvider { // Whether certain permissions are considered varies by extension type. // TODO(sashab): Add an implementation of this method that uses // PermissionIDSet instead, then deprecate this one. - virtual bool IsPrivilegeIncrease( - const PermissionSet* old_permissions, - const PermissionSet* new_permissions, - Manifest::Type extension_type) const = 0; + virtual bool IsPrivilegeIncrease(const PermissionSet& old_permissions, + const PermissionSet& new_permissions, + Manifest::Type extension_type) const = 0; // Given the permissions for an extension, finds the IDs of all the // permissions for that extension (including API, manifest and host @@ -50,7 +49,7 @@ class PermissionMessageProvider { // this type, and make this take as little as is needed to work out the // PermissionIDSet. virtual PermissionIDSet GetAllPermissionIDs( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type) const = 0; }; diff --git a/extensions/common/permissions/permission_message_test_util.cc b/extensions/common/permissions/permission_message_test_util.cc index 2cf3a5d..9b1981e 100644 --- a/extensions/common/permissions/permission_message_test_util.cc +++ b/extensions/common/permissions/permission_message_test_util.cc @@ -17,7 +17,7 @@ namespace extensions { namespace { -PermissionMessages GetMessages(const PermissionSet* permissions, +PermissionMessages GetMessages(const PermissionSet& permissions, Manifest::Type extension_type) { const PermissionMessageProvider* provider = PermissionMessageProvider::Get(); return provider->GetPermissionMessages( @@ -194,7 +194,7 @@ testing::AssertionResult VerifyHasPermissionMessage( } testing::AssertionResult VerifyHasPermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const std::string& expected_message) { return VerifyHasPermissionMessage(permissions, extension_type, @@ -202,7 +202,7 @@ testing::AssertionResult VerifyHasPermissionMessage( } testing::AssertionResult VerifyHasPermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const base::string16& expected_message) { return VerifyHasPermissionMessageImpl( @@ -231,7 +231,7 @@ testing::AssertionResult VerifyOnePermissionMessage( } testing::AssertionResult VerifyOnePermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const base::string16& expected_message) { return VerifyPermissionMessagesWithSubmessagesImpl( diff --git a/extensions/common/permissions/permission_message_test_util.h b/extensions/common/permissions/permission_message_test_util.h index 8cfc3e0..34e36f3 100644 --- a/extensions/common/permissions/permission_message_test_util.h +++ b/extensions/common/permissions/permission_message_test_util.h @@ -24,11 +24,11 @@ testing::AssertionResult VerifyHasPermissionMessage( const PermissionsData* permissions_data, const base::string16& expected_message); testing::AssertionResult VerifyHasPermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const std::string& expected_message); testing::AssertionResult VerifyHasPermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const base::string16& expected_message); @@ -42,7 +42,7 @@ testing::AssertionResult VerifyOnePermissionMessage( const PermissionsData* permissions_data, const base::string16& expected_message); testing::AssertionResult VerifyOnePermissionMessage( - const PermissionSet* permissions, + const PermissionSet& permissions, Manifest::Type extension_type, const base::string16& expected_message); diff --git a/extensions/common/permissions/permissions_data.cc b/extensions/common/permissions/permissions_data.cc index 6757298..7c001a5 100644 --- a/extensions/common/permissions/permissions_data.cc +++ b/extensions/common/permissions/permissions_data.cc @@ -42,13 +42,12 @@ class AutoLockOnValidThread { PermissionsData::PermissionsData(const Extension* extension) : extension_id_(extension->id()), manifest_type_(extension->GetType()) { - const PermissionSet* required_permissions = + const PermissionSet& required_permissions = PermissionsParser::GetRequiredPermissions(extension); - active_permissions_unsafe_.reset( - new PermissionSet(required_permissions->apis(), - required_permissions->manifest_permissions(), - required_permissions->explicit_hosts(), - required_permissions->scriptable_hosts())); + active_permissions_unsafe_.reset(new PermissionSet( + required_permissions.apis(), required_permissions.manifest_permissions(), + required_permissions.explicit_hosts(), + required_permissions.scriptable_hosts())); withheld_permissions_unsafe_.reset(new PermissionSet()); } @@ -75,16 +74,16 @@ bool PermissionsData::CanExecuteScriptEverywhere(const Extension* extension) { // static bool PermissionsData::ScriptsMayRequireActionForExtension( const Extension* extension, - const PermissionSet* permissions) { + const PermissionSet& permissions) { // An extension may require user action to execute scripts iff the extension // shows up in chrome:extensions (so the user can grant withheld permissions), // is not part of chrome or corporate policy, not on the scripting whitelist, // and requires enough permissions that we should withhold them. return extension->ShouldDisplayInExtensionSettings() && - !Manifest::IsPolicyLocation(extension->location()) && - !Manifest::IsComponentLocation(extension->location()) && - !CanExecuteScriptEverywhere(extension) && - permissions->ShouldWarnAllHosts(); + !Manifest::IsPolicyLocation(extension->location()) && + !Manifest::IsComponentLocation(extension->location()) && + !CanExecuteScriptEverywhere(extension) && + permissions.ShouldWarnAllHosts(); } // static @@ -226,7 +225,7 @@ PermissionMessages PermissionsData::GetPermissionMessages() const { base::AutoLock auto_lock(runtime_lock_); return PermissionMessageProvider::Get()->GetPermissionMessages( PermissionMessageProvider::Get()->GetAllPermissionIDs( - active_permissions_unsafe_.get(), manifest_type_)); + *active_permissions_unsafe_, manifest_type_)); } bool PermissionsData::HasWithheldImpliedAllHosts() const { diff --git a/extensions/common/permissions/permissions_data.h b/extensions/common/permissions/permissions_data.h index d7d5f27..19fbe02 100644 --- a/extensions/common/permissions/permissions_data.h +++ b/extensions/common/permissions/permissions_data.h @@ -78,7 +78,7 @@ class PermissionsData { // that are currently on the extension's PermissionsData. static bool ScriptsMayRequireActionForExtension( const Extension* extension, - const PermissionSet* permissions); + const PermissionSet& permissions); // Returns true if we should skip the permissions warning for the extension // with the given |extension_id|. @@ -204,14 +204,14 @@ class PermissionsData { return tab_specific_permissions_; } - const PermissionSet* active_permissions() const { + const PermissionSet& active_permissions() const { DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); - return active_permissions_unsafe_.get(); + return *active_permissions_unsafe_; } - const PermissionSet* withheld_permissions() const { + const PermissionSet& withheld_permissions() const { DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); - return withheld_permissions_unsafe_.get(); + return *withheld_permissions_unsafe_; } #if defined(UNIT_TEST) |