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

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

Issue 10649003: 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 on HEAD 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 0f13369b7597cab95baabdd99c315bbea8bfe9d0..f683cf486cb901bf07634778243bb552ab897e78 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -37,6 +37,7 @@
#include "chrome/common/extensions/features/simple_feature_provider.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/extensions/manifest.h"
+#include "chrome/common/extensions/permissions/permissions_info.h"
#include "chrome/common/extensions/url_pattern_set.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/url_constants.h"
@@ -281,8 +282,8 @@ Extension::TtsVoice::~TtsVoice() {}
Extension::OAuth2Info::OAuth2Info() {}
Extension::OAuth2Info::~OAuth2Info() {}
-ExtensionOAuth2Scopes Extension::OAuth2Info::GetScopesAsSet() {
- ExtensionOAuth2Scopes result;
+OAuth2Scopes Extension::OAuth2Info::GetScopesAsSet() {
+ OAuth2Scopes result;
std::copy(scopes.begin(), scopes.end(),
std::inserter(result, result.begin()));
return result;
@@ -1306,7 +1307,7 @@ bool Extension::LoadLaunchContainer(string16* error) {
}
bool Extension::LoadSharedFeatures(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
if (!LoadDescription(error) ||
!LoadHomepageURL(error) ||
@@ -1784,7 +1785,7 @@ bool Extension::LoadBackgroundScripts(const std::string& key, string16* error) {
}
bool Extension::LoadBackgroundPage(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
if (is_platform_app()) {
return LoadBackgroundPage(
@@ -1801,7 +1802,7 @@ bool Extension::LoadBackgroundPage(
bool Extension::LoadBackgroundPage(
const std::string& key,
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
base::Value* background_page_value = NULL;
if (!manifest_->Get(key, &background_page_value))
@@ -1823,7 +1824,7 @@ bool Extension::LoadBackgroundPage(
background_url_ = GURL(background_str);
// Make sure "background" permission is set.
- if (!api_permissions.count(ExtensionAPIPermission::kBackground)) {
+ if (!api_permissions.count(APIPermission::kBackground)) {
*error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded);
return false;
}
@@ -1848,7 +1849,7 @@ bool Extension::LoadBackgroundPage(
}
bool Extension::LoadBackgroundPersistent(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
if (is_platform_app()) {
background_page_is_persistent_ = false;
@@ -1873,7 +1874,7 @@ bool Extension::LoadBackgroundPersistent(
}
bool Extension::LoadBackgroundAllowJSAccess(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
Value* allow_js_access = NULL;
if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access))
@@ -2050,7 +2051,7 @@ bool Extension::LoadWebIntentServices(string16* error) {
return true;
}
bool Extension::LoadExtensionFeatures(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
if (manifest_->HasKey(keys::kConvertedFromUserScript))
manifest_->GetBoolean(keys::kConvertedFromUserScript,
@@ -2086,7 +2087,7 @@ bool Extension::LoadDevToolsPage(string16* error) {
}
bool Extension::LoadInputComponents(
- const ExtensionAPIPermissionSet& api_permissions,
+ const APIPermissionSet& api_permissions,
string16* error) {
if (!manifest_->HasKey(keys::kInputComponents))
return true;
@@ -2712,7 +2713,7 @@ bool Extension::LoadContentSecurityPolicy(string16* error) {
}
bool Extension::LoadAppIsolation(
- const ExtensionAPIPermissionSet& api_permissions, string16* error) {
+ const APIPermissionSet& api_permissions, string16* error) {
// Platform apps always get isolated storage.
if (is_platform_app()) {
is_storage_isolated_ = true;
@@ -2721,7 +2722,7 @@ bool Extension::LoadAppIsolation(
// Other apps only get it if it is requested _and_ experimental APIs are
// enabled.
- if (!api_permissions.count(ExtensionAPIPermission::kExperimental) ||
+ if (!api_permissions.count(APIPermission::kExperimental) ||
!is_app()) {
return true;
}
@@ -3063,9 +3064,9 @@ bool Extension::InitFromValue(int flags, string16* error) {
base::AutoLock auto_lock(runtime_data_lock_);
// Initialize permissions with an empty, default permission set.
- runtime_data_.SetActivePermissions(new ExtensionPermissionSet());
- optional_permission_set_ = new ExtensionPermissionSet();
- required_permission_set_ = new ExtensionPermissionSet();
+ runtime_data_.SetActivePermissions(new PermissionSet());
+ optional_permission_set_ = new PermissionSet();
+ required_permission_set_ = new PermissionSet();
creation_flags_ = flags;
@@ -3093,7 +3094,7 @@ bool Extension::InitFromValue(int flags, string16* error) {
if (is_app() && !LoadAppFeatures(error))
return false;
- ExtensionAPIPermissionSet api_permissions;
+ APIPermissionSet api_permissions;
URLPatternSet host_permissions;
if (!ParsePermissions(keys::kPermissions,
error,
@@ -3102,7 +3103,7 @@ bool Extension::InitFromValue(int flags, string16* error) {
return false;
}
- ExtensionAPIPermissionSet optional_api_permissions;
+ APIPermissionSet optional_api_permissions;
URLPatternSet optional_host_permissions;
if (!ParsePermissions(keys::kOptionalPermissions,
error,
@@ -3128,11 +3129,11 @@ bool Extension::InitFromValue(int flags, string16* error) {
return false;
}
- runtime_data_.SetActivePermissions(new ExtensionPermissionSet(
+ runtime_data_.SetActivePermissions(new PermissionSet(
this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet()));
- required_permission_set_ = new ExtensionPermissionSet(
+ required_permission_set_ = new PermissionSet(
this, api_permissions, host_permissions, oauth2_info_.GetScopesAsSet());
- optional_permission_set_ = new ExtensionPermissionSet(
+ optional_permission_set_ = new PermissionSet(
optional_api_permissions, optional_host_permissions, URLPatternSet());
return true;
@@ -3292,7 +3293,7 @@ GURL Extension::GetIconURL(int size,
bool Extension::ParsePermissions(const char* key,
string16* error,
- ExtensionAPIPermissionSet* api_permissions,
+ APIPermissionSet* api_permissions,
URLPatternSet* host_permissions) {
if (manifest_->HasKey(key)) {
ListValue* permissions = NULL;
@@ -3310,17 +3311,17 @@ bool Extension::ParsePermissions(const char* key,
return false;
}
- // NOTE: We need to get the ExtensionAPIPermission before the Feature
+ // NOTE: We need to get the APIPermission before the Feature
// object because the feature system does not know about aliases.
- ExtensionAPIPermission* permission =
- ExtensionPermissionsInfo::GetInstance()->GetByName(permission_str);
+ APIPermission* permission =
+ PermissionsInfo::GetInstance()->GetByName(permission_str);
if (permission) {
extensions::SimpleFeatureProvider* permission_features =
extensions::SimpleFeatureProvider::GetPermissionFeatures();
extensions::Feature* feature =
permission_features->GetFeature(permission->name());
- // The feature should exist since we just got an ExtensionAPIPermission
+ // The feature should exist since we just got an APIPermission
// for it. The two systems should be updated together whenever a
// permission is added.
CHECK(feature);
@@ -3341,7 +3342,7 @@ bool Extension::ParsePermissions(const char* key,
continue;
}
- if (permission->id() == ExtensionAPIPermission::kExperimental) {
+ if (permission->id() == APIPermission::kExperimental) {
if (!CanSpecifyExperimentalPermission()) {
*error = ASCIIToUTF16(errors::kExperimentalFlagRequired);
return false;
@@ -3398,7 +3399,7 @@ bool Extension::CanSilentlyIncreasePermissions() const {
}
bool Extension::CanSpecifyHostPermission(const URLPattern& pattern,
- const ExtensionAPIPermissionSet& permissions) const {
+ const APIPermissionSet& permissions) const {
if (!pattern.match_all_urls() &&
pattern.MatchesScheme(chrome::kChromeUIScheme)) {
// Regular extensions are only allowed access to chrome://favicon.
@@ -3407,7 +3408,7 @@ bool Extension::CanSpecifyHostPermission(const URLPattern& pattern,
// Experimental extensions are also allowed chrome://thumb.
if (pattern.host() == chrome::kChromeUIThumbnailHost) {
- return permissions.find(ExtensionAPIPermission::kExperimental) !=
+ return permissions.find(APIPermission::kExperimental) !=
permissions.end();
}
@@ -3423,7 +3424,7 @@ bool Extension::CanSpecifyHostPermission(const URLPattern& pattern,
}
bool Extension::HasAPIPermission(
- ExtensionAPIPermission::ID permission) const {
+ APIPermission::ID permission) const {
base::AutoLock auto_lock(runtime_data_lock_);
return runtime_data_.GetActivePermissions()->HasAPIPermission(permission);
}
@@ -3463,10 +3464,10 @@ bool Extension::HasFullPermissions() const {
return runtime_data_.GetActivePermissions()->HasEffectiveFullAccess();
}
-ExtensionPermissionMessages Extension::GetPermissionMessages() const {
+PermissionMessages Extension::GetPermissionMessages() const {
base::AutoLock auto_lock(runtime_data_lock_);
if (IsTrustedId(id()))
- return ExtensionPermissionMessages();
+ return PermissionMessages();
else
return runtime_data_.GetActivePermissions()->GetPermissionMessages();
}
@@ -3480,12 +3481,12 @@ std::vector<string16> Extension::GetPermissionMessageStrings() const {
}
void Extension::SetActivePermissions(
- const ExtensionPermissionSet* permissions) const {
+ const PermissionSet* permissions) const {
base::AutoLock auto_lock(runtime_data_lock_);
runtime_data_.SetActivePermissions(permissions);
}
-scoped_refptr<const ExtensionPermissionSet>
+scoped_refptr<const PermissionSet>
Extension::GetActivePermissions() const {
base::AutoLock auto_lock(runtime_data_lock_);
return runtime_data_.GetActivePermissions();
@@ -3799,7 +3800,7 @@ bool Extension::CheckPlatformAppFeatures(std::string* utf8_error) {
bool Extension::CheckConflictingFeatures(std::string* utf8_error) {
if (has_lazy_background_page() &&
- HasAPIPermission(ExtensionAPIPermission::kWebRequest)) {
+ HasAPIPermission(APIPermission::kWebRequest)) {
*utf8_error = errors::kWebRequestConflictsWithLazyBackground;
return false;
}
@@ -3810,17 +3811,17 @@ bool Extension::CheckConflictingFeatures(std::string* utf8_error) {
ExtensionInfo::~ExtensionInfo() {}
Extension::RuntimeData::RuntimeData() {}
-Extension::RuntimeData::RuntimeData(const ExtensionPermissionSet* active)
+Extension::RuntimeData::RuntimeData(const PermissionSet* active)
: active_permissions_(active) {}
Extension::RuntimeData::~RuntimeData() {}
-scoped_refptr<const ExtensionPermissionSet>
+scoped_refptr<const PermissionSet>
Extension::RuntimeData::GetActivePermissions() const {
return active_permissions_;
}
void Extension::RuntimeData::SetActivePermissions(
- const ExtensionPermissionSet* active) {
+ const PermissionSet* active) {
active_permissions_ = active;
}
@@ -3854,7 +3855,7 @@ UnloadedExtensionInfo::UnloadedExtensionInfo(
UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
const Extension* extension,
- const ExtensionPermissionSet* permissions,
+ const PermissionSet* permissions,
Reason reason)
: reason(reason),
extension(extension),
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698