mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 789114 - Make B2G and Fennec browser actors inherit the extensibility API changes. f=glandium r=msucan,mfinkle,vingtetun
This commit is contained in:
parent
cf0e138e04
commit
152572b05a
@ -38,6 +38,7 @@ DeviceRootActor.prototype = new BrowserRootActor();
|
||||
* Disconnects the actor from the browser window.
|
||||
*/
|
||||
DeviceRootActor.prototype.disconnect = function DRA_disconnect() {
|
||||
this._extraActors = null;
|
||||
let actor = this._tabActors.get(this.browser);
|
||||
if (actor) {
|
||||
actor.exit();
|
||||
@ -61,6 +62,8 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
let actorPool = new ActorPool(this.conn);
|
||||
actorPool.addActor(actor);
|
||||
|
||||
this._createExtraActors(DebuggerServer.globalActorFactories, actorPool);
|
||||
|
||||
// Now drop the old actorID -> actor map. Actors that still mattered were
|
||||
// added to the new map, others will go away.
|
||||
if (this._tabActorPool) {
|
||||
@ -69,11 +72,13 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
this._tabActorPool = actorPool;
|
||||
this.conn.addActorPool(this._tabActorPool);
|
||||
|
||||
return {
|
||||
let response = {
|
||||
'from': 'root',
|
||||
'selected': 0,
|
||||
'tabs': [actor.grip()]
|
||||
};
|
||||
this._appendExtraActors(response);
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -103,11 +108,23 @@ DeviceTabActor.prototype.grip = function DTA_grip() {
|
||||
'grip() should not be called on exited browser actor.');
|
||||
dbg_assert(this.actorID,
|
||||
'tab should have an actorID.');
|
||||
return {
|
||||
|
||||
let response = {
|
||||
'actor': this.actorID,
|
||||
'title': this.browser.title,
|
||||
'url': this.browser.document.documentURI
|
||||
};
|
||||
|
||||
// Walk over tab actors added by extensions and add them to a new ActorPool.
|
||||
let actorPool = new ActorPool(this.conn);
|
||||
this._createExtraActors(DebuggerServer.globalActorFactories, actorPool);
|
||||
if (!actorPool.isEmpty()) {
|
||||
this._tabActorPool = actorPool;
|
||||
this.conn.addActorPool(this._tabActorPool);
|
||||
}
|
||||
|
||||
this._appendExtraActors(response);
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
// an ActorPool.
|
||||
|
||||
let actorPool = new ActorPool(this.conn);
|
||||
let actorList = [];
|
||||
let tabActorList = [];
|
||||
|
||||
let win = windowMediator.getMostRecentWindow("navigator:browser");
|
||||
this.browser = win.BrowserApp.selectedBrowser;
|
||||
@ -59,7 +59,7 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
let browser = tab.browser;
|
||||
|
||||
if (browser == this.browser) {
|
||||
selected = actorList.length;
|
||||
selected = tabActorList.length;
|
||||
}
|
||||
|
||||
let actor = this._tabActors.get(browser);
|
||||
@ -70,9 +70,11 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
}
|
||||
|
||||
actorPool.addActor(actor);
|
||||
actorList.push(actor);
|
||||
tabActorList.push(actor);
|
||||
}
|
||||
|
||||
this._createExtraActors(DebuggerServer.globalActorFactories, actorPool);
|
||||
|
||||
// Now drop the old actorID -> actor map. Actors that still
|
||||
// mattered were added to the new map, others will go
|
||||
// away.
|
||||
@ -83,10 +85,13 @@ DeviceRootActor.prototype.onListTabs = function DRA_onListTabs() {
|
||||
this._tabActorPool = actorPool;
|
||||
this.conn.addActorPool(this._tabActorPool);
|
||||
|
||||
return { "from": "root",
|
||||
"selected": selected,
|
||||
"tabs": [actor.grip()
|
||||
for each (actor in actorList)] };
|
||||
let response = {
|
||||
"from": "root",
|
||||
"selected": selected,
|
||||
"tabs": [actor.grip() for (actor of tabActorList)]
|
||||
};
|
||||
this._appendExtraActors(response);
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -113,17 +113,7 @@ BrowserRootActor.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// Walk over global actors added by extensions.
|
||||
for (let name in DebuggerServer.globalActorFactories) {
|
||||
let actor = this._extraActors[name];
|
||||
if (!actor) {
|
||||
actor = DebuggerServer.globalActorFactories[name].bind(null, this.conn);
|
||||
actor.prototype = DebuggerServer.globalActorFactories[name].prototype;
|
||||
actor.parentID = this.actorID;
|
||||
this._extraActors[name] = actor;
|
||||
}
|
||||
actorPool.addActor(actor);
|
||||
}
|
||||
this._createExtraActors(DebuggerServer.globalActorFactories, actorPool);
|
||||
|
||||
// Now drop the old actorID -> actor map. Actors that still
|
||||
// mattered were added to the new map, others will go
|
||||
@ -139,11 +129,35 @@ BrowserRootActor.prototype = {
|
||||
"selected": selected,
|
||||
"tabs": [actor.grip() for (actor of tabActorList)]
|
||||
};
|
||||
this._appendExtraActors(response);
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds dynamically-added actors from add-ons to the provided pool.
|
||||
*/
|
||||
_createExtraActors: function BRA_createExtraActors(aFactories, aPool) {
|
||||
// Walk over global actors added by extensions.
|
||||
for (let name in aFactories) {
|
||||
let actor = this._extraActors[name];
|
||||
if (!actor) {
|
||||
actor = aFactories[name].bind(null, this.conn);
|
||||
actor.prototype = aFactories[name].prototype;
|
||||
actor.parentID = this.actorID;
|
||||
this._extraActors[name] = actor;
|
||||
}
|
||||
aPool.addActor(actor);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Appends the extra actors to the specified object.
|
||||
*/
|
||||
_appendExtraActors: function BRA_appendExtraActors(aObject) {
|
||||
for (let name in this._extraActors) {
|
||||
let actor = this._extraActors[name];
|
||||
response[name] = actor.actorID;
|
||||
aObject[name] = actor.actorID;
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -230,6 +244,8 @@ function BrowserTabActor(aConnection, aBrowser, aTabBrowser)
|
||||
// A map of actor names to actor instances provided by extensions.
|
||||
this._extraActors = {};
|
||||
|
||||
this._createExtraActors = BrowserRootActor.prototype._createExtraActors.bind(this);
|
||||
this._appendExtraActors = BrowserRootActor.prototype._appendExtraActors.bind(this);
|
||||
this._onWindowCreated = this.onWindowCreated.bind(this);
|
||||
}
|
||||
|
||||
@ -288,25 +304,13 @@ BrowserTabActor.prototype = {
|
||||
|
||||
// Walk over tab actors added by extensions and add them to a new ActorPool.
|
||||
let actorPool = new ActorPool(this.conn);
|
||||
for (let name in DebuggerServer.tabActorFactories) {
|
||||
let actor = this._extraActors[name];
|
||||
if (!actor) {
|
||||
actor = DebuggerServer.tabActorFactories[name].bind(null, this.conn);
|
||||
actor.prototype = DebuggerServer.tabActorFactories[name].prototype;
|
||||
actor.parentID = this.actorID;
|
||||
this._extraActors[name] = actor;
|
||||
}
|
||||
actorPool.addActor(actor);
|
||||
}
|
||||
this._createExtraActors(DebuggerServer.tabActorFactories, actorPool);
|
||||
if (!actorPool.isEmpty()) {
|
||||
this._tabActorPool = actorPool;
|
||||
this.conn.addActorPool(this._tabActorPool);
|
||||
}
|
||||
|
||||
for (let name in this._extraActors) {
|
||||
let actor = this._extraActors[name];
|
||||
response[name] = actor.actorID;
|
||||
}
|
||||
this._appendExtraActors(response);
|
||||
return response;
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user