Bug 823695: Part 1 - Send update errors after the shell is ready in B2G. r=fabrice

This commit is contained in:
Marshall Culpepper 2013-01-14 23:40:51 -08:00
parent 32ab354a8f
commit e85796faf3
2 changed files with 23 additions and 9 deletions

View File

@ -1005,9 +1005,11 @@ window.addEventListener('ContentStart', function cr_onContentStart() {
window.addEventListener('ContentStart', function update_onContentStart() {
let updatePrompt = Cc["@mozilla.org/updates/update-prompt;1"]
.createInstance(Ci.nsIUpdatePrompt);
if (!updatePrompt) {
return;
}
let content = shell.contentBrowser.contentWindow;
content.addEventListener("mozContentEvent", updatePrompt.wrappedJSObject);
updatePrompt.wrappedJSObject.handleContentStart(shell);
});
(function geolocationStatusTracker() {

View File

@ -118,6 +118,7 @@ UpdatePrompt.prototype = {
_applyPromptTimer: null,
_waitingForIdle: false,
_updateCheckListner: null,
_pendingEvents: [],
get applyPromptTimeout() {
return Services.prefs.getIntPref(PREF_APPLY_PROMPT_TIMEOUT);
@ -127,6 +128,16 @@ UpdatePrompt.prototype = {
return Services.prefs.getIntPref(PREF_APPLY_IDLE_TIMEOUT);
},
handleContentStart: function UP_handleContentStart(shell) {
let content = shell.contentBrowser.contentWindow;
content.addEventListener("mozContentEvent", this);
for (let i = 0; i < this._pendingEvents.length; i++) {
shell.sendChromeEvent(this._pendingEvents[i]);
}
this._pendingEvents.length = 0;
},
// nsIUpdatePrompt
// FIXME/bug 737601: we should have users opt-in to downloading
@ -237,16 +248,17 @@ UpdatePrompt.prototype = {
},
sendChromeEvent: function UP_sendChromeEvent(aType, aDetail) {
let browser = Services.wm.getMostRecentWindow("navigator:browser");
if (!browser) {
log("Warning: Couldn't send update event " + aType +
": no content browser");
return false;
}
let detail = aDetail || {};
detail.type = aType;
let browser = Services.wm.getMostRecentWindow("navigator:browser");
if (!browser) {
this._pendingEvents.push(detail);
log("Warning: Couldn't send update event " + aType +
": no content browser. Will send again when content becomes available.");
return false;
}
browser.shell.sendChromeEvent(detail);
return true;
},