[extensions-web] If the plugin fails, don't bail out entirely.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] If the plugin fails, don't bail out entirely.
- Date: Tue, 27 Sep 2011 03:38:12 +0000 (UTC)
commit 6799dea86a09e3713fea78763c317345ea967d55
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Sep 26 15:31:22 2011 -0400
If the plugin fails, don't bail out entirely.
sweettooth/static/js/dbus.js | 49 ++++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/sweettooth/static/js/dbus.js b/sweettooth/static/js/dbus.js
index e8cc761..db92d77 100644
--- a/sweettooth/static/js/dbus.js
+++ b/sweettooth/static/js/dbus.js
@@ -7,26 +7,33 @@ define({
load: function(name, req, onLoad, config) {
req(['jquery'], function ($) {
if (!('SweetTooth' in window)) {
- var MIME_TYPE = 'application/x-gnome-shell-integration';
- var $plg = $('<embed>', { type: MIME_TYPE });
+ try {
+ var MIME_TYPE = 'application/x-gnome-shell-integration';
+ var $plg = $('<embed>', { type: MIME_TYPE });
- // Netscape plugins are strange: if you make them invisible with
- // CSS or give them 0 width/height, they won't load. Just smack it
- // off-screen so it isn't visible, but still works.
- $plg.css({ position: 'absolute',
- left: '-1000em',
- top: '-1000em' });
+ // Netscape plugins are strange: if you make them invisible with
+ // CSS or give them 0 width/height, they won't load. Just smack it
+ // off-screen so it isn't visible, but still works.
+ $plg.css({ position: 'absolute',
+ left: '-1000em',
+ top: '-1000em' });
- // TODO: this may not work if the DOM is not ready
- // when this call is made. Depending on browsers
- // you want to support, wither listen to
- // DOMContentLoaded, event, or use $(function(){}), but in
- // those cases, the full body of this load action should
- // be in that call.
- $(document.body).append($plg);
+ // TODO: this may not work if the DOM is not ready
+ // when this call is made. Depending on browsers
+ // you want to support, wither listen to
+ // DOMContentLoaded, event, or use $(function(){}), but in
+ // those cases, the full body of this load action should
+ // be in that call.
+ $(document.body).append($plg);
- // The API is defined on the plugin itself.
- window.SweetTooth = $plg[0];
+ // The API is defined on the plugin itself.
+ window.SweetTooth = $plg[0];
+ } except (e) {
+ // In this case we probably failed the origin checks and
+ // the NPAPI plugin spat out an error. Explicitly set the
+ // plugin to NULL
+ window.SweetTooth = null;
+ }
}
if (name == "API") {
@@ -34,10 +41,12 @@ define({
return;
}
- var apiVersion = window.SweetTooth.apiVersion;
- var scriptname = null;
+ var apiVersion;
+ if (window.SweetTooth)
+ apiVersion = window.SweetTooth.apiVersion;
+
if (apiVersion) {
- scriptname = './versions/' + apiVersion + '/main';
+ var scriptname = './versions/' + apiVersion + '/main';
// requirejs caches response.
req([scriptname], function(module) {
onLoad(module);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]