| 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 "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 class RulesRegistry; |
| 13 } |
| 12 | 14 |
| 13 class AddRulesFunction : public SyncExtensionFunction { | 15 namespace extensions { |
| 16 |
| 17 class RulesFunction : public AsyncExtensionFunction { |
| 14 public: | 18 public: |
| 15 virtual bool RunImpl() OVERRIDE; | 19 RulesFunction(); |
| 20 virtual bool RunImpl(); |
| 21 |
| 22 // Concrete implementation of the RulesFunction that is being called |
| 23 // on the thread on which the respective RulesRegistry lives. |
| 24 virtual void RunImplOnCorrectThread() = 0; |
| 25 |
| 26 protected: |
| 27 RulesRegistry* rules_registry_; |
| 28 |
| 29 private: |
| 30 void SendResponseOnUIThread(); |
| 31 }; |
| 32 |
| 33 class AddRulesFunction : public RulesFunction { |
| 34 public: |
| 35 virtual void RunImplOnCorrectThread() OVERRIDE; |
| 16 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.addRules"); | 36 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.addRules"); |
| 17 }; | 37 }; |
| 18 | 38 |
| 19 class RemoveRulesFunction : public SyncExtensionFunction { | 39 class RemoveRulesFunction : public RulesFunction { |
| 20 public: | 40 public: |
| 21 virtual bool RunImpl() OVERRIDE; | 41 virtual void RunImplOnCorrectThread() OVERRIDE; |
| 22 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.removeRules"); | 42 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.removeRules"); |
| 23 }; | 43 }; |
| 24 | 44 |
| 25 class GetRulesFunction : public SyncExtensionFunction { | 45 class GetRulesFunction : public RulesFunction { |
| 26 public: | 46 public: |
| 27 virtual bool RunImpl() OVERRIDE; | 47 virtual void RunImplOnCorrectThread() OVERRIDE; |
| 28 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.getRules"); | 48 DECLARE_EXTENSION_FUNCTION_NAME("experimental.declarative.getRules"); |
| 29 }; | 49 }; |
| 30 | 50 |
| 31 } // namespace extensions | 51 } // namespace extensions |
| 32 | 52 |
| 33 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ | 53 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_DECLARATIVE_API_H__ |
| OLD | NEW |