35
35
* ***** END LICENSE BLOCK ***** */
37
37
Components.utils.import("resource://gre/modules/Services.jsm");
38
Components.utils.import("resource://ubufox/uAddonInstaller.jsm");
40
function getAppVersion ()
42
var versionString = null;
44
versionString = Components.classes["@mozilla.org/fuel/application;1"].getService(Components.interfaces.extIApplication).version;
48
if (versionString == null)
51
if (String_startsWith (versionString, "3.0"))
52
versionString = "3.0";
53
else if (String_startsWith (versionString, "3.5"))
54
versionString = "3.5";
55
else // Return null for > 3.6 as firefox is unversioned now
61
function getSourcePackageName ()
63
var sourcePackageName = "firefox";
64
var versionString = getAppVersion();
66
sourcePackageName = sourcePackageName + "-" + versionString;
68
return sourcePackageName;
71
function ubufoxReportBug(event) {
74
Components.classes['@mozilla.org/file/local;1']
75
.createInstance(Components.interfaces.nsILocalFile);
77
executable.initWithPath("/usr/bin/ubuntu-bug");
79
if(!executable.exists () || !executable.isExecutable())
80
alert('Unexpected error!');
83
Components.classes['@mozilla.org/process/util;1']
84
.createInstance(Components.interfaces.nsIProcess);
86
var nsFile = executable.QueryInterface(Components.interfaces.nsIFile);
88
procUtil.init(executable);
91
args = new Array("-p", getSourcePackageName());
93
var res = procUtil.run(false, args, args.length);
97
function ubufoxGetHelpOnline(event)
99
var codename = Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.codename");
100
var getHelpUrl = "https://launchpad.net/distros/ubuntu/" + codename + "/+sources/" + getSourcePackageName() + "/+gethelp";
101
openUILink(getHelpUrl, event, false, true);
104
function ubufoxHelpTranslateLaunchpad(event)
106
var codename = Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.codename");
107
var translateUrl = "https://launchpad.net/distros/ubuntu/" + codename + "/+sources/" + getSourcePackageName() + "/+translate";
108
openUILink(translateUrl, event, false, true);
38
//Components.utils.import("resource://ubufox/uAddonInstaller.jsm");
39
Components.utils.import("resource://ubufox/UpdateRestartNotifier.jsm");
42
var UpdateRestartListener = {
44
restartNotificationLabel: null,
45
restartNotificationButton: null,
46
restartNotificationKey: null,
49
init: function URL_init() {
50
let bundle = document.getElementById("ubufox-restart-strings");
51
this.restartNotificationLabel = bundle.getString("restartNotificationLabel");
52
this.restartNotificationButton = bundle.getString("restartNotificationButton");
53
this.restartNotificationKey = bundle.getString("restartNotificationKey");
54
this.buttons = [{ label: this.restartNotificationButton,
55
accessKey: this.restartNotificationKey,
56
callback: UpdateRestartNotifier.restart }];
59
addNotificationToBrowser: function URL_addNotificationToBrowser(browser) {
60
let notificationBox = gBrowser.getNotificationBox(browser);
61
let notification = notificationBox
62
.getNotificationWithValue("notification-restart");
64
notificationBox.appendNotification(this.restartNotificationLabel,
65
"notification-restart", "",
66
notificationBox.PRIORITY_WARNING_LOW,
71
onUpdatedNotify: function URL_onUpdatedNotify() {
73
throw "onUpdatedNotify called more than once";
78
gBrowser.browsers.forEach(function(browser) {
79
UpdateRestartListener.addNotificationToBrowser(browser);
82
gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) {
83
UpdateRestartListener.addNotificationToBrowser(gBrowser
84
.getBrowserForTab(aEvent.target));
88
onUpdatedReminder: function URL_onUpdatedReminder() {
89
gBrowser.browsers.forEach(function(browser) {
90
UpdateRestartListener.addNotificationToBrowser(browser);
95
addEventListener("load", function() {
96
removeEventListener("load", arguments.callee, false);
97
UpdateRestartNotifier.addListener(UpdateRestartListener);
100
addEventListener("unload", function() {
101
removeEventListener("unload", arguments.callee, false);
102
// Don't remove this call, ever. Without this we will leak the
103
// document as it is in the scope of the callback, which
104
// UpdateRestartNotifier is holding on to
105
UpdateRestartNotifier.removeListener(UpdateRestartListener);
109
if (!com) var com = {};
110
if (!com.ubuntu) com.ubuntu = {};
113
const Ci = Components.interfaces;
114
const Cc = Components.classes;
117
openPluginFinder: function() {
118
let contentMimeArray = {};
119
let pluginsOnTab = false;
120
let elements = gBrowser.selectedBrowser.contentDocument
121
.getElementsByTagName("embed");
122
for (let a = 0; a < elements.length; a++) {
123
let element = elements[a];
124
let pluginInfo = getPluginInfo(element);
125
contentMimeArray[pluginInfo.mimetype] = pluginInfo;
128
window.openDialog("chrome://ubufox/content/pluginAlternativeOverlay.xul",
129
"PFSWindow", "chrome,centerscreen,resizable=yes",
130
{plugins: contentMimeArray,
131
browser: gBrowser.selectedBrowser,
132
pluginsOnTab: pluginsOnTab});
135
reportBug: function() {
136
let executable = Cc["@mozilla.org/file/local;1"]
137
.createInstance(Ci.nsILocalFile);
139
executable.initWithPath("/usr/bin/ubuntu-bug");
141
if(!executable.exists () || !executable.isExecutable())
142
alert('Unexpected error!');
144
let procUtil = Cc["@mozilla.org/process/util;1"]
145
.createInstance(Ci.nsIProcess);
147
procUtil.init(executable);
150
args = new Array("-p", firefox);
152
procUtil.run(false, args, args.length);
156
let codename = Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.codename");
157
let url = "https://launchpad.net/distros/ubuntu/" + codename + "/+sources/firefox/+gethelp";
158
openUILinkIn(url, "tab");
161
translate: function() {
162
let codename = Services.prefs.getCharPref("extensions.ubufox@ubuntu.com.codename");
163
let url = "https://launchpad.net/distros/ubuntu/" +
164
codename + "/+sources/firefox/+translate";
165
openUILinkIn(url, "tab");
169
window.addEventListener("load", function() {
170
window.removeEventListener("load", arguments.callee, false);
171
let item = document.getElementById("ubufox-helptranslate");