| 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 virtual ~RulesFunction(); | 19 virtual ~RulesFunction(); |
| 20 virtual bool RunImpl() OVERRIDE; | 20 virtual bool RunImpl() OVERRIDE; |
| 21 | 21 |
| 22 // Concrete implementation of the RulesFunction that is being called | 22 // Concrete implementation of the RulesFunction that is being called |
| 23 // on the thread on which the respective RulesRegistry lives. | 23 // on the thread on which the respective RulesRegistry lives. |
| 24 // Returns false in case of errors. | 24 // Returns false in case of errors. |
| 25 virtual bool RunImplOnCorrectThread() = 0; | 25 virtual bool RunImplOnCorrectThread() = 0; |
| 26 | 26 |
| 27 protected: | 27 protected: |
| 28 scoped_refptr<RulesRegistry> rules_registry_; | 28 scoped_refptr<RulesRegistry> rules_registry_; |
| 29 | |
| 30 private: | |
| 31 void SendResponseOnUIThread(); | |
| 32 }; | 29 }; |
| 33 | 30 |
| 34 class AddRulesFunction : public RulesFunction { | 31 class AddRulesFunction : public RulesFunction { |
| 35 public: | 32 public: |
| 36 virtual bool RunImplOnCorrectThread() OVERRIDE; | 33 virtual bool RunImplOnCorrectThread() OVERRIDE; |
| 37 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.addRules"); | 34 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.addRules"); |
| 38 }; | 35 }; |
| 39 | 36 |
| 40 class RemoveRulesFunction : public RulesFunction { | 37 class RemoveRulesFunction : public RulesFunction { |
| 41 public: | 38 public: |
| 42 virtual bool RunImplOnCorrectThread() OVERRIDE; | 39 virtual bool RunImplOnCorrectThread() OVERRIDE; |
| 43 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.removeRules"); | 40 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.removeRules"); |
| 44 }; | 41 }; |
| 45 | 42 |
| 46 class GetRulesFunction : public RulesFunction { | 43 class GetRulesFunction : public RulesFunction { |
| 47 public: | 44 public: |
| 48 virtual bool RunImplOnCorrectThread() OVERRIDE; | 45 virtual bool RunImplOnCorrectThread() OVERRIDE; |
| 49 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.getRules"); | 46 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.getRules"); |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 } // namespace extensions | 49 } // namespace extensions |
| 53 | 50 |
| 54 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ | 51 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ |
| OLD | NEW |