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

Unified Diff: chrome/renderer/resources/require.js

Issue 9657026: Revert 125801 - Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/resources/extensions/webstore.js ('k') | chrome/test/base/chrome_render_view_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/require.js
===================================================================
--- chrome/renderer/resources/require.js (revision 125813)
+++ chrome/renderer/resources/require.js (working copy)
@@ -15,9 +15,15 @@
//
// |bootstrap| contains the following fields:
// - GetSource(module): returns the source code for |module|
+// - Run(source): runs the string os JS |source|
// - GetNative(nativeName): returns the named native object
(function(bootstrap) {
+function wrap(source) {
+ return "(function(require, requireNative, exports) {" + source +
+ "\n})";
+}
+
function ModuleLoader() {
this.cache_ = {};
};
@@ -27,8 +33,9 @@
if (!source) {
return null;
}
+ var wrappedSource = wrap(source);
+ var f = bootstrap.Run(wrappedSource);
var exports = {};
- var f = new Function("require", "requireNative", "exports", source);
f(require, requireNative, exports);
return exports;
};
@@ -46,11 +53,7 @@
var moduleLoader = new ModuleLoader();
function requireNative(nativeName) {
- var result = bootstrap.GetNative(nativeName);
- if (!result) {
- throw "No such native object: '" + nativeName + "'";
- }
- return result;
+ return bootstrap.GetNative(nativeName);
}
function require(moduleId) {
« no previous file with comments | « chrome/renderer/resources/extensions/webstore.js ('k') | chrome/test/base/chrome_render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698