mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-07 07:04:09 +00:00
Bug 927310 - dispatch activitydone event from mozbrowser iframe
This commit is contained in:
parent
fc3242add6
commit
89a0b3f88f
@ -1327,16 +1327,6 @@ window.addEventListener('ContentStart', function update_onContentStart() {
|
||||
}, 'volume-state-changed', false);
|
||||
})();
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
let data = JSON.parse(aData);
|
||||
shell.sendChromeEvent({
|
||||
type: "activity-done",
|
||||
success: data.success,
|
||||
manifestURL: data.manifestURL,
|
||||
pageURL: data.pageURL
|
||||
});
|
||||
}, "activity-done", false);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// Devices don't have all the same partition size for /cache where we
|
||||
// store the http cache.
|
||||
|
@ -301,12 +301,10 @@ let Activities = {
|
||||
|
||||
case "Activity:PostResult":
|
||||
caller.mm.sendAsyncMessage("Activity:FireSuccess", msg);
|
||||
Services.obs.notifyObservers(null, "activity-done", obsData);
|
||||
delete this.callers[msg.id];
|
||||
break;
|
||||
case "Activity:PostError":
|
||||
caller.mm.sendAsyncMessage("Activity:FireError", msg);
|
||||
Services.obs.notifyObservers(null, "activity-done", obsData);
|
||||
delete this.callers[msg.id];
|
||||
break;
|
||||
|
||||
|
@ -9,6 +9,7 @@ const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
@ -53,6 +54,7 @@ ActivityRequestHandler.prototype = {
|
||||
"id": this._id,
|
||||
"result": aResult
|
||||
});
|
||||
Services.obs.notifyObservers(null, "activity-success", this._id);
|
||||
},
|
||||
|
||||
postError: function arh_postError(aError) {
|
||||
@ -60,6 +62,7 @@ ActivityRequestHandler.prototype = {
|
||||
"id": this._id,
|
||||
"error": aError
|
||||
});
|
||||
Services.obs.notifyObservers(null, "activity-error", this._id);
|
||||
},
|
||||
|
||||
classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"),
|
||||
|
@ -50,21 +50,36 @@ ActivityWrapper.prototype = {
|
||||
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic !== "inner-window-destroyed") {
|
||||
return;
|
||||
}
|
||||
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == innerWindowID) {
|
||||
debug("Closing activity window " + innerWindowID);
|
||||
Services.obs.removeObserver(observer, "inner-window-destroyed");
|
||||
cpmm.sendAsyncMessage("Activity:PostError",
|
||||
{ id: aMessage.id,
|
||||
error: "ActivityCanceled" });
|
||||
switch (aTopic) {
|
||||
case 'inner-window-destroyed':
|
||||
let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
if (wId == innerWindowID) {
|
||||
debug("Closing activity window " + innerWindowID);
|
||||
Services.obs.removeObserver(observer, "inner-window-destroyed");
|
||||
cpmm.sendAsyncMessage("Activity:PostError",
|
||||
{ id: aMessage.id,
|
||||
error: "ActivityCanceled"
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'activity-error':
|
||||
case 'activity-success':
|
||||
if (aData !== aMessage.id) {
|
||||
return;
|
||||
}
|
||||
Services.obs.removeObserver(observer, "activity-error");
|
||||
Services.obs.removeObserver(observer, "activity-success");
|
||||
let docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
Services.obs.notifyObservers(docshell, "activity-done", aTopic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, "activity-error", false);
|
||||
Services.obs.addObserver(observer, "activity-success", false);
|
||||
Services.obs.addObserver(observer, "inner-window-destroyed", false);
|
||||
return handler;
|
||||
},
|
||||
|
@ -265,12 +265,18 @@ BrowserElementChild.prototype = {
|
||||
Services.obs.addObserver(this,
|
||||
'xpcom-shutdown',
|
||||
/* ownsWeak = */ true);
|
||||
|
||||
Services.obs.addObserver(this,
|
||||
'activity-done',
|
||||
/* ownsWeak = */ true);
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
// Ignore notifications not about our document. (Note that |content| /can/
|
||||
// be null; see bug 874900.)
|
||||
if (!content || subject != content.document)
|
||||
if (topic !== 'activity-done' && (!content || subject != content.document))
|
||||
return;
|
||||
if (topic == 'activity-done' && docShell !== subject)
|
||||
return;
|
||||
switch (topic) {
|
||||
case 'fullscreen-origin-change':
|
||||
@ -282,6 +288,9 @@ BrowserElementChild.prototype = {
|
||||
case 'ask-parent-to-rollback-fullscreen':
|
||||
sendAsyncMsg('rollback-fullscreen');
|
||||
break;
|
||||
case 'activity-done':
|
||||
sendAsyncMsg('activitydone', { success: (data == 'activity-success') });
|
||||
break;
|
||||
case 'xpcom-shutdown':
|
||||
this._shuttingDown = true;
|
||||
break;
|
||||
|
@ -127,6 +127,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
|
||||
"iconchange": this._fireEventFromMsg,
|
||||
"close": this._fireEventFromMsg,
|
||||
"resize": this._fireEventFromMsg,
|
||||
"activitydone": this._fireEventFromMsg,
|
||||
"opensearch": this._fireEventFromMsg,
|
||||
"securitychange": this._fireEventFromMsg,
|
||||
"error": this._fireEventFromMsg,
|
||||
|
Loading…
x
Reference in New Issue
Block a user