diff options
| author | Yuri Konotopov <ykonotopov@gnome.org> | 2016-11-19 08:12:33 (GMT) |
|---|---|---|
| committer | Yuri Konotopov <ykonotopov@gnome.org> | 2016-11-19 08:12:33 (GMT) |
| commit | 9d6f222d2638088b7df60a2b6dabae8358633177 (patch) | |
| tree | d616e52cf112b2846f27e59584f9896b8b10c4fd | |
| parent | d501ceb87712a63f1f5e972a63ceb4b9763d27d5 (diff) | |
| download | extensions-web-9d6f222d2638088b7df60a2b6dabae8358633177.zip extensions-web-9d6f222d2638088b7df60a2b6dabae8358633177.tar.xz | |
dbus.js: added support for chrome-gnome-shell.
That will allow to drop most of hacks in chrome-gnome-shell
| -rw-r--r-- | sweettooth/static/js/dbus.js | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/sweettooth/static/js/dbus.js b/sweettooth/static/js/dbus.js index 9d1234c..4711e2f 100644 --- a/sweettooth/static/js/dbus.js +++ b/sweettooth/static/js/dbus.js @@ -13,9 +13,34 @@ define(['jquery'], function($) { var exports = {}; var load = exports.load = function(name, req, onLoad, config) { + function processLoad() + { + if (name == "API") { + onLoad(window.SweetTooth); + return; + } + + var apiVersion = undefined; + + try { + if (window.SweetTooth) { + apiVersion = window.SweetTooth.apiVersion; + } + } catch (e) { } + + if (!apiVersion) + apiVersion = 'dummy'; + + var scriptname = './versions/' + apiVersion + '/main'; + // requirejs caches response. + req([scriptname], function(module) { + onLoad(module); + }); + } $(document).ready(function() { if (!('SweetTooth' in window)) { + // Try NPAPI plugin try { var MIME_TYPE = 'application/x-gnome-shell-integration'; var $plg = $('<embed>', { type: MIME_TYPE }); @@ -43,29 +68,21 @@ define(['jquery'], function($) { // plugin to NULL window.SweetTooth = null; } - } - if (name == "API") { - onLoad(window.SweetTooth); - return; + processLoad(); + } + else if (typeof(SweetTooth.initialize) === 'function') + { + // Browser extension + // SweetTooth.initialize should be Promise or jQuery.Deferred + SweetTooth.initialize().then(function() { + processLoad(); + }) + } + else + { + processLoad(); } - - var apiVersion = undefined; - - try { - if (window.SweetTooth) { - apiVersion = window.SweetTooth.apiVersion; - } - } catch (e) { } - - if (!apiVersion) - apiVersion = 'dummy'; - - var scriptname = './versions/' + apiVersion + '/main'; - // requirejs caches response. - req([scriptname], function(module) { - onLoad(module); - }); }); }; |
