Bug 785391 - Activities 'data' content cannot be accessed [r=gwagner]

This commit is contained in:
Fabrice Desré 2012-08-24 21:07:58 -07:00
parent 9701ecf307
commit 3b1bc3892e
6 changed files with 21 additions and 13 deletions

View File

@ -6,13 +6,16 @@
interface nsIDOMMozActivity;
interface nsIDOMMozActivityOptions;
interface nsIDOMWindow;
/**
* Implemented by @mozilla.org/dom/activities/proxy;1
*/
[scriptable, uuid(2241faf9-6219-4bc0-95f3-18651ac8a18b)]
[scriptable, uuid(3f9e0695-f466-4111-a8fa-ed5c0751c42b)]
interface nsIActivityProxy : nsISupports
{
void startActivity(in nsIDOMMozActivity activity, in nsIDOMMozActivityOptions options);
void startActivity(in nsIDOMMozActivity activity,
in nsIDOMMozActivityOptions options,
in nsIDOMWindow window);
void cleanup();
};

View File

@ -67,7 +67,7 @@ Activity::Initialize(nsISupports* aOwner,
mProxy = do_CreateInstance("@mozilla.org/dom/activities/proxy;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mProxy->StartActivity(this, options);
mProxy->StartActivity(this, options, window);
return NS_OK;
}

View File

@ -3,13 +3,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"]
@ -24,7 +25,7 @@ function debug(aMsg) {
/**
* nsIActivityProxy implementation
* We keep a reference to the C++ Activity object, and
* communicate with the Message Manager to know when to
* communicate with the Message Manager to know when to
* fire events on it.
*/
function ActivityProxy() {
@ -33,9 +34,10 @@ function ActivityProxy() {
}
ActivityProxy.prototype = {
startActivity: function actProxy_startActivity(aActivity, aOptions) {
startActivity: function actProxy_startActivity(aActivity, aOptions, aWindow) {
debug("startActivity");
this.window = aWindow;
this.activity = aActivity;
this.id = Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator)
@ -56,7 +58,8 @@ ActivityProxy.prototype = {
switch(aMessage.name) {
case "Activity:FireSuccess":
debug("FireSuccess");
Services.DOMRequest.fireSuccess(this.activity, msg.result);
Services.DOMRequest.fireSuccess(this.activity,
ObjectWrapper.wrap(msg.result, this.window));
break;
case "Activity:FireError":
debug("FireError");

View File

@ -9,6 +9,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
function debug(aMsg) {
//dump("-- ActivityWrapper.js " + Date.now() + " : " + aMsg + "\n");
@ -23,7 +24,7 @@ function ActivityWrapper() {
}
ActivityWrapper.prototype = {
wrapMessage: function wrapMessage(aMessage) {
wrapMessage: function wrapMessage(aMessage, aWindow) {
debug("Wrapping " + JSON.stringify(aMessage));
let handler = Cc["@mozilla.org/dom/activities/request-handler;1"]
.createInstance(Ci.nsIDOMMozActivityRequestHandler);
@ -32,7 +33,7 @@ ActivityWrapper.prototype = {
// options is an nsIDOMActivityOptions object.
var options = handler.wrappedJSObject._options;
options.wrappedJSObject._name = aMessage.payload.name;
options.wrappedJSObject._data = aMessage.payload.data;
options.wrappedJSObject._data = ObjectWrapper.wrap(aMessage.payload.data, aWindow);
return handler;
},

View File

@ -60,7 +60,7 @@ SystemMessageManager.prototype = {
debug(contractID + " is registered, creating an instance");
let wrapper = Cc[contractID].createInstance(Ci.nsISystemMessagesWrapper);
if (wrapper) {
aMessage = wrapper.wrapMessage(aMessage);
aMessage = wrapper.wrapMessage(aMessage, this._window);
wrapped = true;
debug("wrapped = " + aMessage);
}

View File

@ -5,6 +5,7 @@
#include "domstubs.idl"
interface nsIURI;
interface nsIDOMWindow;
// Implemented by the contract id @mozilla.org/system-message-internal;1
@ -29,12 +30,12 @@ interface nsISystemMessagesInternal : nsISupports
void registerPage(in DOMString type, in nsIURI pageURI, in nsIURI manifestURI);
};
[scriptable, uuid(b43c74ec-1b64-49fb-b552-aadd9d827eec)]
[scriptable, uuid(002f0e82-91f0-41de-ad43-569a2b9d12df)]
interface nsISystemMessagesWrapper: nsISupports
{
/*
* Wrap a message and gives back any kind of object.
* @param message The json blob to wrap.
*/
jsval wrapMessage(in jsval message);
jsval wrapMessage(in jsval message, in nsIDOMWindow window);
};