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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_
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"
13 namespace extensions
{
15 class RulesFunction
: public ChromeAsyncExtensionFunction
{
20 virtual ~RulesFunction();
23 virtual bool HasPermission() OVERRIDE
;
24 virtual bool RunImpl() OVERRIDE
;
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 RunImplOnCorrectThread() = 0;
31 scoped_refptr
<RulesRegistry
> rules_registry_
;
34 class EventsEventAddRulesFunction
: public RulesFunction
{
36 DECLARE_EXTENSION_FUNCTION("events.addRules", EVENTS_ADDRULES
)
39 virtual ~EventsEventAddRulesFunction() {}
42 virtual bool RunImplOnCorrectThread() OVERRIDE
;
45 class EventsEventRemoveRulesFunction
: public RulesFunction
{
47 DECLARE_EXTENSION_FUNCTION("events.removeRules", EVENTS_REMOVERULES
)
50 virtual ~EventsEventRemoveRulesFunction() {}
53 virtual bool RunImplOnCorrectThread() OVERRIDE
;
56 class EventsEventGetRulesFunction
: public RulesFunction
{
58 DECLARE_EXTENSION_FUNCTION("events.getRules", EVENTS_GETRULES
)
61 virtual ~EventsEventGetRulesFunction() {}
64 virtual bool RunImplOnCorrectThread() OVERRIDE
;
67 } // namespace extensions
69 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H_