зеркало из https://github.com/mozilla/gecko-dev.git
Bug 796293 - [camera] Picking camera after long press causes app crash and phone reboot. r=fabrice, a=blocking-basecamp
This commit is contained in:
Родитель
b9df421ed9
Коммит
94deddb3c3
|
@ -90,12 +90,22 @@ SystemMessageInternal.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
let pagesToOpen = {};
|
||||
this._pages.forEach(function(aPage) {
|
||||
if (!this._isPageMatched(aPage, aType, aPageURI.spec, aManifestURI.spec)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._openAppPage(aPage, aMessage, messageID);
|
||||
// Queue this message in the corresponding pages.
|
||||
this._queueMessage(aPage, aMessage, messageID);
|
||||
|
||||
// Open app pages to handle their pending messages.
|
||||
// Note that we only need to open each app page once.
|
||||
let key = this._createKeyForPage(aPage);
|
||||
if (!pagesToOpen.hasOwnProperty(key)) {
|
||||
this._openAppPage(aPage, aMessage);
|
||||
pagesToOpen[key] = true;
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
@ -115,6 +125,7 @@ SystemMessageInternal.prototype = {
|
|||
|
||||
debug("Broadcasting " + aType + " " + JSON.stringify(aMessage));
|
||||
// Find pages that registered an handler for this type.
|
||||
let pagesToOpen = {};
|
||||
this._pages.forEach(function(aPage) {
|
||||
if (aPage.type == aType) {
|
||||
if (this._listeners[aPage.manifest]) {
|
||||
|
@ -127,7 +138,16 @@ SystemMessageInternal.prototype = {
|
|||
msgID: messageID })
|
||||
});
|
||||
}
|
||||
this._openAppPage(aPage, aMessage, messageID);
|
||||
// Queue this message in the corresponding pages.
|
||||
this._queueMessage(aPage, aMessage, messageID);
|
||||
|
||||
// Open app pages to handle their pending messages.
|
||||
// Note that we only need to open each app page once.
|
||||
let key = this._createKeyForPage(aPage);
|
||||
if (!pagesToOpen.hasOwnProperty(key)) {
|
||||
this._openAppPage(aPage, aMessage);
|
||||
pagesToOpen[key] = true;
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
@ -266,14 +286,16 @@ SystemMessageInternal.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_openAppPage: function _openAppPage(aPage, aMessage, aMessageID) {
|
||||
_queueMessage: function _queueMessage(aPage, aMessage, aMessageID) {
|
||||
// Queue the message for this page because we've never known if an app is
|
||||
// opened or not. We'll clean it up when the app has already received it.
|
||||
aPage.pendingMessages.push({ msg: aMessage, msgID: aMessageID });
|
||||
if (aPage.pendingMessages.length > kMaxPendingMessages) {
|
||||
aPage.pendingMessages.splice(0, 1);
|
||||
}
|
||||
},
|
||||
|
||||
_openAppPage: function _openAppPage(aPage, aMessage) {
|
||||
// We don't need to send the full object to observers.
|
||||
let page = { uri: aPage.uri,
|
||||
manifest: aPage.manifest,
|
||||
|
@ -289,6 +311,24 @@ SystemMessageInternal.prototype = {
|
|||
aPage.uri === aUri)
|
||||
},
|
||||
|
||||
_createKeyForPage: function _createKeyForPage(aPage) {
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||
.createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
converter.charset = "UTF-8";
|
||||
|
||||
let hasher = Cc["@mozilla.org/security/hash;1"]
|
||||
.createInstance(Ci.nsICryptoHash);
|
||||
hasher.init(hasher.SHA1);
|
||||
|
||||
// add uri and action to the hash
|
||||
["type", "manifest", "uri"].forEach(function(aProp) {
|
||||
let data = converter.convertToByteArray(aPage[aProp], {});
|
||||
hasher.update(data, data.length);
|
||||
});
|
||||
|
||||
return hasher.finish(true);
|
||||
},
|
||||
|
||||
classID: Components.ID("{70589ca5-91ac-4b9e-b839-d6a88167d714}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessagesInternal, Ci.nsIObserver])
|
||||
|
|
Загрузка…
Ссылка в новой задаче