OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/declarative/declarative_api.h" | 5 #include "chrome/browser/extensions/api/declarative/declarative_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 namespace extensions { | 39 namespace extensions { |
40 | 40 |
41 RulesFunction::RulesFunction() : rules_registry_(NULL) {} | 41 RulesFunction::RulesFunction() : rules_registry_(NULL) {} |
42 | 42 |
43 RulesFunction::~RulesFunction() {} | 43 RulesFunction::~RulesFunction() {} |
44 | 44 |
| 45 bool RulesFunction::HasPermission() { |
| 46 std::string event_name; |
| 47 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
| 48 return extension_->HasAPIPermission(event_name); |
| 49 } |
| 50 |
45 bool RulesFunction::RunImpl() { | 51 bool RulesFunction::RunImpl() { |
46 std::string event_name; | 52 std::string event_name; |
47 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); | 53 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
48 | 54 |
49 RulesRegistryService* rules_registry_service = | 55 RulesRegistryService* rules_registry_service = |
50 ExtensionSystemFactory::GetForProfile(profile())-> | 56 ExtensionSystemFactory::GetForProfile(profile())-> |
51 rules_registry_service(); | 57 rules_registry_service(); |
52 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); | 58 rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); |
53 // Raw access to this function is not available to extensions, therefore | 59 // Raw access to this function is not available to extensions, therefore |
54 // there should never be a request for a nonexisting rules registry. | 60 // there should never be a request for a nonexisting rules registry. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 error_ = rules_registry_->GetAllRules(extension_id(), &rules); | 116 error_ = rules_registry_->GetAllRules(extension_id(), &rules); |
111 } | 117 } |
112 | 118 |
113 if (error_.empty()) | 119 if (error_.empty()) |
114 results_ = GetRules::Results::Create(rules); | 120 results_ = GetRules::Results::Create(rules); |
115 | 121 |
116 return error_.empty(); | 122 return error_.empty(); |
117 } | 123 } |
118 | 124 |
119 } // namespace extensions | 125 } // namespace extensions |
OLD | NEW |