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()); |