Преглед на файлове

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
 
1044
 
1045
     // Set default desktop sharing method
1045
     // Set default desktop sharing method
1046
     setDesktopSharing(config.desktopSharing);
1046
     setDesktopSharing(config.desktopSharing);
1047
+    // Initialize Chrome extension inline installs
1048
+    if(config.chromeExtensionId)
1049
+    {
1050
+        initInlineInstalls();
1051
+    }
1047
 
1052
 
1048
     // By default we use camera
1053
     // By default we use camera
1049
     getVideoSize = getCameraVideoSize;
1054
     getVideoSize = getCameraVideoSize;

+ 20
- 2
desktopsharing.js Целия файл

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
  * Toggles screen sharing.
97
  * Toggles screen sharing.
79
  */
98
  */
168
                 doGetStreamFromExtension(streamCallback, failCallback);
187
                 doGetStreamFromExtension(streamCallback, failCallback);
169
             } else {
188
             } else {
170
                 chrome.webstore.install(
189
                 chrome.webstore.install(
171
-                    "https://chrome.google.com/webstore/detail/" + config.chromeExtensionId,
190
+                    getWebStoreInstallUrl(),
172
                     function(arg) {
191
                     function(arg) {
173
                         console.log("Extension installed successfully", arg);
192
                         console.log("Extension installed successfully", arg);
174
                         // We need to reload the page in order to get the access to chrome.runtime
193
                         // We need to reload the page in order to get the access to chrome.runtime
188
     if(!chrome.runtime) {
207
     if(!chrome.runtime) {
189
         // No API, so no extension for sure
208
         // No API, so no extension for sure
190
         isInstalledCallback(false);
209
         isInstalledCallback(false);
191
-        return false;
192
     }
210
     }
193
     chrome.runtime.sendMessage(
211
     chrome.runtime.sendMessage(
194
         config.chromeExtensionId,
212
         config.chromeExtensionId,

+ 1
- 1
index.html Целия файл

31
     <link rel="stylesheet" href="css/modaldialog.css?v=3">
31
     <link rel="stylesheet" href="css/modaldialog.css?v=3">
32
     <!--
32
     <!--
33
         Link used for inline installation of chrome desktop streaming extension,
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
     <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/diibjkoicjeejcmhdnailmkgecihlobk">
35
     <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/diibjkoicjeejcmhdnailmkgecihlobk">
36
     <script src="libs/jquery-impromptu.js"></script>
36
     <script src="libs/jquery-impromptu.js"></script>
37
     <script src="libs/jquery.autosize.js"></script>
37
     <script src="libs/jquery.autosize.js"></script>

Loading…
Отказ
Запис