Use extension API features instead of kNonPermissionModulesNames.
This migrates the constants in permission_set.cc to _api_features.json.
This includes a slight behavior change. Some modules with manifest keys, like
browserAction, omnibox, and commands, used to be accessible even without the
manifest key present. After this patch, they will be inaccessible. I don't
think that should be an issue in practice, because the modules wouldn't do
anything if there was no manifest key present.
BUG=234790,265006
Review URL: https://chromiumcodereview.appspot.com/20818004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215161 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 18f6c81f..e846c00e 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -41,6 +41,7 @@
using extensions::api::activity_log_private::BlockedChromeActivityDetail;
using extensions::Extension;
using extensions::ExtensionAPI;
+using extensions::Feature;
using content::RenderViewHost;
namespace {
@@ -473,8 +474,8 @@
// to just the permissions they explicitly request. They should not have access
// to extension APIs like eg chrome.runtime, chrome.windows, etc. that normally
// are available without permission.
-// TODO(asargent/kalman) - get rid of this when the features system can express
-// the "non permission" permissions.
+// TODO(mpcomplete): move this to ExtensionFunction::HasPermission (or remove
+// it altogether).
bool AllowHostedAppAPICall(const Extension& extension,
const GURL& source_url,
const std::string& function_name) {
@@ -484,11 +485,11 @@
if (!extension.web_extent().MatchesURL(source_url))
return false;
- // We just allow the hosted app's explicit permissions, plus chrome.test.
- scoped_refptr<const extensions::PermissionSet> permissions =
- extension.GetActivePermissions();
- return (permissions->HasAccessToFunction(function_name, false) ||
- StartsWithASCII(function_name, "test.", true /*case_sensitive*/));
+ Feature::Availability availability =
+ ExtensionAPI::GetSharedInstance()->IsAvailable(
+ function_name, &extension, Feature::BLESSED_EXTENSION_CONTEXT,
+ source_url);
+ return availability.is_available();
}
} // namespace