mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 873348 - System Message API: s/sendSystemMessage/openAppForSystemMessage/ in the shell.js. r=fabrice
This commit is contained in:
parent
e0efa610de
commit
815a3150ad
@ -431,8 +431,8 @@ var shell = {
|
||||
},
|
||||
|
||||
lastHardwareButtonEventType: null, // property for the hack above
|
||||
needBufferSysMsgs: true,
|
||||
bufferedSysMsgs: [],
|
||||
needBufferOpenAppReq: true,
|
||||
bufferedOpenAppReqs: [],
|
||||
timer: null,
|
||||
visibleNormalAudioActive: false,
|
||||
|
||||
@ -548,7 +548,7 @@ var shell = {
|
||||
ObjectWrapper.wrap(details, getContentWindow()));
|
||||
},
|
||||
|
||||
sendSystemMessage: function shell_sendSystemMessage(msg) {
|
||||
openAppForSystemMessage: function shell_openAppForSystemMessage(msg) {
|
||||
let origin = Services.io.newURI(msg.manifest, null, null).prePath;
|
||||
this.sendChromeEvent({
|
||||
type: 'open-app',
|
||||
@ -623,16 +623,16 @@ nsBrowserAccess.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
// Listen for system messages and relay them to Gaia.
|
||||
Services.obs.addObserver(function onSystemMessage(subject, topic, data) {
|
||||
// Listen for the request of opening app and relay them to Gaia.
|
||||
Services.obs.addObserver(function onSystemMessageOpenApp(subject, topic, data) {
|
||||
let msg = JSON.parse(data);
|
||||
// Buffer non-activity messages until content starts to load for 10 seconds.
|
||||
// We'll revisit this later if new kind of messages don't need to be cached.
|
||||
if (shell.needBufferSysMsgs && msg.type !== 'activity') {
|
||||
shell.bufferedSysMsgs.push(msg);
|
||||
// Buffer non-activity request until content starts to load for 10 seconds.
|
||||
// We'll revisit this later if new kind of requests don't need to be cached.
|
||||
if (shell.needBufferOpenAppReq && msg.type !== 'activity') {
|
||||
shell.bufferedOpenAppReqs.push(msg);
|
||||
return;
|
||||
}
|
||||
shell.sendSystemMessage(msg);
|
||||
shell.openAppForSystemMessage(msg);
|
||||
}, 'system-messages-open-app', false);
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
@ -662,14 +662,17 @@ var CustomEventManager = {
|
||||
content.addEventListener("mozContentEvent", this, false, true);
|
||||
|
||||
// After content starts to load for 10 seconds, send and
|
||||
// clean up the buffered system messages if there is any.
|
||||
// clean up the buffered open-app requests if there is any.
|
||||
//
|
||||
// TODO: Bug 793420 - Remove the waiting timer for the 'open-app'
|
||||
// mozChromeEvents requested by System Message
|
||||
shell.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
shell.timer.initWithCallback(function timerCallback() {
|
||||
shell.bufferedSysMsgs.forEach(function sendSysMsg(msg) {
|
||||
shell.sendSystemMessage(msg);
|
||||
shell.bufferedOpenAppReqs.forEach(function bufferOpenAppReq(msg) {
|
||||
shell.openAppForSystemMessage(msg);
|
||||
});
|
||||
shell.bufferedSysMsgs.length = 0;
|
||||
shell.needBufferSysMsgs = false;
|
||||
shell.bufferedOpenAppReqs.length = 0;
|
||||
shell.needBufferOpenAppReq = false;
|
||||
shell.timer = null;
|
||||
}, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}).bind(this), false);
|
||||
|
Loading…
Reference in New Issue
Block a user