Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 const Ci = Components.interfaces;
8 const Cu = Components.utils;
10 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
11 Cu.import("resource://gre/modules/Services.jsm");
13 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
14 "@mozilla.org/childprocessmessagemanager;1",
15 "nsISyncMessageSender");
17 function debug(aMsg) {
18 //dump("-- ActivityRequestHandler.js " + Date.now() + " : " + aMsg + "\n");
19 }
21 /**
22 * nsIDOMMozActivityRequestHandler implementation.
23 */
25 function ActivityRequestHandler() {
26 debug("ActivityRequestHandler");
28 // When a system message of type 'activity' is emitted, it forces the
29 // creation of an ActivityWrapper which in turns replace the default
30 // system message callback. The newly created wrapper then create an
31 // ActivityRequestHandler object.
32 }
34 ActivityRequestHandler.prototype = {
35 init: function arh_init(aWindow) {
36 this._window = aWindow;
37 },
39 __init: function arh___init(aId, aOptions) {
40 this._id = aId;
41 this._options = aOptions;
42 },
44 get source() {
45 // We need to clone this object because the this._options.data has
46 // the type any in WebIDL which will cause the binding layer to pass
47 // the value which is a COW unmodified to content.
48 return Cu.cloneInto(this._options, this._window);
49 },
51 postResult: function arh_postResult(aResult) {
52 cpmm.sendAsyncMessage("Activity:PostResult", {
53 "id": this._id,
54 "result": aResult
55 });
56 Services.obs.notifyObservers(null, "activity-success", this._id);
57 },
59 postError: function arh_postError(aError) {
60 cpmm.sendAsyncMessage("Activity:PostError", {
61 "id": this._id,
62 "error": aError
63 });
64 Services.obs.notifyObservers(null, "activity-error", this._id);
65 },
67 classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"),
69 QueryInterface: XPCOMUtils.generateQI([
70 Ci.nsIDOMGlobalPropertyInitializer
71 ])
72 }
74 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityRequestHandler]);