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_TEST_TEST_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
7 | 7 |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // ExtensionFunction: | 91 // ExtensionFunction: |
92 virtual bool RunImpl() OVERRIDE; | 92 virtual bool RunImpl() OVERRIDE; |
93 }; | 93 }; |
94 | 94 |
95 class TestGetConfigFunction : public SyncExtensionFunction { | 95 class TestGetConfigFunction : public SyncExtensionFunction { |
96 public: | 96 public: |
97 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) | 97 DECLARE_EXTENSION_FUNCTION("test.getConfig", UNKNOWN) |
98 | 98 |
99 // Set the dictionary returned by chrome.test.getConfig(). | 99 // Set the dictionary returned by chrome.test.getConfig(). |
100 // Does not take ownership of |value|. | 100 // Does not take ownership of |value|. |
101 static void set_test_config_state(DictionaryValue* value); | 101 static void set_test_config_state(base::DictionaryValue* value); |
102 | 102 |
103 protected: | 103 protected: |
104 // Tests that set configuration state do so by calling | 104 // Tests that set configuration state do so by calling |
105 // set_test_config_state() as part of test set up, and unsetting it | 105 // set_test_config_state() as part of test set up, and unsetting it |
106 // during tear down. This singleton class holds a pointer to that | 106 // during tear down. This singleton class holds a pointer to that |
107 // state, owned by the test code. | 107 // state, owned by the test code. |
108 class TestConfigState { | 108 class TestConfigState { |
109 public: | 109 public: |
110 static TestConfigState* GetInstance(); | 110 static TestConfigState* GetInstance(); |
111 | 111 |
112 void set_config_state(DictionaryValue* config_state) { | 112 void set_config_state(base::DictionaryValue* config_state) { |
113 config_state_ = config_state; | 113 config_state_ = config_state; |
114 } | 114 } |
115 | 115 |
116 const DictionaryValue* config_state() { | 116 const base::DictionaryValue* config_state() { |
117 return config_state_; | 117 return config_state_; |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 friend struct DefaultSingletonTraits<TestConfigState>; | 121 friend struct DefaultSingletonTraits<TestConfigState>; |
122 TestConfigState(); | 122 TestConfigState(); |
123 | 123 |
124 DictionaryValue* config_state_; | 124 base::DictionaryValue* config_state_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(TestConfigState); | 126 DISALLOW_COPY_AND_ASSIGN(TestConfigState); |
127 }; | 127 }; |
128 | 128 |
129 virtual ~TestGetConfigFunction(); | 129 virtual ~TestGetConfigFunction(); |
130 | 130 |
131 // ExtensionFunction: | 131 // ExtensionFunction: |
132 virtual bool RunImpl() OVERRIDE; | 132 virtual bool RunImpl() OVERRIDE; |
133 }; | 133 }; |
134 | 134 |
135 } // namespace extensions | 135 } // namespace extensions |
136 | 136 |
137 #endif // CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ | 137 #endif // CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
OLD | NEW |