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

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

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: . Created 3 years, 12 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
« no previous file with comments | « extensions/renderer/api_request_handler.cc ('k') | extensions/renderer/module_system.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_MODULE_SYSTEM_H_ 5 #ifndef EXTENSIONS_RENDERER_MODULE_SYSTEM_H_
6 #define EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ 6 #define EXTENSIONS_RENDERER_MODULE_SYSTEM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void SetNativeLazyField(v8::Local<v8::Object> object, 146 void SetNativeLazyField(v8::Local<v8::Object> object,
147 const std::string& field, 147 const std::string& field,
148 const std::string& module_name, 148 const std::string& module_name,
149 const std::string& module_field); 149 const std::string& module_field);
150 150
151 // Passes exceptions to |handler| rather than console::Fatal. 151 // Passes exceptions to |handler| rather than console::Fatal.
152 void SetExceptionHandlerForTest(std::unique_ptr<ExceptionHandler> handler) { 152 void SetExceptionHandlerForTest(std::unique_ptr<ExceptionHandler> handler) {
153 exception_handler_ = std::move(handler); 153 exception_handler_ = std::move(handler);
154 } 154 }
155 155
156 // Called when a native binding is created in order to run any custom binding
157 // code to set up various hooks.
158 // TODO(devlin): We can get rid of this once we convert all our custom
159 // bindings.
160 void OnNativeBindingCreated(const std::string& api_name,
161 v8::Local<v8::Value> api_bridge_value);
162
156 protected: 163 protected:
157 friend class ModuleSystemTestEnvironment; 164 friend class ModuleSystemTestEnvironment;
158 friend class ScriptContext; 165 friend class ScriptContext;
159 void Invalidate() override; 166 void Invalidate() override;
160 167
161 private: 168 private:
162 typedef std::map<std::string, std::unique_ptr<NativeHandler>> 169 typedef std::map<std::string, std::unique_ptr<NativeHandler>>
163 NativeHandlerMap; 170 NativeHandlerMap;
164 171
165 // Retrieves the lazily defined field specified by |property|. 172 // Retrieves the lazily defined field specified by |property|.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void RequireAsync(const v8::FunctionCallbackInfo<v8::Value>& args); 209 void RequireAsync(const v8::FunctionCallbackInfo<v8::Value>& args);
203 210
204 // Wraps |source| in a (function(define, require, requireNative, ...) {...}). 211 // Wraps |source| in a (function(define, require, requireNative, ...) {...}).
205 v8::Local<v8::String> WrapSource(v8::Local<v8::String> source); 212 v8::Local<v8::String> WrapSource(v8::Local<v8::String> source);
206 213
207 // NativeHandler implementation which returns the private area of an Object. 214 // NativeHandler implementation which returns the private area of an Object.
208 void Private(const v8::FunctionCallbackInfo<v8::Value>& args); 215 void Private(const v8::FunctionCallbackInfo<v8::Value>& args);
209 216
210 // Loads and runs a Javascript module. 217 // Loads and runs a Javascript module.
211 v8::Local<v8::Value> LoadModule(const std::string& module_name); 218 v8::Local<v8::Value> LoadModule(const std::string& module_name);
219 v8::Local<v8::Value> LoadModuleWithNativeAPIBridge(
220 const std::string& module_name,
221 v8::Local<v8::Value> api_object);
212 222
213 // Invoked when a module is loaded in response to a requireAsync call. 223 // Invoked when a module is loaded in response to a requireAsync call.
214 // Resolves |resolver| with |value|. 224 // Resolves |resolver| with |value|.
215 void OnModuleLoaded( 225 void OnModuleLoaded(
216 std::unique_ptr<v8::Global<v8::Promise::Resolver>> resolver, 226 std::unique_ptr<v8::Global<v8::Promise::Resolver>> resolver,
217 v8::Local<v8::Value> value); 227 v8::Local<v8::Value> value);
218 228
219 // gin::ModuleRegistryObserver overrides. 229 // gin::ModuleRegistryObserver overrides.
220 void OnDidAddPendingModule( 230 void OnDidAddPendingModule(
221 const std::string& id, 231 const std::string& id,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 std::vector<std::unique_ptr<NativeHandler>> clobbered_native_handlers_; 267 std::vector<std::unique_ptr<NativeHandler>> clobbered_native_handlers_;
258 268
259 base::WeakPtrFactory<ModuleSystem> weak_factory_; 269 base::WeakPtrFactory<ModuleSystem> weak_factory_;
260 270
261 DISALLOW_COPY_AND_ASSIGN(ModuleSystem); 271 DISALLOW_COPY_AND_ASSIGN(ModuleSystem);
262 }; 272 };
263 273
264 } // namespace extensions 274 } // namespace extensions
265 275
266 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_ 276 #endif // EXTENSIONS_RENDERER_MODULE_SYSTEM_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_request_handler.cc ('k') | extensions/renderer/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698