Add module-level permissions to extensions.
This first pass is fairly simple. If a permission is not specified in the
manifest, the corresponding module will not be exposed to script. For example,
without specifying the "tabs" permission, chrome.tabs and chrome.windows will
not be available.
BUG=12140
TEST=no
Review URL: http://codereview.chromium.org/164039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22745 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 550fbba10..7969e96 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -58,6 +58,10 @@
// Icon sizes used by the extension system.
static const int kIconSizes[];
+ // Each permission is a module that the extension is permitted to use.
+ static const char* kPermissionNames[];
+ static const size_t kNumPermissions;
+
// An NPAPI plugin included in the extension.
struct PluginInfo {
FilePath path; // Path to the plugin.
@@ -172,7 +176,12 @@
const std::vector<PluginInfo>& plugins() const { return plugins_; }
const GURL& background_url() const { return background_url_; }
const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; }
- const std::vector<URLPattern>& permissions() const { return permissions_; }
+ const std::vector<URLPattern>& host_permissions() const {
+ return host_permissions_;
+ }
+ const std::vector<std::string>& api_permissions() const {
+ return api_permissions_;
+ }
const GURL& update_url() const { return update_url_; }
const std::map<int, std::string>& icons() { return icons_; }
@@ -293,8 +302,11 @@
// Whether the extension is a theme - if it is, certain things are disabled.
bool is_theme_;
+ // The set of module-level APIs this extension can use.
+ std::vector<std::string> api_permissions_;
+
// The sites this extension has permission to talk to (using XHR, etc).
- std::vector<URLPattern> permissions_;
+ std::vector<URLPattern> host_permissions_;
// The paths to the icons the extension contains mapped by their width.
std::map<int, std::string> icons_;