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" | |
18 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
19 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
20 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
21 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
22 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
23 | 22 |
24 class Browser; | 23 class Browser; |
25 class ChromeRenderMessageFilter; | 24 class ChromeRenderMessageFilter; |
26 class ExtensionFunction; | 25 class ExtensionFunction; |
27 class ExtensionFunctionDispatcher; | 26 class ExtensionFunctionDispatcher; |
28 class UIThreadExtensionFunction; | 27 class UIThreadExtensionFunction; |
29 class IOThreadExtensionFunction; | 28 class IOThreadExtensionFunction; |
30 class ListValue; | 29 class ListValue; |
| 30 class Profile; |
31 class QuotaLimitHeuristic; | 31 class QuotaLimitHeuristic; |
32 class RenderViewHost; | 32 class RenderViewHost; |
33 class Value; | 33 class Value; |
34 | 34 |
35 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ | 35 #define EXTENSION_FUNCTION_VALIDATE(test) do { \ |
36 if (!(test)) { \ | 36 if (!(test)) { \ |
37 bad_message_ = true; \ | 37 bad_message_ = true; \ |
38 return false; \ | 38 return false; \ |
39 } \ | 39 } \ |
40 } while (0) | 40 } while (0) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // be empty). | 87 // be empty). |
88 virtual const std::string GetResult(); | 88 virtual const std::string GetResult(); |
89 | 89 |
90 // Retrieves any error string from the function. | 90 // Retrieves any error string from the function. |
91 virtual const std::string GetError(); | 91 virtual const std::string GetError(); |
92 | 92 |
93 // Specifies the name of the function. | 93 // Specifies the name of the function. |
94 void set_name(const std::string& name) { name_ = name; } | 94 void set_name(const std::string& name) { name_ = name; } |
95 const std::string& name() const { return name_; } | 95 const std::string& name() const { return name_; } |
96 | 96 |
97 void set_profile_id(ProfileId profile_id) { profile_id_ = profile_id; } | 97 void set_profile(void* profile) { profile_ = profile_; } |
98 ProfileId profile_id() const { return profile_id_; } | 98 void* profile() const { return profile_; } |
99 | 99 |
100 void set_extension(const Extension* extension) { extension_ = extension; } | 100 void set_extension(const Extension* extension) { extension_ = extension; } |
101 const Extension* GetExtension() const { return extension_.get(); } | 101 const Extension* GetExtension() const { return extension_.get(); } |
102 const std::string& extension_id() const { return extension_->id(); } | 102 const std::string& extension_id() const { return extension_->id(); } |
103 | 103 |
104 void set_request_id(int request_id) { request_id_ = request_id; } | 104 void set_request_id(int request_id) { request_id_ = request_id; } |
105 int request_id() { return request_id_; } | 105 int request_id() { return request_id_; } |
106 | 106 |
107 void set_source_url(const GURL& source_url) { source_url_ = source_url; } | 107 void set_source_url(const GURL& source_url) { source_url_ = source_url; } |
108 const GURL& source_url() { return source_url_; } | 108 const GURL& source_url() { return source_url_; } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // the renderer instead. | 143 // the renderer instead. |
144 void HandleBadMessage(base::ProcessHandle process); | 144 void HandleBadMessage(base::ProcessHandle process); |
145 | 145 |
146 // Return true if the argument to this function at |index| was provided and | 146 // Return true if the argument to this function at |index| was provided and |
147 // is non-null. | 147 // is non-null. |
148 bool HasOptionalArgument(size_t index); | 148 bool HasOptionalArgument(size_t index); |
149 | 149 |
150 // Id of this request, used to map the response back to the caller. | 150 // Id of this request, used to map the response back to the caller. |
151 int request_id_; | 151 int request_id_; |
152 | 152 |
153 // The ID of the Profile of this function's extension. | 153 // The Profile of this function's extension. |
154 ProfileId profile_id_; | 154 void* profile_; |
155 | 155 |
156 // The extension that called this function. | 156 // The extension that called this function. |
157 scoped_refptr<const Extension> extension_; | 157 scoped_refptr<const Extension> extension_; |
158 | 158 |
159 // The name of this function. | 159 // The name of this function. |
160 std::string name_; | 160 std::string name_; |
161 | 161 |
162 // The URL of the frame which is making this request | 162 // The URL of the frame which is making this request |
163 GURL source_url_; | 163 GURL source_url_; |
164 | 164 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 public: | 349 public: |
350 SyncIOThreadExtensionFunction(); | 350 SyncIOThreadExtensionFunction(); |
351 | 351 |
352 virtual void Run() OVERRIDE; | 352 virtual void Run() OVERRIDE; |
353 | 353 |
354 protected: | 354 protected: |
355 virtual ~SyncIOThreadExtensionFunction(); | 355 virtual ~SyncIOThreadExtensionFunction(); |
356 }; | 356 }; |
357 | 357 |
358 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ | 358 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ |
OLD | NEW |