Преглед изворни кода

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

j8
paweldomas пре 11 година
родитељ
комит
83a685bca6
3 измењених фајлова са 26 додато и 3 уклоњено
  1. 5
    0
      app.js
  2. 20
    2
      desktopsharing.js
  3. 1
    1
      index.html

+ 5
- 0
app.js Прегледај датотеку

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

+ 20
- 2
desktopsharing.js Прегледај датотеку

@@ -74,6 +74,25 @@ function showDesktopSharingButton() {
74 74
     }
75 75
 }
76 76
 
77
+/**
78
+ * Initializes <link rel=chrome-webstore-item /> with extension id set in config.js to support inline installs.
79
+ * Host site must be selected as main website of published extension.
80
+ */
81
+function initInlineInstalls()
82
+{
83
+    $("link[rel=chrome-webstore-item]").attr("href", getWebStoreInstallUrl());
84
+}
85
+
86
+/**
87
+ * Constructs inline install URL for Chrome desktop streaming extension.
88
+ * The 'chromeExtensionId' must be defined in config.js.
89
+ * @returns {string}
90
+ */
91
+function getWebStoreInstallUrl()
92
+{
93
+    return "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId;
94
+}
95
+
77 96
 /*
78 97
  * Toggles screen sharing.
79 98
  */
@@ -168,7 +187,7 @@ function obtainScreenFromExtension(streamCallback, failCallback) {
168 187
                 doGetStreamFromExtension(streamCallback, failCallback);
169 188
             } else {
170 189
                 chrome.webstore.install(
171
-                    "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId,
190
+                    getWebStoreInstallUrl(),
172 191
                     function(arg) {
173 192
                         console.log("Extension installed successfully", arg);
174 193
                         // We need to reload the page in order to get the access to chrome.runtime
@@ -188,7 +207,6 @@ function checkExtInstalled(isInstalledCallback) {
188 207
     if(!chrome.runtime) {
189 208
         // No API, so no extension for sure
190 209
         isInstalledCallback(false);
191
-        return false;
192 210
     }
193 211
     chrome.runtime.sendMessage(
194 212
         config.chromeExtensionId,

+ 1
- 1
index.html Прегледај датотеку

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

Loading…
Откажи
Сачувај