I'm trying to inline-load a Google Chrome extension using the chrome.webstore.install( link, success, fail)
function.
Here's the link from within my page's <head>
stanza.
<link rel="chrome-webstore-item"
href="https://chrome.google.com/webstore/detail/oafp--redacted--ffencd" />
Here's the button.
<input type="button" class="btn btn-default" onclick="getExtension();">Go</input>
Here's the Javascript, which appears right before the closing </body>
tag.
<script type="text/javascript">
function getExtension() {
function extensionFailed(reason) {
console.log("extension Install Failed:", reason);
}
function extensionInstalled() {
console.log("installed");
};
console.log("calling install");
chrome.webstore.install(undefined, extensionInstalled(), extensionFailed());
console.log("install returned");
};
</script>
Clicking the button that calls getExtension gets me this sequence of events, delivered one after the other immediately.
- "calling install" (right before call to
chrome.webstore.install()
) - "installed" (in success callback)
- "extension Install failed, undefined" (in failure callback)
- "install returned." (after return from call to
chrome.webstore.install()
)
Somewhere in the middle of that, asynchronously, I get the inline installation popup and accept it.
I thought...
- the failure callback should only get called on failure.
- the failure reason should be something meaningful, not
undefined
. - the success callback should be deferred until the user accepts the installation.
I must be doing something wrong. ...