OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | |
12 | |
13 namespace extensions { | |
14 | |
15 class RulesFunction : public ChromeAsyncExtensionFunction { | |
16 public: | |
17 RulesFunction(); | |
18 | |
19 protected: | |
20 virtual ~RulesFunction(); | |
21 | |
22 // ExtensionFunction: | |
23 virtual bool HasPermission() OVERRIDE; | |
24 virtual bool RunAsync() OVERRIDE; | |
25 | |
26 // Concrete implementation of the RulesFunction that is being called | |
27 // on the thread on which the respective RulesRegistry lives. | |
28 // Returns false in case of errors. | |
29 virtual bool RunAsyncOnCorrectThread() = 0; | |
30 | |
31 scoped_refptr<RulesRegistry> rules_registry_; | |
32 }; | |
33 | |
34 class EventsEventAddRulesFunction : public RulesFunction { | |
35 public: | |
36 DECLARE_EXTENSION_FUNCTION("events.addRules", EVENTS_ADDRULES) | |
37 | |
38 protected: | |
39 virtual ~EventsEventAddRulesFunction() {} | |
40 | |
41 // RulesFunction: | |
42 virtual bool RunAsyncOnCorrectThread() OVERRIDE; | |
43 }; | |
44 | |
45 class EventsEventRemoveRulesFunction : public RulesFunction { | |
46 public: | |
47 DECLARE_EXTENSION_FUNCTION("events.removeRules", EVENTS_REMOVERULES) | |
48 | |
49 protected: | |
50 virtual ~EventsEventRemoveRulesFunction() {} | |
51 | |
52 // RulesFunction: | |
53 virtual bool RunAsyncOnCorrectThread() OVERRIDE; | |
54 }; | |
55 | |
56 class EventsEventGetRulesFunction : public RulesFunction { | |
57 public: | |
58 DECLARE_EXTENSION_FUNCTION("events.getRules", EVENTS_GETRULES) | |
59 | |
60 protected: | |
61 virtual ~EventsEventGetRulesFunction() {} | |
62 | |
63 // RulesFunction: | |
64 virtual bool RunAsyncOnCorrectThread() OVERRIDE; | |
65 }; | |
66 | |
67 } // namespace extensions | |
68 | |
69 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_ | |
OLD | NEW |