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_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "content/public/renderer/render_process_observer.h" | 15 #include "content/public/renderer/render_process_observer.h" |
16 #include "chrome/common/extensions/extension_set.h" | 16 #include "chrome/common/extensions/extension_set.h" |
17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" | 17 #include "chrome/renderer/extensions/chrome_v8_context_set.h" |
18 #include "v8/include/v8.h" | 18 #include "v8/include/v8.h" |
19 | 19 |
| 20 class ChromeV8Extension; |
20 class GURL; | 21 class GURL; |
21 class URLPattern; | 22 class URLPattern; |
22 class UserScriptSlave; | 23 class UserScriptSlave; |
23 struct ExtensionMsg_Loaded_Params; | 24 struct ExtensionMsg_Loaded_Params; |
24 | 25 |
25 namespace WebKit { | 26 namespace WebKit { |
26 class WebFrame; | 27 class WebFrame; |
27 } | 28 } |
28 | 29 |
29 namespace base { | 30 namespace base { |
(...skipping 29 matching lines...) Expand all Loading... |
59 // TODO(koz): Remove once WebKit no longer calls this. | 60 // TODO(koz): Remove once WebKit no longer calls this. |
60 bool AllowScriptExtension(WebKit::WebFrame* frame, | 61 bool AllowScriptExtension(WebKit::WebFrame* frame, |
61 const std::string& v8_extension_name, | 62 const std::string& v8_extension_name, |
62 int extension_group); | 63 int extension_group); |
63 | 64 |
64 bool AllowScriptExtension(WebKit::WebFrame* frame, | 65 bool AllowScriptExtension(WebKit::WebFrame* frame, |
65 const std::string& v8_extension_name, | 66 const std::string& v8_extension_name, |
66 int extension_group, | 67 int extension_group, |
67 int world_id); | 68 int world_id); |
68 | 69 |
| 70 bool AllowAPI(WebKit::WebFrame* frame, |
| 71 const std::string& v8_extension_name, |
| 72 int extension_group, |
| 73 int world_id); |
| 74 |
69 void DidCreateScriptContext(WebKit::WebFrame* frame, | 75 void DidCreateScriptContext(WebKit::WebFrame* frame, |
70 v8::Handle<v8::Context> context, | 76 v8::Handle<v8::Context> context, |
| 77 int extension_group, |
71 int world_id); | 78 int world_id); |
72 void WillReleaseScriptContext(WebKit::WebFrame* frame, | 79 void WillReleaseScriptContext(WebKit::WebFrame* frame, |
73 v8::Handle<v8::Context> context, | 80 v8::Handle<v8::Context> context, |
74 int world_id); | 81 int world_id); |
75 | 82 |
76 void SetTestExtensionId(const std::string& extension_id); | 83 void SetTestExtensionId(const std::string& extension_id); |
77 | 84 |
78 // TODO(mpcomplete): remove. http://crbug.com/100411 | 85 // TODO(mpcomplete): remove. http://crbug.com/100411 |
79 bool IsAdblockWithWebRequestInstalled() const { | 86 bool IsAdblockWithWebRequestInstalled() const { |
80 return webrequest_adblock_; | 87 return webrequest_adblock_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 | 137 // Calls RenderThread's RegisterExtension and keeps tracks of which v8 |
131 // extension is for Chrome Extensions only. | 138 // extension is for Chrome Extensions only. |
132 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); | 139 void RegisterExtension(v8::Extension* extension, bool restrict_to_extensions); |
133 | 140 |
134 // Sets up the host permissions for |extension|. | 141 // Sets up the host permissions for |extension|. |
135 void InitOriginPermissions(const Extension* extension); | 142 void InitOriginPermissions(const Extension* extension); |
136 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, | 143 void UpdateOriginPermissions(UpdatedExtensionPermissionsInfo::Reason reason, |
137 const Extension* extension, | 144 const Extension* extension, |
138 const URLPatternSet& origins); | 145 const URLPatternSet& origins); |
139 | 146 |
| 147 // Set up the extension API bindings in |context|. |
| 148 void SetupAPIBindings(ChromeV8Context* context, |
| 149 WebKit::WebFrame* frame, |
| 150 int extension_group, |
| 151 int world_id); |
| 152 |
140 // Finds the extension ID for the current context. This is determined from | 153 // Finds the extension ID for the current context. This is determined from |
141 // |world_id| if it's non-zero, or the URL in |frame| if it is. | 154 // |world_id| if it's non-zero, or the URL in |frame| if it is. |
142 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); | 155 std::string GetExtensionID(WebKit::WebFrame* frame, int world_id); |
143 | 156 |
| 157 void RegisterExtensions(ChromeV8Context* context); |
| 158 v8::Handle<v8::Object> BuildBrowserObject(ChromeV8Context* context); |
| 159 |
144 // True if this renderer is running extensions. | 160 // True if this renderer is running extensions. |
145 bool is_extension_process_; | 161 bool is_extension_process_; |
146 | 162 |
147 // Contains all loaded extensions. This is essentially the renderer | 163 // Contains all loaded extensions. This is essentially the renderer |
148 // counterpart to ExtensionService in the browser. It contains information | 164 // counterpart to ExtensionService in the browser. It contains information |
149 // about all extensions currently loaded by the browser. | 165 // about all extensions currently loaded by the browser. |
150 ExtensionSet extensions_; | 166 ExtensionSet extensions_; |
151 | 167 |
152 // All the bindings contexts that are currently loaded for this renderer. | 168 // All the bindings contexts that are currently loaded for this renderer. |
153 // There is zero or one for each v8 context. | 169 // There is zero or one for each v8 context. |
(...skipping 25 matching lines...) Expand all Loading... |
179 // Status of webrequest usage for known extensions. | 195 // Status of webrequest usage for known extensions. |
180 // TODO(mpcomplete): remove. http://crbug.com/100411 | 196 // TODO(mpcomplete): remove. http://crbug.com/100411 |
181 bool webrequest_adblock_; | 197 bool webrequest_adblock_; |
182 bool webrequest_adblock_plus_; | 198 bool webrequest_adblock_plus_; |
183 bool webrequest_other_; | 199 bool webrequest_other_; |
184 | 200 |
185 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); | 201 DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); |
186 }; | 202 }; |
187 | 203 |
188 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ | 204 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_DISPATCHER_H_ |
OLD | NEW |