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