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/values.h" | 8 #include "base/values.h" |
9 #include "extensions/browser/extension_function.h" | 9 #include "extensions/browser/extension_function.h" |
10 | 10 |
11 template <typename T> | 11 template <typename T> |
12 struct DefaultSingletonTraits; | 12 struct DefaultSingletonTraits; |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 // A function that is only available in tests. | 16 // A function that is only available in tests. |
17 // Prior to running, checks that we are in a testing process. | 17 // Prior to running, checks that we are in a testing process. |
18 class TestExtensionFunction : public SyncExtensionFunction { | 18 class TestExtensionFunction : public SyncExtensionFunction { |
19 protected: | 19 protected: |
20 virtual ~TestExtensionFunction(); | 20 virtual ~TestExtensionFunction(); |
21 | 21 |
22 // SyncExtensionFunction: | 22 // SyncExtensionFunction: |
23 virtual bool RunSync() OVERRIDE; | 23 virtual bool RunSync() override; |
24 | 24 |
25 virtual bool RunSafe() = 0; | 25 virtual bool RunSafe() = 0; |
26 }; | 26 }; |
27 | 27 |
28 class TestNotifyPassFunction : public TestExtensionFunction { | 28 class TestNotifyPassFunction : public TestExtensionFunction { |
29 public: | 29 public: |
30 DECLARE_EXTENSION_FUNCTION("test.notifyPass", UNKNOWN) | 30 DECLARE_EXTENSION_FUNCTION("test.notifyPass", UNKNOWN) |
31 | 31 |
32 protected: | 32 protected: |
33 virtual ~TestNotifyPassFunction(); | 33 virtual ~TestNotifyPassFunction(); |
34 | 34 |
35 // TestExtensionFunction: | 35 // TestExtensionFunction: |
36 virtual bool RunSafe() OVERRIDE; | 36 virtual bool RunSafe() override; |
37 }; | 37 }; |
38 | 38 |
39 class TestNotifyFailFunction : public TestExtensionFunction { | 39 class TestNotifyFailFunction : public TestExtensionFunction { |
40 public: | 40 public: |
41 DECLARE_EXTENSION_FUNCTION("test.notifyFail", UNKNOWN) | 41 DECLARE_EXTENSION_FUNCTION("test.notifyFail", UNKNOWN) |
42 | 42 |
43 protected: | 43 protected: |
44 virtual ~TestNotifyFailFunction(); | 44 virtual ~TestNotifyFailFunction(); |
45 | 45 |
46 // TestExtensionFunction: | 46 // TestExtensionFunction: |
47 virtual bool RunSafe() OVERRIDE; | 47 virtual bool RunSafe() override; |
48 }; | 48 }; |
49 | 49 |
50 class TestLogFunction : public TestExtensionFunction { | 50 class TestLogFunction : public TestExtensionFunction { |
51 public: | 51 public: |
52 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN) | 52 DECLARE_EXTENSION_FUNCTION("test.log", UNKNOWN) |
53 | 53 |
54 protected: | 54 protected: |
55 virtual ~TestLogFunction(); | 55 virtual ~TestLogFunction(); |
56 | 56 |
57 // TestExtensionFunction: | 57 // TestExtensionFunction: |
58 virtual bool RunSafe() OVERRIDE; | 58 virtual bool RunSafe() override; |
59 }; | 59 }; |
60 | 60 |
61 class TestSendMessageFunction : public AsyncExtensionFunction { | 61 class TestSendMessageFunction : public AsyncExtensionFunction { |
62 public: | 62 public: |
63 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN) | 63 DECLARE_EXTENSION_FUNCTION("test.sendMessage", UNKNOWN) |
64 | 64 |
65 // Sends a reply back to the calling extension. Many extensions don't need | 65 // Sends a reply back to the calling extension. Many extensions don't need |
66 // a reply and will just ignore it. | 66 // a reply and will just ignore it. |
67 void Reply(const std::string& message); | 67 void Reply(const std::string& message); |
68 | 68 |
69 // Sends an error back to the calling extension. | 69 // Sends an error back to the calling extension. |
70 void ReplyWithError(const std::string& error); | 70 void ReplyWithError(const std::string& error); |
71 | 71 |
72 protected: | 72 protected: |
73 virtual ~TestSendMessageFunction(); | 73 virtual ~TestSendMessageFunction(); |
74 | 74 |
75 // ExtensionFunction: | 75 // ExtensionFunction: |
76 virtual bool RunAsync() OVERRIDE; | 76 virtual bool RunAsync() override; |
77 }; | 77 }; |
78 | 78 |
79 class TestGetConfigFunction : public TestExtensionFunction { | 79 class TestGetConfigFunction : public TestExtensionFunction { |
80 public: | 80 public: |
81 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) | 81 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) |
82 | 82 |
83 // Set the dictionary returned by chrome.test.getConfig(). | 83 // Set the dictionary returned by chrome.test.getConfig(). |
84 // Does not take ownership of |value|. | 84 // Does not take ownership of |value|. |
85 static void set_test_config_state(base::DictionaryValue* value); | 85 static void set_test_config_state(base::DictionaryValue* value); |
86 | 86 |
(...skipping 17 matching lines...) Expand all Loading... |
104 TestConfigState(); | 104 TestConfigState(); |
105 | 105 |
106 base::DictionaryValue* config_state_; | 106 base::DictionaryValue* config_state_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(TestConfigState); | 108 DISALLOW_COPY_AND_ASSIGN(TestConfigState); |
109 }; | 109 }; |
110 | 110 |
111 virtual ~TestGetConfigFunction(); | 111 virtual ~TestGetConfigFunction(); |
112 | 112 |
113 // TestExtensionFunction: | 113 // TestExtensionFunction: |
114 virtual bool RunSafe() OVERRIDE; | 114 virtual bool RunSafe() override; |
115 }; | 115 }; |
116 | 116 |
117 class TestWaitForRoundTripFunction : public TestExtensionFunction { | 117 class TestWaitForRoundTripFunction : public TestExtensionFunction { |
118 public: | 118 public: |
119 DECLARE_EXTENSION_FUNCTION("test.waitForRoundTrip", UNKNOWN) | 119 DECLARE_EXTENSION_FUNCTION("test.waitForRoundTrip", UNKNOWN) |
120 | 120 |
121 protected: | 121 protected: |
122 virtual ~TestWaitForRoundTripFunction(); | 122 virtual ~TestWaitForRoundTripFunction(); |
123 | 123 |
124 // TestExtensionFunction: | 124 // TestExtensionFunction: |
125 virtual bool RunSafe() OVERRIDE; | 125 virtual bool RunSafe() override; |
126 }; | 126 }; |
127 | 127 |
128 } // namespace extensions | 128 } // namespace extensions |
129 | 129 |
130 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ | 130 #endif // EXTENSIONS_BROWSER_API_TEST_TEST_API_H_ |
OLD | NEW |