mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 851217 - Create webapp specific branding. r=Mossop
This commit is contained in:
parent
0e285f8064
commit
68b838bcbc
@ -62,7 +62,7 @@ ContentPermission.prototype = {
|
||||
}
|
||||
|
||||
// Display a prompt at the top level
|
||||
let {name} = WebappRT.config.app.manifest;
|
||||
let {name} = WebappRT.localeManifest;
|
||||
let requestingWindow = request.window.top;
|
||||
let chromeWin = this._getChromeWindow(requestingWindow);
|
||||
let bundle = Services.strings.createBundle("chrome://webapprt/locale/webapp.properties");
|
||||
|
@ -20,11 +20,14 @@ Cu.import("resource://gre/modules/PermissionsInstaller.jsm");
|
||||
Cu.import('resource://gre/modules/Payment.jsm');
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
// Initialize window-independent handling of webapps- notifications.
|
||||
Cu.import("resource://webapprt/modules/WebappsHandler.jsm");
|
||||
Cu.import("resource://webapprt/modules/WebappRT.jsm");
|
||||
|
||||
const PROFILE_DIR = OS.Constants.Path.profileDir;
|
||||
|
||||
function isFirstRunOrUpdate() {
|
||||
let savedBuildID = null;
|
||||
try {
|
||||
@ -41,6 +44,38 @@ function isFirstRunOrUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function writeFile(aPath, aData) {
|
||||
return Task.spawn(function() {
|
||||
let data = TextEncoder().encode(aData);
|
||||
yield OS.File.writeAtomic(aPath, data, { tmpPath: aPath + ".tmp" });
|
||||
});
|
||||
}
|
||||
|
||||
function createBrandingFiles() {
|
||||
return Task.spawn(function() {
|
||||
let manifest = WebappRT.localeManifest;
|
||||
let name = WebappRT.localeManifest.name;
|
||||
let developer = " ";
|
||||
if (WebappRT.localeManifest.developer) {
|
||||
developer = WebappRT.localeManifest.developer.name;
|
||||
}
|
||||
|
||||
let brandDTDContent = '<!ENTITY brandShortName "' + name + '">\n\
|
||||
<!ENTITY brandFullName "' + name + '">\n\
|
||||
<!ENTITY vendorShortName "' + developer + '">\n\
|
||||
<!ENTITY trademarkInfo.part1 " ">';
|
||||
|
||||
yield writeFile(OS.Path.join(PROFILE_DIR, "brand.dtd"), brandDTDContent);
|
||||
|
||||
let brandPropertiesContent = 'brandShortName=' + name + '\n\
|
||||
brandFullName=' + name + '\n\
|
||||
vendorShortName=' + developer;
|
||||
|
||||
yield writeFile(OS.Path.join(PROFILE_DIR, "brand.properties"),
|
||||
brandPropertiesContent);
|
||||
});
|
||||
}
|
||||
|
||||
// Observes all the events needed to actually launch an application.
|
||||
// It waits for XUL window and webapps registry loading.
|
||||
this.startup = function(window) {
|
||||
@ -79,9 +114,21 @@ this.startup = function(window) {
|
||||
// TODO: Update the permissions when the application is updated.
|
||||
if (isFirstRunOrUpdate(Services.prefs)) {
|
||||
PermissionsInstaller.installPermissions(WebappRT.config.app, true);
|
||||
yield createBrandingFiles();
|
||||
}
|
||||
}
|
||||
|
||||
// Branding substitution
|
||||
let aliasFile = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Ci.nsIFile);
|
||||
aliasFile.initWithPath(PROFILE_DIR);
|
||||
|
||||
let aliasURI = Services.io.newFileURI(aliasFile);
|
||||
|
||||
Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Ci.nsIResProtocolHandler)
|
||||
.setSubstitution("webappbranding", aliasURI);
|
||||
|
||||
// Wait for XUL window loading
|
||||
yield deferredWindowLoad.promise;
|
||||
|
||||
|
@ -46,8 +46,12 @@ this.WebappRT = {
|
||||
},
|
||||
|
||||
get launchURI() {
|
||||
let manifest = new ManifestHelper(this.config.app.manifest,
|
||||
this.config.app.origin);
|
||||
let manifest = this.localeManifest;
|
||||
return manifest.fullLaunchPath();
|
||||
}
|
||||
},
|
||||
|
||||
get localeManifest() {
|
||||
return new ManifestHelper(this.config.app.manifest,
|
||||
this.config.app.origin);
|
||||
},
|
||||
};
|
||||
|
@ -7,3 +7,5 @@
|
||||
% locale webapprt @AB_CD@ %locale/webapprt/
|
||||
locale/webapprt/webapp.dtd (%webapprt/webapp.dtd)
|
||||
locale/webapprt/webapp.properties (%webapprt/webapp.properties)
|
||||
|
||||
% locale branding @AB_CD@ resource://webappbranding/
|
||||
|
Loading…
Reference in New Issue
Block a user