Commit 9d6f222d authored by Yuri Konotopov's avatar Yuri Konotopov
Browse files

dbus.js: added support for chrome-gnome-shell.

That will allow to drop most of hacks in chrome-gnome-shell
parent d501ceb8
...@@ -13,9 +13,34 @@ define(['jquery'], function($) { ...@@ -13,9 +13,34 @@ define(['jquery'], function($) {
var exports = {}; var exports = {};
var load = exports.load = function(name, req, onLoad, config) { 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() { $(document).ready(function() {
if (!('SweetTooth' in window)) { if (!('SweetTooth' in window)) {
// Try NPAPI plugin
try { try {
var MIME_TYPE = 'application/x-gnome-shell-integration'; var MIME_TYPE = 'application/x-gnome-shell-integration';
var $plg = $('<embed>', { type: MIME_TYPE }); var $plg = $('<embed>', { type: MIME_TYPE });
...@@ -43,29 +68,21 @@ define(['jquery'], function($) { ...@@ -43,29 +68,21 @@ define(['jquery'], function($) {
// plugin to NULL // plugin to NULL
window.SweetTooth = null; window.SweetTooth = null;
} }
}
if (name == "API") { processLoad();
onLoad(window.SweetTooth); }
return; 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);
});
}); });
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment