Index: chrome/renderer/resources/extensions/webstore_custom_bindings.js |
diff --git a/chrome/renderer/resources/extensions/webstore_custom_bindings.js b/chrome/renderer/resources/extensions/webstore_custom_bindings.js |
index 963adaa1da3a04822a7a8bb382c33b64cb4900a3..a9b906243531a70cab565042c43ccafbf3068a68 100644 |
--- a/chrome/renderer/resources/extensions/webstore_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/webstore_custom_bindings.js |
@@ -5,15 +5,32 @@ |
// Custom binding for the webstore API. |
var webstoreNatives = requireNative('webstore'); |
+var Event = require('event_bindings').Event; |
function Installer() { |
this._pendingInstall = null; |
+ this.onInstallStageChanged = |
+ new Event(null, [{name: 'stage', type: 'string'}], {unmanaged: true}); |
+ this.onDownloadProgress = |
+ new Event(null, [{name: 'progress', type: 'number'}], {unmanaged: true}); |
asargent_no_longer_on_chrome
2014/03/03 18:49:08
We'll want to update the documentation for this at
Devlin
2014/03/03 21:15:13
We discussed it, but we thought that would be too
asargent_no_longer_on_chrome
2014/03/03 22:25:33
Ok, sgtm.
|
} |
Installer.prototype.install = function(url, onSuccess, onFailure) { |
if (this._pendingInstall) |
throw 'A Chrome Web Store installation is already pending.'; |
not at google - send to devlin
2014/03/01 01:42:07
throw new Error(...)
same for all the rest.
Devlin
2014/03/03 17:44:59
Done.
asargent_no_longer_on_chrome
2014/03/03 18:49:08
If developers find themselves in a situation where
Devlin
2014/03/03 21:15:13
That's a good idea, but I think it's a separate is
asargent_no_longer_on_chrome
2014/03/03 22:25:33
Maybe just log a bug for follow-up and we can have
Devlin
2014/03/03 22:49:16
Done. crbug.com/348752
|
- var installId = webstoreNatives.Install(url, onSuccess, onFailure); |
+ if (url !== undefined && typeof(url) !== 'string') |
+ throw 'The Chrome Web Store item link URL parameter must be a string.'; |
+ if (onSuccess !== undefined && typeof(onSuccess) !== 'function') |
+ throw 'The success callback parameter must be a function.'; |
+ if (onFailure !== undefined && typeof(onFailure) !== 'function') |
+ throw 'The failure callback parameter must be a function.'; |
+ |
+ var installId = webstoreNatives.Install( |
+ this.onInstallStageChanged.hasListeners(), |
+ this.onDownloadProgress.hasListeners(), |
not at google - send to devlin
2014/03/01 01:42:07
make sure you document that listeners need to be a
Devlin
2014/03/03 17:44:59
Doc'd here in a comment and in the Event descripti
|
+ url, |
+ onSuccess, |
+ onFailure); |
if (installId !== undefined) { |
this._pendingInstall = { |
installId: installId, |
@@ -43,20 +60,32 @@ Installer.prototype.onInstallResponse = function(installId, success, error) { |
} |
}; |
+Installer.prototype.onInstallStageChanged = function(installStage) { |
+ this.onInstallStageChanged.dispatch(installStage); |
+}; |
+ |
+Installer.prototype.onDownloadProgress = function(progress) { |
+ this.onDownloadProgress.dispatch(progress); |
+}; |
+ |
var installer = new Installer(); |
var chromeWebstore = { |
- install: function install(url, onSuccess, onFailure) { |
+ install: function (url, onSuccess, onFailure) { |
installer.install(url, onSuccess, onFailure); |
- } |
+ }, |
+ onInstallStageChanged: installer.onInstallStageChanged, |
+ onDownloadProgress: installer.onDownloadProgress |
}; |
-// Called by webstore_binding.cc. |
-function onInstallResponse(installId, success, error) { |
- installer.onInstallResponse(installId, success, error); |
-} |
- |
-// These must match the names in InstallWebstorebinding in |
+// This must match the name in InstallWebstoreBindings in |
// chrome/renderer/extensions/dispatcher.cc. |
exports.chromeWebstore = chromeWebstore; |
-exports.onInstallResponse = onInstallResponse; |
+ |
+// Called by webstore_binding.cc. |
asargent_no_longer_on_chrome
2014/03/03 18:49:08
nit: I assume you meant webstore_bindings.cc ?
Devlin
2014/03/03 21:15:13
Whoops, done.
|
+exports.onInstallResponse = |
+ Installer.prototype.onInstallResponse.bind(installer); |
+exports.onInstallStageChanged = |
+ Installer.prototype.onInstallStageChanged.bind(installer); |
+exports.onDownloadProgress = |
+ Installer.prototype.onDownloadProgress.bind(installer); |