Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | const Cu = Components.utils; |
michael@0 | 7 | |
michael@0 | 8 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 9 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 10 | |
michael@0 | 11 | // ----------------------------------------------------------------------- |
michael@0 | 12 | // Alerts Service |
michael@0 | 13 | // ----------------------------------------------------------------------- |
michael@0 | 14 | |
michael@0 | 15 | function AlertsService() { } |
michael@0 | 16 | |
michael@0 | 17 | AlertsService.prototype = { |
michael@0 | 18 | classID: Components.ID("{fe33c107-82a4-41d6-8c64-5353267e04c9}"), |
michael@0 | 19 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIAlertsService]), |
michael@0 | 20 | |
michael@0 | 21 | showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable, |
michael@0 | 22 | aCookie, aAlertListener, aName, aDir, aLang) { |
michael@0 | 23 | let browser = Services.wm.getMostRecentWindow("navigator:browser"); |
michael@0 | 24 | try { |
michael@0 | 25 | browser.AlertsHelper.showAlertNotification(aImageUrl, aTitle, aText, aTextClickable, aCookie, aAlertListener); |
michael@0 | 26 | } catch (ex) { |
michael@0 | 27 | let chromeWin = this._getChromeWindow(browser).wrappedJSObject; |
michael@0 | 28 | let notificationBox = chromeWin.Browser.getNotificationBox(); |
michael@0 | 29 | notificationBox.appendNotification(aTitle, |
michael@0 | 30 | aText, |
michael@0 | 31 | aImageUrl, |
michael@0 | 32 | notificationBox.PRIORITY_WARNING_MEDIUM, |
michael@0 | 33 | null); |
michael@0 | 34 | } |
michael@0 | 35 | }, |
michael@0 | 36 | |
michael@0 | 37 | closeAlert: function(aName) { |
michael@0 | 38 | let browser = Services.wm.getMostRecentWindow("navigator:browser"); |
michael@0 | 39 | browser.AlertsHelper.closeAlert(); |
michael@0 | 40 | }, |
michael@0 | 41 | |
michael@0 | 42 | _getChromeWindow: function (aWindow) { |
michael@0 | 43 | let chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 44 | .getInterface(Ci.nsIWebNavigation) |
michael@0 | 45 | .QueryInterface(Ci.nsIDocShellTreeItem) |
michael@0 | 46 | .rootTreeItem |
michael@0 | 47 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 48 | .getInterface(Ci.nsIDOMWindow) |
michael@0 | 49 | .QueryInterface(Ci.nsIDOMChromeWindow); |
michael@0 | 50 | return chromeWin; |
michael@0 | 51 | } |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AlertsService]); |