Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: extensions/renderer/dispatcher.h

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments -> round 1 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_RENDERER_DISPATCHER_H_ 5 #ifndef EXTENSIONS_RENDERER_DISPATCHER_H_
6 #define EXTENSIONS_RENDERER_DISPATCHER_H_ 6 #define EXTENSIONS_RENDERER_DISPATCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const ScriptContextSet& script_context_set() const { 76 const ScriptContextSet& script_context_set() const {
77 return *script_context_set_; 77 return *script_context_set_;
78 } 78 }
79 79
80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } 80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); }
81 81
82 ContentWatcher* content_watcher() { return content_watcher_.get(); } 82 ContentWatcher* content_watcher() { return content_watcher_.get(); }
83 83
84 RequestSender* request_sender() { return request_sender_.get(); } 84 RequestSender* request_sender() { return request_sender_.get(); }
85 85
86 // Thread safe.
87 static void InstallV8ExtensionForServiceWorkers();
88
86 const std::string& webview_partition_id() { return webview_partition_id_; } 89 const std::string& webview_partition_id() { return webview_partition_id_; }
87 90
88 void OnRenderFrameCreated(content::RenderFrame* render_frame); 91 void OnRenderFrameCreated(content::RenderFrame* render_frame);
89 92
90 bool IsExtensionActive(const std::string& extension_id) const; 93 bool IsExtensionActive(const std::string& extension_id) const;
91 94
92 void DidCreateScriptContext(blink::WebLocalFrame* frame, 95 void DidCreateScriptContext(blink::WebLocalFrame* frame,
93 const v8::Local<v8::Context>& context, 96 const v8::Local<v8::Context>& context,
94 int extension_group, 97 int extension_group,
95 int world_id); 98 int world_id);
96 99
97 // Runs on a different thread and should not use any member variables. 100 // Runs on a different thread and should only use thread safe member
98 static void DidInitializeServiceWorkerContextOnWorkerThread( 101 // variables.
102 void DidInitializeServiceWorkerContextOnWorkerThread(
99 v8::Local<v8::Context> v8_context, 103 v8::Local<v8::Context> v8_context,
104 int embedded_worker_id,
100 const GURL& url); 105 const GURL& url);
101 106
102 void WillReleaseScriptContext(blink::WebLocalFrame* frame, 107 void WillReleaseScriptContext(blink::WebLocalFrame* frame,
103 const v8::Local<v8::Context>& context, 108 const v8::Local<v8::Context>& context,
104 int world_id); 109 int world_id);
105 110
106 // Runs on a different thread and should not use any member variables. 111 // Runs on a different thread and should not use any member variables.
107 static void WillDestroyServiceWorkerContextOnWorkerThread( 112 static void WillDestroyServiceWorkerContextOnWorkerThread(
108 v8::Local<v8::Context> v8_context, 113 v8::Local<v8::Context> v8_context,
114 int embedded_worker_id,
109 const GURL& url); 115 const GURL& url);
110 116
111 // This method is not allowed to run JavaScript code in the frame. 117 // This method is not allowed to run JavaScript code in the frame.
112 void DidCreateDocumentElement(blink::WebLocalFrame* frame); 118 void DidCreateDocumentElement(blink::WebLocalFrame* frame);
113 119
114 // These methods may run (untrusted) JavaScript code in the frame, and 120 // These methods may run (untrusted) JavaScript code in the frame, and
115 // cause |render_frame| to become invalid. 121 // cause |render_frame| to become invalid.
116 void RunScriptsAtDocumentStart(content::RenderFrame* render_frame); 122 void RunScriptsAtDocumentStart(content::RenderFrame* render_frame);
117 void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame); 123 void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame);
118 124
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const std::string& tls_channel_id); 174 const std::string& tls_channel_id);
169 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); 175 void OnDispatchOnDisconnect(int port_id, const std::string& error_message);
170 void OnLoaded( 176 void OnLoaded(
171 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); 177 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions);
172 void OnMessageInvoke(const std::string& extension_id, 178 void OnMessageInvoke(const std::string& extension_id,
173 const std::string& module_name, 179 const std::string& module_name,
174 const std::string& function_name, 180 const std::string& function_name,
175 const base::ListValue& args, 181 const base::ListValue& args,
176 bool user_gesture); 182 bool user_gesture);
177 void OnSetChannel(int channel); 183 void OnSetChannel(int channel);
184 void OnSetExtensionAPIEnabledInExtensionServiceWorkers(bool enabled);
178 void OnSetScriptingWhitelist( 185 void OnSetScriptingWhitelist(
179 const ExtensionsClient::ScriptingWhitelist& extension_ids); 186 const ExtensionsClient::ScriptingWhitelist& extension_ids);
180 void OnSetSystemFont(const std::string& font_family, 187 void OnSetSystemFont(const std::string& font_family,
181 const std::string& font_size); 188 const std::string& font_size);
182 void OnSetWebViewPartitionID(const std::string& partition_id); 189 void OnSetWebViewPartitionID(const std::string& partition_id);
183 void OnShouldSuspend(const std::string& extension_id, uint64_t sequence_id); 190 void OnShouldSuspend(const std::string& extension_id, uint64_t sequence_id);
184 void OnSuspend(const std::string& extension_id); 191 void OnSuspend(const std::string& extension_id);
185 void OnTransferBlobs(const std::vector<std::string>& blob_uuids); 192 void OnTransferBlobs(const std::vector<std::string>& blob_uuids);
186 void OnUnloaded(const std::string& id); 193 void OnUnloaded(const std::string& id);
187 void OnUpdatePermissions(const ExtensionMsg_UpdatePermissions_Params& params); 194 void OnUpdatePermissions(const ExtensionMsg_UpdatePermissions_Params& params);
(...skipping 28 matching lines...) Expand all
216 223
217 // Adds or removes bindings for every context belonging to |extension_id|, or 224 // Adds or removes bindings for every context belonging to |extension_id|, or
218 // or all contexts if |extension_id| is empty. 225 // or all contexts if |extension_id| is empty.
219 void UpdateBindings(const std::string& extension_id); 226 void UpdateBindings(const std::string& extension_id);
220 227
221 void UpdateBindingsForContext(ScriptContext* context); 228 void UpdateBindingsForContext(ScriptContext* context);
222 229
223 void RegisterBinding(const std::string& api_name, ScriptContext* context); 230 void RegisterBinding(const std::string& api_name, ScriptContext* context);
224 231
225 void RegisterNativeHandlers(ModuleSystem* module_system, 232 void RegisterNativeHandlers(ModuleSystem* module_system,
226 ScriptContext* context); 233 ScriptContext* context,
234 RequestSender* request_sender,
235 V8SchemaRegistry* v8_schema_registry);
227 236
228 // Determines if a ScriptContext can connect to any externally_connectable- 237 // Determines if a ScriptContext can connect to any externally_connectable-
229 // enabled extension. 238 // enabled extension.
230 bool IsRuntimeAvailableToContext(ScriptContext* context); 239 bool IsRuntimeAvailableToContext(ScriptContext* context);
231 240
232 // Updates a web page context with any content capabilities granted by active 241 // Updates a web page context with any content capabilities granted by active
233 // extensions. 242 // extensions.
234 void UpdateContentCapabilities(ScriptContext* context); 243 void UpdateContentCapabilities(ScriptContext* context);
235 244
236 // Inserts static source code into |source_map_|. 245 // Inserts static source code into |source_map_|.
237 void PopulateSourceMap(); 246 void PopulateSourceMap();
238 247
239 // Returns whether the current renderer hosts a platform app. 248 // Returns whether the current renderer hosts a platform app.
240 bool IsWithinPlatformApp(); 249 bool IsWithinPlatformApp();
241 250
242 // Gets |field| from |object| or creates it as an empty object if it doesn't 251 // Gets |field| from |object| or creates it as an empty object if it doesn't
243 // exist. 252 // exist.
244 v8::Local<v8::Object> GetOrCreateObject(const v8::Local<v8::Object>& object, 253 static v8::Local<v8::Object> GetOrCreateObject(
245 const std::string& field, 254 const v8::Local<v8::Object>& object,
246 v8::Isolate* isolate); 255 const std::string& field,
256 v8::Isolate* isolate);
247 257
248 v8::Local<v8::Object> GetOrCreateBindObjectIfAvailable( 258 static v8::Local<v8::Object> GetOrCreateBindObjectIfAvailable(
249 const std::string& api_name, 259 const std::string& api_name,
250 std::string* bind_name, 260 std::string* bind_name,
251 ScriptContext* context); 261 ScriptContext* context);
252 262
253 // Requires the GuestView modules in the module system of the ScriptContext 263 // Requires the GuestView modules in the module system of the ScriptContext
254 // |context|. 264 // |context|.
255 void RequireGuestViewModules(ScriptContext* context); 265 void RequireGuestViewModules(ScriptContext* context);
256 266
257 // The delegate for this dispatcher. Not owned, but must extend beyond the 267 // The delegate for this dispatcher. Not owned, but must extend beyond the
258 // Dispatcher's own lifetime. 268 // Dispatcher's own lifetime.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // if this renderer is a WebView guest render process. Otherwise, this will be 319 // if this renderer is a WebView guest render process. Otherwise, this will be
310 // empty. 320 // empty.
311 std::string webview_partition_id_; 321 std::string webview_partition_id_;
312 322
313 DISALLOW_COPY_AND_ASSIGN(Dispatcher); 323 DISALLOW_COPY_AND_ASSIGN(Dispatcher);
314 }; 324 };
315 325
316 } // namespace extensions 326 } // namespace extensions
317 327
318 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ 328 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698