| 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 #include "chrome/renderer/extensions/module_system.h" | 5 #include "chrome/renderer/extensions/module_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 natives_enabled_(0), | 125 natives_enabled_(0), |
| 126 exception_handler_(new DefaultExceptionHandler(context)) { | 126 exception_handler_(new DefaultExceptionHandler(context)) { |
| 127 RouteFunction("require", | 127 RouteFunction("require", |
| 128 base::Bind(&ModuleSystem::RequireForJs, base::Unretained(this))); | 128 base::Bind(&ModuleSystem::RequireForJs, base::Unretained(this))); |
| 129 RouteFunction("requireNative", | 129 RouteFunction("requireNative", |
| 130 base::Bind(&ModuleSystem::RequireNative, base::Unretained(this))); | 130 base::Bind(&ModuleSystem::RequireNative, base::Unretained(this))); |
| 131 | 131 |
| 132 v8::Handle<v8::Object> global(context->v8_context()->Global()); | 132 v8::Handle<v8::Object> global(context->v8_context()->Global()); |
| 133 global->SetHiddenValue(v8::String::New(kModulesField), v8::Object::New()); | 133 global->SetHiddenValue(v8::String::New(kModulesField), v8::Object::New()); |
| 134 global->SetHiddenValue(v8::String::New(kModuleSystem), | 134 global->SetHiddenValue(v8::String::New(kModuleSystem), |
| 135 v8::External::New(this)); | 135 v8::External::New(context->isolate(), this)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 ModuleSystem::~ModuleSystem() { | 138 ModuleSystem::~ModuleSystem() { |
| 139 Invalidate(); | 139 Invalidate(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ModuleSystem::Invalidate() { | 142 void ModuleSystem::Invalidate() { |
| 143 if (!is_valid()) | 143 if (!is_valid()) |
| 144 return; | 144 return; |
| 145 | 145 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 "(function(require, requireNative, exports, " | 536 "(function(require, requireNative, exports, " |
| 537 "console, " | 537 "console, " |
| 538 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" | 538 "$Array, $Function, $JSON, $Object, $RegExp, $String) {" |
| 539 "'use strict';"); | 539 "'use strict';"); |
| 540 v8::Handle<v8::String> right = v8::String::New("\n})"); | 540 v8::Handle<v8::String> right = v8::String::New("\n})"); |
| 541 return handle_scope.Close( | 541 return handle_scope.Close( |
| 542 v8::String::Concat(left, v8::String::Concat(source, right))); | 542 v8::String::Concat(left, v8::String::Concat(source, right))); |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace extensions | 545 } // namespace extensions |
| OLD | NEW |