mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 970208 - Only print debug messages when in debug mode; r=wesj
This commit is contained in:
parent
1890a5332f
commit
e9180388f8
@ -28,13 +28,15 @@ XPCOMUtils.defineLazyGetter(this, "Strings", function() {
|
|||||||
return Services.strings.createBundle("chrome://browser/locale/webapp.properties");
|
return Services.strings.createBundle("chrome://browser/locale/webapp.properties");
|
||||||
});
|
});
|
||||||
|
|
||||||
function log(message) {
|
function debug(aMessage) {
|
||||||
// We use *dump* instead of Services.console.logStringMessage so the messages
|
// We use *dump* instead of Services.console.logStringMessage so the messages
|
||||||
// have the INFO level of severity instead of the ERROR level. And we don't
|
// have the INFO level of severity instead of the ERROR level. And we don't
|
||||||
// append a newline character to the end of the message because *dump* spills
|
// append a newline character to the end of the message because *dump* spills
|
||||||
// into the Android native logging system, which strips newlines from messages
|
// into the Android native logging system, which strips newlines from messages
|
||||||
// and breaks messages into lines automatically at display time (i.e. logcat).
|
// and breaks messages into lines automatically at display time (i.e. logcat).
|
||||||
dump(message);
|
#ifdef MOZ_DEBUG
|
||||||
|
dump(aMessage);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessageToJava(aMessage) {
|
function sendMessageToJava(aMessage) {
|
||||||
@ -80,7 +82,7 @@ this.WebappManager = {
|
|||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
aMessage.error = ex;
|
aMessage.error = ex;
|
||||||
aMessageManager.sendAsyncMessage("Webapps:Install:Return:KO", aMessage);
|
aMessageManager.sendAsyncMessage("Webapps:Install:Return:KO", aMessage);
|
||||||
log("error downloading APK: " + ex);
|
debug("error downloading APK: " + ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ this.WebappManager = {
|
|||||||
}).bind(this)); },
|
}).bind(this)); },
|
||||||
|
|
||||||
_downloadApk: function(aManifestUrl) {
|
_downloadApk: function(aManifestUrl) {
|
||||||
log("_downloadApk for " + aManifestUrl);
|
debug("_downloadApk for " + aManifestUrl);
|
||||||
let deferred = Promise.defer();
|
let deferred = Promise.defer();
|
||||||
|
|
||||||
// Get the endpoint URL and convert it to an nsIURI/nsIURL object.
|
// Get the endpoint URL and convert it to an nsIURI/nsIURL object.
|
||||||
@ -106,7 +108,7 @@ this.WebappManager = {
|
|||||||
};
|
};
|
||||||
generatorUrl.query =
|
generatorUrl.query =
|
||||||
[p + "=" + encodeURIComponent(params[p]) for (p in params)].join("&");
|
[p + "=" + encodeURIComponent(params[p]) for (p in params)].join("&");
|
||||||
log("downloading APK from " + generatorUrl.spec);
|
debug("downloading APK from " + generatorUrl.spec);
|
||||||
|
|
||||||
let file = Cc["@mozilla.org/download-manager;1"].
|
let file = Cc["@mozilla.org/download-manager;1"].
|
||||||
getService(Ci.nsIDownloadManager).
|
getService(Ci.nsIDownloadManager).
|
||||||
@ -114,7 +116,7 @@ this.WebappManager = {
|
|||||||
clone();
|
clone();
|
||||||
file.append(aManifestUrl.replace(/[^a-zA-Z0-9]/gi, "") + ".apk");
|
file.append(aManifestUrl.replace(/[^a-zA-Z0-9]/gi, "") + ".apk");
|
||||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
|
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
|
||||||
log("downloading APK to " + file.path);
|
debug("downloading APK to " + file.path);
|
||||||
|
|
||||||
let worker = new ChromeWorker("resource://gre/modules/WebappManagerWorker.js");
|
let worker = new ChromeWorker("resource://gre/modules/WebappManagerWorker.js");
|
||||||
worker.onmessage = function(event) {
|
worker.onmessage = function(event) {
|
||||||
@ -125,7 +127,7 @@ this.WebappManager = {
|
|||||||
if (type == "success") {
|
if (type == "success") {
|
||||||
deferred.resolve(file.path);
|
deferred.resolve(file.path);
|
||||||
} else { // type == "failure"
|
} else { // type == "failure"
|
||||||
log("error downloading APK: " + message);
|
debug("error downloading APK: " + message);
|
||||||
deferred.reject(message);
|
deferred.reject(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +149,7 @@ this.WebappManager = {
|
|||||||
// when we trigger the native install dialog and doesn't re-init itself
|
// when we trigger the native install dialog and doesn't re-init itself
|
||||||
// afterward (TODO: file bug about this behavior).
|
// afterward (TODO: file bug about this behavior).
|
||||||
if ("appcache_path" in aData.app.manifest) {
|
if ("appcache_path" in aData.app.manifest) {
|
||||||
log("deleting appcache_path from manifest: " + aData.app.manifest.appcache_path);
|
debug("deleting appcache_path from manifest: " + aData.app.manifest.appcache_path);
|
||||||
delete aData.app.manifest.appcache_path;
|
delete aData.app.manifest.appcache_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +170,7 @@ this.WebappManager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
launch: function({ manifestURL, origin }) {
|
launch: function({ manifestURL, origin }) {
|
||||||
log("launchWebapp: " + manifestURL);
|
debug("launchWebapp: " + manifestURL);
|
||||||
|
|
||||||
sendMessageToJava({
|
sendMessageToJava({
|
||||||
type: "Webapps:Open",
|
type: "Webapps:Open",
|
||||||
@ -178,7 +180,7 @@ this.WebappManager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
uninstall: function(aData) {
|
uninstall: function(aData) {
|
||||||
log("uninstall: " + aData.manifestURL);
|
debug("uninstall: " + aData.manifestURL);
|
||||||
|
|
||||||
if (this._testing) {
|
if (this._testing) {
|
||||||
// We don't have to do anything, as the registry does all the work.
|
// We don't have to do anything, as the registry does all the work.
|
||||||
@ -199,7 +201,7 @@ this.WebappManager = {
|
|||||||
let mm = {
|
let mm = {
|
||||||
sendAsyncMessage: function (aMessageName, aData) {
|
sendAsyncMessage: function (aMessageName, aData) {
|
||||||
// TODO hook this back to Java to report errors.
|
// TODO hook this back to Java to report errors.
|
||||||
log("sendAsyncMessage " + aMessageName + ": " + JSON.stringify(aData));
|
debug("sendAsyncMessage " + aMessageName + ": " + JSON.stringify(aData));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ this.WebappManager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_autoUpdate: function(aData, aOldApp) { return Task.spawn((function*() {
|
_autoUpdate: function(aData, aOldApp) { return Task.spawn((function*() {
|
||||||
log("_autoUpdate app of type " + aData.type);
|
debug("_autoUpdate app of type " + aData.type);
|
||||||
|
|
||||||
if (aData.type == "hosted") {
|
if (aData.type == "hosted") {
|
||||||
let oldManifest = yield DOMApplicationRegistry.getManifestFor(aData.manifestURL);
|
let oldManifest = yield DOMApplicationRegistry.getManifestFor(aData.manifestURL);
|
||||||
@ -257,13 +259,13 @@ this.WebappManager = {
|
|||||||
_checkingForUpdates: false,
|
_checkingForUpdates: false,
|
||||||
|
|
||||||
checkForUpdates: function(userInitiated) { return Task.spawn((function*() {
|
checkForUpdates: function(userInitiated) { return Task.spawn((function*() {
|
||||||
log("checkForUpdates");
|
debug("checkForUpdates");
|
||||||
|
|
||||||
// Don't start checking for updates if we're already doing so.
|
// Don't start checking for updates if we're already doing so.
|
||||||
// TODO: Consider cancelling the old one and starting a new one anyway
|
// TODO: Consider cancelling the old one and starting a new one anyway
|
||||||
// if the user requested this one.
|
// if the user requested this one.
|
||||||
if (this._checkingForUpdates) {
|
if (this._checkingForUpdates) {
|
||||||
log("already checking for updates");
|
debug("already checking for updates");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._checkingForUpdates = true;
|
this._checkingForUpdates = true;
|
||||||
@ -466,7 +468,7 @@ this.WebappManager = {
|
|||||||
try {
|
try {
|
||||||
yield OS.file.remove(apk.filePath);
|
yield OS.file.remove(apk.filePath);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
log("error removing " + apk.filePath + " for cancelled update: " + ex);
|
debug("error removing " + apk.filePath + " for cancelled update: " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,14 +514,14 @@ this.WebappManager = {
|
|||||||
for (let id in DOMApplicationRegistry.webapps) {
|
for (let id in DOMApplicationRegistry.webapps) {
|
||||||
let app = DOMApplicationRegistry.webapps[id];
|
let app = DOMApplicationRegistry.webapps[id];
|
||||||
if (aData.apkPackageNames.indexOf(app.apkPackageName) > -1) {
|
if (aData.apkPackageNames.indexOf(app.apkPackageName) > -1) {
|
||||||
log("attempting to uninstall " + app.name);
|
debug("attempting to uninstall " + app.name);
|
||||||
DOMApplicationRegistry.uninstall(
|
DOMApplicationRegistry.uninstall(
|
||||||
app.manifestURL,
|
app.manifestURL,
|
||||||
function() {
|
function() {
|
||||||
log("success uninstalling " + app.name);
|
debug("success uninstalling " + app.name);
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
log("error uninstalling " + app.name + ": " + error);
|
debug("error uninstalling " + app.name + ": " + error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -548,7 +550,7 @@ this.WebappManager = {
|
|||||||
if (aPrefs.length > 0) {
|
if (aPrefs.length > 0) {
|
||||||
let array = new TextEncoder().encode(JSON.stringify(aPrefs));
|
let array = new TextEncoder().encode(JSON.stringify(aPrefs));
|
||||||
OS.File.writeAtomic(aFile.path, array, { tmpPath: aFile.path + ".tmp" }).then(null, function onError(reason) {
|
OS.File.writeAtomic(aFile.path, array, { tmpPath: aFile.path + ".tmp" }).then(null, function onError(reason) {
|
||||||
log("Error writing default prefs: " + reason);
|
debug("Error writing default prefs: " + reason);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,9 @@ EXTRA_JS_MODULES += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
if CONFIG['MOZ_ANDROID_SYNTHAPKS']:
|
if CONFIG['MOZ_ANDROID_SYNTHAPKS']:
|
||||||
EXTRA_JS_MODULES += [
|
EXTRA_PP_JS_MODULES += [
|
||||||
'WebappManager.jsm',
|
'WebappManager.jsm',
|
||||||
|
]
|
||||||
|
EXTRA_JS_MODULES += [
|
||||||
'WebappManagerWorker.js',
|
'WebappManagerWorker.js',
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user