Bug 877627 - [Contacts][Dialer] Dialer doesn't show on screen when launching from contacts. r=fabrice,shianyow a=tef+

This commit is contained in:
Gene Lian 2013-05-31 22:34:33 +08:00
parent 01dda39d42
commit 1ac319a951
2 changed files with 35 additions and 10 deletions

View File

@ -243,7 +243,17 @@ SystemMessageInternal.prototype = {
return -1;
},
_removeTargetFromListener: function _removeTargetFromListener(aTarget, aManifest, aRemoveListener) {
_isEmptyObject: function _isEmptyObject(aObj) {
for (let name in aObj) {
return false;
}
return true;
},
_removeTargetFromListener: function _removeTargetFromListener(aTarget,
aManifest,
aRemoveListener,
aUri) {
let targets = this._listeners[aManifest];
if (!targets) {
return false;
@ -260,7 +270,13 @@ SystemMessageInternal.prototype = {
return true;
}
if (--targets[index].winCount === 0) {
let target = targets[index];
if (aUri && target.winCounts[aUri] !== undefined &&
--target.winCounts[aUri] === 0) {
delete target.winCounts[aUri];
}
if (this._isEmptyObject(target.winCounts)) {
if (targets.length === 1) {
// If it's the only one, get rid of this manifest entirely.
debug("remove the listener for " + aManifest);
@ -297,17 +313,25 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Register":
{
debug("Got Register from " + msg.uri + " @ " + msg.manifest);
let uri = msg.uri;
let targets, index;
if (!(targets = this._listeners[msg.manifest])) {
let winCounts = {};
winCounts[uri] = 1;
this._listeners[msg.manifest] = [{ target: aMessage.target,
uri: msg.uri,
winCount: 1 }];
winCounts: winCounts }];
} else if ((index = this._findTargetIndex(targets, aMessage.target)) === -1) {
let winCounts = {};
winCounts[uri] = 1;
targets.push({ target: aMessage.target,
uri: msg.uri,
winCount: 1 });
winCounts: winCounts });
} else {
targets[index].winCount++;
let winCounts = targets[index].winCounts;
if (winCounts[uri] === undefined) {
winCounts[uri] = 1;
} else {
winCounts[uri]++;
}
}
debug("listeners for " + msg.manifest + " innerWinID " + msg.innerWindowID);
@ -318,7 +342,7 @@ SystemMessageInternal.prototype = {
debug("Got child-process-shutdown from " + aMessage.target);
for (let manifest in this._listeners) {
// See if any processes in this manifest have this target.
if (this._removeTargetFromListener(aMessage.target, manifest, true)) {
if (this._removeTargetFromListener(aMessage.target, manifest, true, null)) {
break;
}
}
@ -327,7 +351,7 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Unregister":
{
debug("Got Unregister from " + aMessage.target + "innerWinID " + msg.innerWindowID);
this._removeTargetFromListener(aMessage.target, msg.manifest, false);
this._removeTargetFromListener(aMessage.target, msg.manifest, false, msg.uri);
break;
}
case "SystemMessageManager:GetPendingMessages":
@ -521,7 +545,7 @@ SystemMessageInternal.prototype = {
let target = targets[index];
// We only need to send the system message to the targets which match
// the manifest URL and page URL of the destination of system message.
if (target.uri != aPageURI) {
if (target.winCounts[aPageURI] === undefined) {
continue;
}

View File

@ -144,6 +144,7 @@ SystemMessageManager.prototype = {
cpmm.sendAsyncMessage("SystemMessageManager:Unregister",
{ manifest: this._manifest,
uri: this._uri,
innerWindowID: this.innerWindowID });
},