OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <list> | 10 #include <list> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/process.h" | 15 #include "base/process.h" |
16 #include "chrome/browser/extensions/extension_info_map.h" | 16 #include "chrome/browser/extensions/extension_info_map.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "content/browser/browser_thread.h" | 19 #include "content/browser/browser_thread.h" |
20 #include "content/common/notification_observer.h" | 20 #include "content/common/notification_observer.h" |
21 #include "content/common/notification_registrar.h" | 21 #include "content/common/notification_registrar.h" |
22 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
23 | 23 |
24 class Browser; | 24 class Browser; |
25 class ChromeRenderMessageFilter; | 25 class ChromeRenderMessageFilter; |
26 class ExtensionFunction; | 26 class ExtensionFunction; |
27 class ExtensionFunctionDispatcher; | 27 class ExtensionFunctionDispatcher; |
28 class UIThreadExtensionFunction; | 28 class UIThreadExtensionFunction; |
29 class IOThreadExtensionFunction; | 29 class IOThreadExtensionFunction; |
30 class ListValue; | |
31 class QuotaLimitHeuristic; | 30 class QuotaLimitHeuristic; |
32 class RenderViewHost; | 31 class RenderViewHost; |
| 32 |
| 33 namespace base { |
| 34 class ListValue; |
33 class Value; | 35 class Value; |
| 36 } |
34 | 37 |
35 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ | 38 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ |
36 if (!(test)) { \ | 39 if (!(test)) { \ |
37 bad_message_ = true; \ | 40 bad_message_ = true; \ |
38 return false; \ | 41 return false; \ |
39 } \ | 42 } \ |
40 } while (0) | 43 } while (0) |
41 | 44 |
42 #define EXTENSION_FUNCTION_ERROR(error) do { \ | 45 #define EXTENSION_FUNCTION_ERROR(error) do { \ |
43 error_ = error; \ | 46 error_ = error; \ |
(...skipping 30 matching lines...) Expand all Loading... |
74 // Note that once Run() returns, dispatcher() can be NULL, so be sure to | 77 // Note that once Run() returns, dispatcher() can be NULL, so be sure to |
75 // NULL-check. | 78 // NULL-check. |
76 virtual void Run(); | 79 virtual void Run(); |
77 | 80 |
78 // Returns a quota limit heuristic suitable for this function. | 81 // Returns a quota limit heuristic suitable for this function. |
79 // No quota limiting by default. | 82 // No quota limiting by default. |
80 virtual void GetQuotaLimitHeuristics( | 83 virtual void GetQuotaLimitHeuristics( |
81 std::list<QuotaLimitHeuristic*>* heuristics) const {} | 84 std::list<QuotaLimitHeuristic*>* heuristics) const {} |
82 | 85 |
83 // Specifies the raw arguments to the function, as a JSON value. | 86 // Specifies the raw arguments to the function, as a JSON value. |
84 virtual void SetArgs(const ListValue* args); | 87 virtual void SetArgs(const base::ListValue* args); |
85 | 88 |
86 // Retrieves the results of the function as a JSON-encoded string (may | 89 // Retrieves the results of the function as a JSON-encoded string (may |
87 // be empty). | 90 // be empty). |
88 virtual const std::string GetResult(); | 91 virtual const std::string GetResult(); |
89 | 92 |
90 // Retrieves any error string from the function. | 93 // Retrieves any error string from the function. |
91 virtual const std::string GetError(); | 94 virtual const std::string GetError(); |
92 | 95 |
93 // Specifies the name of the function. | 96 // Specifies the name of the function. |
94 void set_name(const std::string& name) { name_ = name; } | 97 void set_name(const std::string& name) { name_ = name; } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // True if this callback should include information from incognito contexts | 172 // True if this callback should include information from incognito contexts |
170 // even if our profile_ is non-incognito. Note that in the case of a "split" | 173 // even if our profile_ is non-incognito. Note that in the case of a "split" |
171 // mode extension, this will always be false, and we will limit access to | 174 // mode extension, this will always be false, and we will limit access to |
172 // data from within the same profile_ (either incognito or not). | 175 // data from within the same profile_ (either incognito or not). |
173 bool include_incognito_; | 176 bool include_incognito_; |
174 | 177 |
175 // True if the call was made in response of user gesture. | 178 // True if the call was made in response of user gesture. |
176 bool user_gesture_; | 179 bool user_gesture_; |
177 | 180 |
178 // The arguments to the API. Only non-null if argument were specified. | 181 // The arguments to the API. Only non-null if argument were specified. |
179 scoped_ptr<ListValue> args_; | 182 scoped_ptr<base::ListValue> args_; |
180 | 183 |
181 // The result of the API. This should be populated by the derived class before | 184 // The result of the API. This should be populated by the derived class before |
182 // SendResponse() is called. | 185 // SendResponse() is called. |
183 scoped_ptr<Value> result_; | 186 scoped_ptr<base::Value> result_; |
184 | 187 |
185 // Any detailed error from the API. This should be populated by the derived | 188 // Any detailed error from the API. This should be populated by the derived |
186 // class before Run() returns. | 189 // class before Run() returns. |
187 std::string error_; | 190 std::string error_; |
188 | 191 |
189 // Any class that gets a malformed message should set this to true before | 192 // Any class that gets a malformed message should set this to true before |
190 // returning. The calling renderer process will be killed. | 193 // returning. The calling renderer process will be killed. |
191 bool bad_message_; | 194 bool bad_message_; |
192 | 195 |
193 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction); | 196 DISALLOW_COPY_AND_ASSIGN(ExtensionFunction); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 public: | 352 public: |
350 SyncIOThreadExtensionFunction(); | 353 SyncIOThreadExtensionFunction(); |
351 | 354 |
352 virtual void Run() OVERRIDE; | 355 virtual void Run() OVERRIDE; |
353 | 356 |
354 protected: | 357 protected: |
355 virtual ~SyncIOThreadExtensionFunction(); | 358 virtual ~SyncIOThreadExtensionFunction(); |
356 }; | 359 }; |
357 | 360 |
358 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 361 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
OLD | NEW |