| Index: extensions/renderer/module_system.h | 
| diff --git a/extensions/renderer/module_system.h b/extensions/renderer/module_system.h | 
| index eec25cce5228a510eff77d9b3c6c2ec98497f535..fe564ac03e4d3a71589fe19a33d66da13bc6a225 100644 | 
| --- a/extensions/renderer/module_system.h | 
| +++ b/extensions/renderer/module_system.h | 
| @@ -15,6 +15,7 @@ | 
| #include "base/memory/scoped_ptr.h" | 
| #include "extensions/renderer/native_handler.h" | 
| #include "extensions/renderer/object_backed_native_handler.h" | 
| +#include "gin/modules/module_registry_observer.h" | 
| #include "v8/include/v8.h" | 
|  | 
| namespace extensions { | 
| @@ -37,7 +38,8 @@ class ScriptContext; | 
| // Note that a ModuleSystem must be used only in conjunction with a single | 
| // v8::Context. | 
| // TODO(koz): Rename this to JavaScriptModuleSystem. | 
| -class ModuleSystem : public ObjectBackedNativeHandler { | 
| +class ModuleSystem : public ObjectBackedNativeHandler, | 
| +                     public gin::ModuleRegistryObserver { | 
| public: | 
| class SourceMap { | 
| public: | 
| @@ -158,12 +160,17 @@ class ModuleSystem : public ObjectBackedNativeHandler { | 
| // Called when an exception is thrown but not caught. | 
| void HandleException(const v8::TryCatch& try_catch); | 
|  | 
| -  // Ensure that require_ has been evaluated from require.js. | 
| -  void EnsureRequireLoaded(); | 
| - | 
| void RequireForJs(const v8::FunctionCallbackInfo<v8::Value>& args); | 
| v8::Local<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); | 
|  | 
| +  bool LoadModule(const std::string& module_name); | 
| +  bool LoadNative(const std::string& native_name); | 
| + | 
| +  // gin::ModuleRegistryObserver overrides. | 
| +  virtual void OnDidAddPendingModule( | 
| +      const std::string& id, | 
| +      const std::vector<std::string>& dependencies) OVERRIDE; | 
| + | 
| typedef v8::Handle<v8::Value>(ModuleSystem::*RequireFunction)( | 
| const std::string&); | 
| // Base implementation of a LazyFieldGetter which uses |require_fn| to require | 
| @@ -183,16 +190,14 @@ class ModuleSystem : public ObjectBackedNativeHandler { | 
| v8::Handle<v8::Value> RequireNativeFromString(const std::string& native_name); | 
| void RequireNative(const v8::FunctionCallbackInfo<v8::Value>& args); | 
|  | 
| -  // Wraps |source| in a (function(require, requireNative, exports) {...}). | 
| -  v8::Handle<v8::String> WrapSource(v8::Handle<v8::String> source); | 
| +  // Wraps |source| in a (function(define) {...}). | 
| +  v8::Handle<v8::String> WrapSource(v8::Handle<v8::String> source, | 
| +                                    const std::string& module_name); | 
| +  v8::Handle<v8::String> WrapAmdSource(v8::Handle<v8::String> source); | 
|  | 
| // NativeHandler implementation which returns the private area of an Object. | 
| void Private(const v8::FunctionCallbackInfo<v8::Value>& args); | 
|  | 
| -  // NativeHandler implementation which returns a function wrapper for a | 
| -  // provided function. | 
| -  void CreateFunctionWrapper(const v8::FunctionCallbackInfo<v8::Value>& args); | 
| - | 
| ScriptContext* context_; | 
|  | 
| // A map from module names to the JS source for that module. GetSource() | 
| @@ -212,6 +217,10 @@ class ModuleSystem : public ObjectBackedNativeHandler { | 
|  | 
| std::set<std::string> overridden_native_handlers_; | 
|  | 
| +  std::set<std::string> modules_supporting_amd_; | 
| + | 
| +  std::set<std::string> failed_module_loads_; | 
| + | 
| DISALLOW_COPY_AND_ASSIGN(ModuleSystem); | 
| }; | 
|  | 
|  |