Index: chrome/browser/resources/plugins.js |
diff --git a/chrome/browser/resources/plugins.js b/chrome/browser/resources/plugins.js |
index 19b21195729468df0efb39fc1a3728846e35bae2..9c3dfdcca5518adabf7d515814d8b60cbd3c90f2 100644 |
--- a/chrome/browser/resources/plugins.js |
+++ b/chrome/browser/resources/plugins.js |
@@ -263,14 +263,11 @@ function importModules(moduleNames) { |
}); |
} |
-// NOTE: Need to keep a reference to the stub here such that it is not garbage |
-// collected, which causes the pipe to close and future calls from C++ to JS to |
-// get dropped. |
-var pluginsPageStub = null; |
- |
-var browserProxy = null; |
-// Exposed globally such that the tests can make direct calls on it. |
+// NOTE: Need to keep a global reference to the |pageProxy| such that it is not |
+// garbage collected, which causes the pipe to close and future calls from C++ |
+// to JS to get dropped. This also allows tests to make direct calls on it. |
var pageProxy = null; |
+var browserProxy = null; |
function initializeProxies() { |
return importModules([ |
@@ -290,20 +287,23 @@ function initializeProxies() { |
serviceProvider.connectToService(pluginsMojom.PluginsPageHandler.name), |
pluginsMojom.PluginsPageHandler); |
- // Connect pipe handle to JS code. |
- var pipe = core.createMessagePipe(); |
- pluginsPageStub = connection.bindHandleToStub( |
- pipe.handle0, pluginsMojom.PluginsPage); |
+ /** @constructor */ |
+ var PluginsPageProxy = function() {}; |
- pageProxy = { |
+ PluginsPageProxy.prototype = { |
__proto__: pluginsMojom.PluginsPage.stubClass.prototype, |
+ |
+ /** @override */ |
onPluginsUpdated: function(plugins) { |
returnPluginsData({plugins: plugins}); |
}, |
}; |
+ pageProxy = new PluginsPageProxy(); |
- bindings.StubBindings(pluginsPageStub).delegate = pageProxy; |
- // Send pipe handle to C++. |
+ var pipe = core.createMessagePipe(); |
+ // Connect one end of the pipe to JS. |
+ connection.bindHandleToObj(pipe.handle0, pageProxy); |
yzshen1
2016/05/27 16:24:45
Does it make sense to name it bindHandleToImpl()?
dpapad
2016/05/27 17:55:37
I found a way to simplify even more by completely
yzshen1
2016/05/27 18:32:46
Okay. I am fine with any name that seems appropria
dpapad
2016/05/27 20:36:56
Ended up renaming to PluginsPageImpl per your sugg
|
+ // Send the other end of the pipe to C++. |
browserProxy.setClientPage(pipe.handle1); |
}); |
} |