2014-07-17 5 views
1

J'essaie d'interagir avec un autre profil ouvert, qui est un processus séparé. Browser Toolbox fait cela. Je me demandais comment puis-je re-simuler ce comportement? Sans l'invite demandant "autoriser la connexion à distance"?Connexion à distance comme la boîte à outils du navigateur

Mon but est de (1) trouver tous les processus open firefox, (2) accéder à chacun de ses xpcom et comprendre le nom du profil, (3) et si c'est un nom de profil qui m'intéresse, Ill focus son plus récent fenêtre.

Répondre

1

Je ne sais pas, mais je reçois quelque part en traçant dans MXR:

http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/toolbox-process-window.js#11

11 let { debuggerSocketConnect, DebuggerClient } = 
12 Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {}); 
13 let { ViewHelpers } = 
14 Cu.import("resource:///modules/devtools/ViewHelpers.jsm", {}); 
15 
16 /** 
17 * Shortcuts for accessing various debugger preferences. 
18 */ 
19 let Prefs = new ViewHelpers.Prefs("devtools.debugger", { 
20 chromeDebuggingHost: ["Char", "chrome-debugging-host"], 
21 chromeDebuggingPort: ["Int", "chrome-debugging-port"] 
22 }); 
23 
24 let gToolbox, gClient; 
25 
26 function connect() { 
27 window.removeEventListener("load", connect); 
28 // Initiate the connection 
29 let transport = debuggerSocketConnect(
30  Prefs.chromeDebuggingHost, 
31  Prefs.chromeDebuggingPort 
32 ); 
33 gClient = new DebuggerClient(transport); 
34 gClient.connect(() => { 
35  let addonID = getParameterByName("addonID"); 
36 
37  if (addonID) { 
38  gClient.listAddons(({addons}) => { 
39   let addonActor = addons.filter(addon => addon.id === addonID).pop(); 
40   openToolbox({ addonActor: addonActor.actor, title: addonActor.name }); 
41  }); 
42  } else { 
43  gClient.listTabs(openToolbox); 
44  } 
45 }); 
46 } 
47 

Je courais le profil et il ressemble à la pref ..-host est localhost et ..-port est 6080 . Je ne suis pas sûr de savoir comment cela permet de cibler un profil spécifique. Peut-être qu'au démarrage de la boîte à outils du navigateur, il a ouvert le port 6080 au profil d'ouverture. Je ne suis pas sûr, mais si c'est vrai, alors vous devrez exécuter du code depuis le profil cible pour ouvrir un port peut-être.

Totalement pas sûr cependant.

Mais le port est ouvert ici:

http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/ToolboxProcess.jsm#107

106 
107 BrowserToolboxProcess.prototype = { 
108 /** 
109 * Initializes the debugger server. 
110 */ 
111 _initServer: function() { 
112  dumpn("Initializing the chrome toolbox server."); 
113 
114  if (!this.loader) { 
115  // Create a separate loader instance, so that we can be sure to receive a 
116  // separate instance of the DebuggingServer from the rest of the devtools. 
117  // This allows us to safely use the tools against even the actors and 
118  // DebuggingServer itself, especially since we can mark this loader as 
119  // invisible to the debugger (unlike the usual loader settings). 
120  this.loader = new DevToolsLoader(); 
121  this.loader.invisibleToDebugger = true; 
122  this.loader.main("devtools/server/main"); 
123  this.debuggerServer = this.loader.DebuggerServer; 
124  dumpn("Created a separate loader instance for the DebuggerServer."); 
125 
126  // Forward interesting events. 
127  this.debuggerServer.on("connectionchange", this.emit.bind(this)); 
128  } 
129 
130  if (!this.debuggerServer.initialized) { 
131  this.debuggerServer.init(); 
132  this.debuggerServer.addBrowserActors(); 
133  dumpn("initialized and added the browser actors for the DebuggerServer."); 
134  } 
135 
136  this.debuggerServer.openListener(Prefs.chromeDebuggingPort); 
137 
138  dumpn("Finished initializing the chrome toolbox server."); 
139  dumpn("Started listening on port: " + Prefs.chromeDebuggingPort); 
140 }, 
141 
+0

Oh qui ressemble à la façon dont cela fonctionne. Idéalement, je suis à la recherche d'une chose à sens unique, où je ne dois pas exécuter du code à partir de l'autre profil pour permettre la connexion à partir d'un autre. – Noitidart