Automatically initializes Chrome Web Store inline install URL with extension ID defined in config.js.

This commit is contained in:
paweldomas 2014-04-01 13:19:11 +02:00
parent 0fe46675de
commit 83a685bca6
3 changed files with 26 additions and 3 deletions

5
app.js
View File

@ -1044,6 +1044,11 @@ $(document).ready(function () {
// Set default desktop sharing method
setDesktopSharing(config.desktopSharing);
// Initialize Chrome extension inline installs
if(config.chromeExtensionId)
{
initInlineInstalls();
}
// By default we use camera
getVideoSize = getCameraVideoSize;

View File

@ -74,6 +74,25 @@ function showDesktopSharingButton() {
}
}
/**
* Initializes <link rel=chrome-webstore-item /> with extension id set in config.js to support inline installs.
* Host site must be selected as main website of published extension.
*/
function initInlineInstalls()
{
$("link[rel=chrome-webstore-item]").attr("href", getWebStoreInstallUrl());
}
/**
* Constructs inline install URL for Chrome desktop streaming extension.
* The 'chromeExtensionId' must be defined in config.js.
* @returns {string}
*/
function getWebStoreInstallUrl()
{
return "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId;
}
/*
* Toggles screen sharing.
*/
@ -168,7 +187,7 @@ function obtainScreenFromExtension(streamCallback, failCallback) {
doGetStreamFromExtension(streamCallback, failCallback);
} else {
chrome.webstore.install(
"https://chrome.google.com/webstore/detail/" + config.chromeExtensionId,
getWebStoreInstallUrl(),
function(arg) {
console.log("Extension installed successfully", arg);
// We need to reload the page in order to get the access to chrome.runtime
@ -188,7 +207,6 @@ function checkExtInstalled(isInstalledCallback) {
if(!chrome.runtime) {
// No API, so no extension for sure
isInstalledCallback(false);
return false;
}
chrome.runtime.sendMessage(
config.chromeExtensionId,

View File

@ -31,7 +31,7 @@
<link rel="stylesheet" href="css/modaldialog.css?v=3">
<!--
Link used for inline installation of chrome desktop streaming extension,
must contain the same extension id as defined in config.js -->
is updated automatically from the code with the value defined in config.js -->
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/diibjkoicjeejcmhdnailmkgecihlobk">
<script src="libs/jquery-impromptu.js"></script>
<script src="libs/jquery.autosize.js"></script>