diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-30 16:56:27 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-30 16:56:27 +0200 |
commit | 3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc (patch) | |
tree | f885285ead836f41431d315cf4f4a6720e82d34a /application/palemoon | |
parent | fefce8f7ccbc476cfc46e61b01eff069346d3c73 (diff) | |
download | UXP-3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc.tar UXP-3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc.tar.gz UXP-3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc.tar.lz UXP-3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc.tar.xz UXP-3ceed6b6db4628b2b5c5ab9661f71f30765e7bcc.zip |
[PALEMOON] Added gBrandBundle lazy getter and use gBrowserBundle in nsBrowserGlue.js
Tag #273
Diffstat (limited to 'application/palemoon')
-rw-r--r-- | application/palemoon/components/nsBrowserGlue.js | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/application/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js index d1f10111a..aa24d88ef 100644 --- a/application/palemoon/components/nsBrowserGlue.js +++ b/application/palemoon/components/nsBrowserGlue.js @@ -45,6 +45,11 @@ XPCOMUtils.defineLazyServiceGetter(this, "AlertsService", ].forEach(([name, resource]) => XPCOMUtils.defineLazyModuleGetter(this, name, resource)); // Define Lazy Getters + +XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() { + return Services.strings.createBundle('chrome://branding/locale/brand.properties'); +}); + XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() { return Services.strings.createBundle('chrome://browser/locale/browser.properties'); }); @@ -470,9 +475,7 @@ BrowserGlue.prototype = { if (!win) return; - let productName = Services.strings - .createBundle("chrome://branding/locale/brand.properties") - .GetStringFromName("brandFullName"); + let productName = gBrandBundle.GetStringFromName("brandFullName"); let message = win.gNavigatorBundle.getFormattedString("slowStartup.message", [productName]); let buttons = [ @@ -719,9 +722,8 @@ BrowserGlue.prototype = { let prompt = Services.prompt; let quitBundle = Services.strings.createBundle("chrome://browser/locale/quitDialog.properties"); - let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); - let appName = brandBundle.GetStringFromName("brandShortName"); + let appName = gBrandBundle.GetStringFromName("brandShortName"); let quitDialogTitle = quitBundle.formatStringFromName("quitDialogTitle", [appName], 1); let neverAskText = quitBundle.GetStringFromName("neverAsk2"); @@ -798,9 +800,7 @@ BrowserGlue.prototype = { var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]. getService(Ci.nsIURLFormatter); - var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); - var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); - var appName = brandBundle.GetStringFromName("brandShortName"); + var appName = gBrandBundle.GetStringFromName("brandShortName"); function getNotifyString(aPropData) { var propValue = update.getProperty(aPropData.propName); @@ -808,11 +808,11 @@ BrowserGlue.prototype = { if (aPropData.prefName) propValue = formatter.formatURLPref(aPropData.prefName); else if (aPropData.stringParams) - propValue = browserBundle.formatStringFromName(aPropData.stringName, - aPropData.stringParams, - aPropData.stringParams.length); + propValue = gBrowserBundle.formatStringFromName(aPropData.stringName, + aPropData.stringParams, + aPropData.stringParams.length); else - propValue = browserBundle.GetStringFromName(aPropData.stringName); + propValue = gBrowserBundle.GetStringFromName(aPropData.stringName); } return propValue; } @@ -1173,8 +1173,7 @@ BrowserGlue.prototype = { * Show the notificationBox for a locked places database. */ _showPlacesLockedNotificationBox: function BG__showPlacesLockedNotificationBox() { - var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); - var applicationName = brandBundle.GetStringFromName("brandShortName"); + var applicationName = gBrandBundle.GetStringFromName("brandShortName"); var placesBundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties"); var title = placesBundle.GetStringFromName("lockPrompt.title"); var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName], 1); @@ -1742,8 +1741,6 @@ ContentPermissionPrompt.prototype = { popup.remove(); } - var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); - var requestingWindow = aRequest.window.top; var chromeWin = this._getChromeWindow(requestingWindow).wrappedJSObject; var browser = chromeWin.gBrowser.getBrowserForDocument(requestingWindow.document); @@ -1769,8 +1766,8 @@ ContentPermissionPrompt.prototype = { } var action = { - label: browserBundle.GetStringFromName(promptAction.stringId), - accessKey: browserBundle.GetStringFromName(promptAction.stringId + ".accesskey"), + label: gBrowserBundle.GetStringFromName(promptAction.stringId), + accessKey: gBrowserBundle.GetStringFromName(promptAction.stringId + ".accesskey"), callback: function() { if (promptAction.callback) { promptAction.callback(); @@ -1829,7 +1826,6 @@ ContentPermissionPrompt.prototype = { }, _promptGeo : function(aRequest) { - var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); var requestingURI = aRequest.principal.URI; var message; @@ -1845,11 +1841,11 @@ ContentPermissionPrompt.prototype = { }]; if (requestingURI.schemeIs("file")) { - message = browserBundle.formatStringFromName("geolocation.shareWithFile", - [requestingURI.path], 1); + message = gBrowserBundle.formatStringFromName("geolocation.shareWithFile", + [requestingURI.path], 1); } else { - message = browserBundle.formatStringFromName("geolocation.shareWithSite", - [requestingURI.host], 1); + message = gBrowserBundle.formatStringFromName("geolocation.shareWithSite", + [requestingURI.host], 1); // Always share location action. actions.push({ stringId: "geolocation.alwaysShareLocation", @@ -1880,11 +1876,10 @@ ContentPermissionPrompt.prototype = { }, _promptWebNotifications : function(aRequest) { - var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); var requestingURI = aRequest.principal.URI; - var message = browserBundle.formatStringFromName("webNotifications.showFromSite", - [requestingURI.host], 1); + var message = gBrowserBundle.formatStringFromName("webNotifications.showFromSite", + [requestingURI.host], 1); var actions; @@ -1932,14 +1927,12 @@ ContentPermissionPrompt.prototype = { }, _promptPointerLock: function CPP_promtPointerLock(aRequest, autoAllow) { - - let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties"); let requestingURI = aRequest.principal.URI; let originString = requestingURI.schemeIs("file") ? requestingURI.path : requestingURI.host; - let message = browserBundle.formatStringFromName(autoAllow ? - "pointerLock.autoLock.title2" : "pointerLock.title2", - [originString], 1); + let message = gBrowserBundle.formatStringFromName(autoAllow ? + "pointerLock.autoLock.title2" : "pointerLock.title2", + [originString], 1); // If this is an autoAllow info prompt, offer no actions. // _showPrompt() will allow the request when it's dismissed. let actions = []; |