Commit 1d4e0280 authored by Arthur Edelstein's avatar Arthur Edelstein
Browse files

Bug #15493: Update circuit display on new circuit info

parent 71a0bba4
......@@ -123,12 +123,15 @@ let getCircuitStatusByID = function* (aController, circuitID) {
return null;
};
// __collectIsolationData(aController)__.
// __collectIsolationData(aController, updateUI)__.
// Watches for STREAM SENTCONNECT events. When a SENTCONNECT event occurs, then
// we assume isolation settings (SOCKS username+password) are now fixed for the
// corresponding circuit. Whenever the first stream on a new circuit is seen,
// looks up u+p and records the node data in the credentialsToNodeDataMap.
let collectIsolationData = function (aController) {
// We need to update the circuit display immediately after any new node data
// is received. So the `updateUI` callback will be called at that point.
// See https://trac.torproject.org/projects/tor/ticket/15493
let collectIsolationData = function (aController, updateUI) {
return aController.watchEvent(
"STREAM",
streamEvent => streamEvent.StreamStatus === "SENTCONNECT",
......@@ -144,6 +147,7 @@ let collectIsolationData = function (aController) {
if (credentials) {
let nodeData = yield nodeDataForCircuit(aController, circuitStatus);
credentialsToNodeDataMap[credentials] = nodeData;
updateUI();
}
}
}).then(null, Cu.reportError));
......@@ -274,32 +278,28 @@ let updateCircuitDisplay = function () {
};
// __syncDisplayWithSelectedTab(syncOn)__.
// We may have multiple tabs, but there is only one instance of TorButton's popup
// panel for displaying the Tor circuit UI. Therefore we need to update the display
// to show the currently selected tab at its current location.
// Whenever the user starts to open the popup menu, make sure the display
// is the correct one for this tab. It's also possible that a new site
// can be loaded while the popup menu is open.
// Update the display if this happens.
let syncDisplayWithSelectedTab = (function() {
let listener1 = event => { updateCircuitDisplay(); },
listener2 = { onLocationChange : function (aBrowser) {
let listener = { onLocationChange : function (aBrowser) {
if (aBrowser === gBrowser.selectedBrowser) {
updateCircuitDisplay();
}
} };
return function (syncOn) {
let popupMenu = document.getElementById("torbutton-context-menu");
if (syncOn) {
// Whenever a different tab is selected, change the circuit display
// to show the circuit for that tab's domain.
gBrowser.tabContainer.addEventListener("TabSelect", listener1);
// Update the circuit display just before the popup menu is shown.
popupMenu.addEventListener("popupshowing", updateCircuitDisplay);
// If the currently selected tab has been sent to a new location,
// update the circuit to reflect that.
gBrowser.addTabsProgressListener(listener2);
// Get started with a correct display.
updateCircuitDisplay();
gBrowser.addTabsProgressListener(listener);
} else {
// Stop syncing.
if (gBrowser.tabContainer) {
gBrowser.tabContainer.removeEventListener("TabSelect", listener1);
}
gBrowser.removeTabsProgressListener(listener2);
gBrowser.removeTabsProgressListener(listener);
popupMenu.removeEventListener("popupshowing", updateCircuitDisplay);
// Hide the display.
showCircuitDisplay(false);
}
......@@ -333,7 +333,7 @@ let setupDisplay = function (host, port, password, enablePrefName) {
stop();
});
syncDisplayWithSelectedTab(true);
stopCollectingIsolationData = collectIsolationData(myController);
stopCollectingIsolationData = collectIsolationData(myController, updateCircuitDisplay);
}
};
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment