| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSION_FUNCTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // Derived classes should implement this method to do their work and return | 118 // Derived classes should implement this method to do their work and return |
| 119 // success/failure. | 119 // success/failure. |
| 120 virtual bool RunImpl() = 0; | 120 virtual bool RunImpl() = 0; |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 virtual ~AsyncExtensionFunction() {} | 123 virtual ~AsyncExtensionFunction() {} |
| 124 | 124 |
| 125 void SendResponse(bool success); | 125 void SendResponse(bool success); |
| 126 | 126 |
| 127 const ListValue* args_as_list() { |
| 128 return static_cast<ListValue*>(args_.get()); |
| 129 } |
| 130 const DictionaryValue* args_as_dictionary() { |
| 131 return static_cast<DictionaryValue*>(args_.get()); |
| 132 } |
| 133 |
| 127 // Note: After Run() returns, dispatcher() can be NULL. Since these getters | 134 // Note: After Run() returns, dispatcher() can be NULL. Since these getters |
| 128 // rely on dispatcher(), make sure it is valid before using them. | 135 // rely on dispatcher(), make sure it is valid before using them. |
| 129 std::string extension_id(); | 136 std::string extension_id(); |
| 130 Profile* profile(); | 137 Profile* profile(); |
| 131 | 138 |
| 132 // The arguments to the API. Only non-null if argument were specified. | 139 // The arguments to the API. Only non-null if argument were specified. |
| 133 Value* args_; | 140 scoped_ptr<Value> args_; |
| 134 | 141 |
| 135 // The result of the API. This should be populated by the derived class before | 142 // The result of the API. This should be populated by the derived class before |
| 136 // SendResponse() is called. | 143 // SendResponse() is called. |
| 137 scoped_ptr<Value> result_; | 144 scoped_ptr<Value> result_; |
| 138 | 145 |
| 139 // Any detailed error from the API. This should be populated by the derived | 146 // Any detailed error from the API. This should be populated by the derived |
| 140 // class before Run() returns. | 147 // class before Run() returns. |
| 141 std::string error_; | 148 std::string error_; |
| 142 | 149 |
| 143 // Any class that gets a malformed message should set this to true before | 150 // Any class that gets a malformed message should set this to true before |
| (...skipping 23 matching lines...) Expand all Loading... |
| 167 } | 174 } |
| 168 | 175 |
| 169 protected: | 176 protected: |
| 170 virtual ~SyncExtensionFunction() {} | 177 virtual ~SyncExtensionFunction() {} |
| 171 | 178 |
| 172 private: | 179 private: |
| 173 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); | 180 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); |
| 174 }; | 181 }; |
| 175 | 182 |
| 176 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
| OLD | NEW |