| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ | 6 #define EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "extensions/browser/extension_function.h" | 10 #include "extensions/browser/extension_function.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 public: | 56 public: |
| 57 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN) | 57 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN) |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 ~TestLogFunction() override; | 60 ~TestLogFunction() override; |
| 61 | 61 |
| 62 // TestExtensionFunction: | 62 // TestExtensionFunction: |
| 63 bool RunSafe() override; | 63 bool RunSafe() override; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class TestSendMessageFunction : public AsyncExtensionFunction { | 66 class TestSendMessageFunction : public UIThreadExtensionFunction { |
| 67 public: | 67 public: |
| 68 TestSendMessageFunction(); |
| 68 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN) | 69 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN) |
| 69 | 70 |
| 70 // Sends a reply back to the calling extension. Many extensions don't need | 71 // Sends a reply back to the calling extension. Many extensions don't need |
| 71 // a reply and will just ignore it. | 72 // a reply and will just ignore it. |
| 72 void Reply(const std::string& message); | 73 void Reply(const std::string& message); |
| 73 | 74 |
| 74 // Sends an error back to the calling extension. | 75 // Sends an error back to the calling extension. |
| 75 void ReplyWithError(const std::string& error); | 76 void ReplyWithError(const std::string& error); |
| 76 | 77 |
| 77 protected: | 78 protected: |
| 78 ~TestSendMessageFunction() override; | 79 ~TestSendMessageFunction() override; |
| 79 | 80 |
| 80 // ExtensionFunction: | 81 // UIExtensionFunction: |
| 81 bool RunAsync() override; | 82 ResponseAction Run() override; |
| 83 |
| 84 // Whether or not the function is currently waiting for a reply. |
| 85 bool waiting_; |
| 86 |
| 87 ResponseValue response_; |
| 82 }; | 88 }; |
| 83 | 89 |
| 84 class TestGetConfigFunction : public TestExtensionFunction { | 90 class TestGetConfigFunction : public TestExtensionFunction { |
| 85 public: | 91 public: |
| 86 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) | 92 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) |
| 87 | 93 |
| 88 // Set the dictionary returned by chrome.test.getConfig(). | 94 // Set the dictionary returned by chrome.test.getConfig(). |
| 89 // Does not take ownership of |value|. | 95 // Does not take ownership of |value|. |
| 90 static void set_test_config_state(base::DictionaryValue* value); | 96 static void set_test_config_state(base::DictionaryValue* value); |
| 91 | 97 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 protected: | 132 protected: |
| 127 ~TestWaitForRoundTripFunction() override; | 133 ~TestWaitForRoundTripFunction() override; |
| 128 | 134 |
| 129 // TestExtensionFunction: | 135 // TestExtensionFunction: |
| 130 bool RunSafe() override; | 136 bool RunSafe() override; |
| 131 }; | 137 }; |
| 132 | 138 |
| 133 } // namespace extensions | 139 } // namespace extensions |
| 134 | 140 |
| 135 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ | 141 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ |
| OLD | NEW |