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

Unified Diff: chrome/browser/extensions/api/declarative/declarative_api.cc

Issue 10823247: In the declarative API, check that the extension has permission for the event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove ExtensionSystem debugging Created 8 years, 4 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/browser/extensions/api/declarative/declarative_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/declarative/declarative_api.cc
diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc
index 8c9b856832d02efdb34ffb48d3d9741a618cb0fc..223328a375bccb05a52e08697fe8ff06ae8db910 100644
--- a/chrome/browser/extensions/api/declarative/declarative_api.cc
+++ b/chrome/browser/extensions/api/declarative/declarative_api.cc
@@ -42,14 +42,17 @@ RulesFunction::RulesFunction() : rules_registry_(NULL) {}
RulesFunction::~RulesFunction() {}
+bool RulesFunction::HasPermission() {
+ return Init() && extension_->HasAPIPermission(event_name_);
+}
+
bool RulesFunction::RunImpl() {
- std::string event_name;
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name));
+ EXTENSION_FUNCTION_VALIDATE(Init());
RulesRegistryService* rules_registry_service =
ExtensionSystemFactory::GetForProfile(profile())->
rules_registry_service();
- rules_registry_ = rules_registry_service->GetRulesRegistry(event_name);
+ rules_registry_ = rules_registry_service->GetRulesRegistry(event_name_);
// Raw access to this function is not available to extensions, therefore
// there should never be a request for a nonexisting rules registry.
EXTENSION_FUNCTION_VALIDATE(rules_registry_);
@@ -71,6 +74,12 @@ bool RulesFunction::RunImpl() {
return true;
}
+bool RulesFunction::Init() {
Matt Perry 2012/08/09 01:31:50 optional: I would get rid of the Init() step, and
not at google - send to devlin 2012/08/09 01:41:44 Done.
+ if (!event_name_.empty())
+ return true;
+ return args_->GetString(0, &event_name_);
+}
+
bool AddRulesFunction::RunImplOnCorrectThread() {
scoped_ptr<AddRules::Params> params(AddRules::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
« no previous file with comments | « chrome/browser/extensions/api/declarative/declarative_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698