Skip to content

Commit

Permalink
Add support for reloading the debugger web app by retaining the user …
Browse files Browse the repository at this point in the history
…selected tabids.
  • Loading branch information
johnjbarton committed Jan 31, 2012
1 parent 318360c commit 39d3510
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extension/crxEnd/TabsAdapter.js
Expand Up @@ -93,7 +93,7 @@ TabsAdapter.prototype = {

onRemoved: function(tabId, removeInfo) {
this.barrier(tabId, arguments, function(tabId, removeInfo, index) {
this.windowsAdapter.removeTab(index);
this.windowsAdapter.removeTab(tabId);
this.postMessage({source: this.getPath(), method: 'onRemoved', params:{tabId: tabId, removeInfo: removeInfo}});
});
},
Expand Down
14 changes: 13 additions & 1 deletion extension/crxEnd/WindowsAdapter.js
Expand Up @@ -26,7 +26,10 @@ function WindowsAdapter(origin, debuggerTab) {
this.chromeTabIds = []; // only these tabs can be used by client

// chrome.debugger calls must complete before any other chrome.* calls
this.chromeQueue = [];
this.chromeQueue = [];

// All user selected tabs are accessible to this debugger
WindowsAdapter.userSelectedTabs.forEach(this.addTab.bind(this));

this._bindListeners();
// chrome.window functions available to client WebApps
Expand All @@ -36,6 +39,7 @@ function WindowsAdapter(origin, debuggerTab) {

WindowsAdapter.path = 'chrome.windows';
WindowsAdapter.instanceCounter = 0;
WindowsAdapter.userSelectedTabs = [];

WindowsAdapter.prototype = {

Expand All @@ -52,6 +56,9 @@ WindowsAdapter.prototype = {
},

//------------------------------------------------------------------------------------
addUserSelectedTab: function(tabId) {
WindowsAdapter.userSelectedTabs.push(tabId);
},

isAccessibleTab: function(tabId) {
return (this.chromeTabIds.indexOf(tabId) > -1);
Expand All @@ -62,6 +69,11 @@ WindowsAdapter.prototype = {
},

removeTab: function(tabId) {
var userIndex = WindowsAdapter.userSelectedTabs.indexOf(tabId);
if (userIndex > -1) {
WindowsAdapter.userSelectedTabs.splice(userIndex, 1);
} // else not user selected

var index = this.chromeTabIds.indexOf(tabId);
if (index > -1) {
this.chromeTabIds.splice(index, 1);
Expand Down
2 changes: 1 addition & 1 deletion extension/crxEnd/background.html
Expand Up @@ -81,7 +81,7 @@
if (!windowsAdapter) { // then this origin has not been seen
windowsAdapter = crxEnd.createWindowsAdapter(validOrigin, debuggerTab);
}
windowsAdapter.addTab(debuggeeTabId);
windowsAdapter.addUserSelectedTab(debuggeeTabId);

var url = allowedSite.site + '?tabId=' + debuggeeTabId + '&';
// now release the debugger
Expand Down

0 comments on commit 39d3510

Please sign in to comment.