Skip to content

Commit 4e39f20

Browse files
committed
Added tab groups. Fixed splicing error.
1 parent 06379d4 commit 4e39f20

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,8 @@
266266
},
267267
"focusOnBreakpoint": {
268268
"message": "Focus on Debugger Paused"
269+
},
270+
"groupInspectorTabs": {
271+
"message": "Group Inspector Tabs"
269272
}
270273
}

background.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ ngApp
770770
maxMessages: 10
771771
},
772772
autoResumeInspectBrk: false,
773-
focusOnBreakpoint: false
773+
focusOnBreakpoint: false,
774+
group: true
774775
};
775776
$scope.remoteConnectionSettings = {};
776777
$scope.Auth = new Auth();
@@ -783,7 +784,7 @@ ngApp
783784
* Todo: write a failsafe to prevent that condition too!
784785
*/
785786
{ 'id': '0', 'name': 'default', 'url': $scope.settings.scheme + 'devtools/bundled/inspector.html', 'selected': true },
786-
{ 'id': '1', 'name': 'appspot', 'url': 'https://chrome-devtools-frontend.appspot.com/serve_file/@548c459fb7741b83bd517b12882f533b04a5513e/inspector.html' },
787+
{ 'id': '1', 'name': 'appspot', 'url': 'https://chrome-devtools-frontend.brakecode.com/inspector.html' },
787788
{ 'id': '2', 'name': 'june07', 'url': 'https://chrome-devtools-frontend.june07.com/front_end/inspector.html' },
788789
{ 'id': '3', 'name': 'custom', 'url': '' },
789790
];
@@ -1640,6 +1641,32 @@ ngApp
16401641
saveSession(url, infoUrl, websocketId, tab.id, nodeInspectMetadataJSON, dtpSocket);
16411642
resolve(tab);
16421643
});
1644+
if ($scope.settings.group && $scope.devToolsSessions.length > 0) {
1645+
let mapped = $scope.devToolsSessions.map(session => {
1646+
return new Promise(resolve => {
1647+
chrome.tabs.get(session.id, tab => resolve({ tabId: tab.id, groupId: tab.groupId }))
1648+
})
1649+
})
1650+
Promise.all(mapped)
1651+
.then(currentSessions => {
1652+
let ungroupedSessions = currentSessions
1653+
.filter(session => session.groupId == -1)
1654+
.map(session => session.tabId)
1655+
1656+
currentSessions = currentSessions.filter(session => session.groupId !== -1)
1657+
let firstGroupId = currentSessions.length > 0 ? currentSessions[0].groupId : -1
1658+
if (currentSessions.length > 0) {
1659+
chrome.tabs.group({ tabIds: tab.id, groupId: firstGroupId }, groupId => {
1660+
console.log(`Added tab to existing group ${groupId}`)
1661+
})
1662+
} else {
1663+
ungroupedSessions.push(tab.id)
1664+
chrome.tabs.group({ tabIds: ungroupedSessions }, groupId => {
1665+
console.log(`Added tab to new group ${groupId}`)
1666+
})
1667+
}
1668+
})
1669+
}
16431670
});
16441671
}
16451672
});
@@ -2086,15 +2113,16 @@ ngApp
20862113
});
20872114
chrome.tabs.onRemoved.addListener(function chromeTabsRemovedEvent(tabId) {
20882115
$window._gaq.push(['_trackEvent', 'Program Event', 'onRemoved', undefined, undefined, true]);
2089-
// Why am I not calling deleteSession() here?
2090-
$scope.devToolsSessions.splice($scope.devToolsSessions.findIndex(function(devToolsSession) {
2116+
let index = $scope.devToolsSessions.findIndex(function(devToolsSession) {
20912117
if (devToolsSession.id === tabId) {
20922118
// Tab removal doesn't mean that the debugging session is dead. So the socket should not be closed.
20932119
//$scope.devToolsProtocolClient.closeSocket(devToolsSession.dtpSocket);
20942120
unlock(hostPortHashmap(tabId));
20952121
return true;
20962122
}
2097-
}), 1);
2123+
})
2124+
// Why am I not calling deleteSession() here?
2125+
if (index >= 0) $scope.devToolsSessions.splice(index, 1);
20982126
});
20992127
chrome.tabs.onActivated.addListener(function chromeTabsActivatedEvent(tabId) {
21002128
resolveTabPromise(tabId);

options.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@
100100
</div>
101101
<span class="i18n">autoCloseInspector</span>
102102
</li>
103+
<li class="collection-item">
104+
<div class="switch right">
105+
<label><span class="i18n">off</span>
106+
<input type="checkbox" ng-model="bg.settings.group" id="Group Inspector Tabs" class="ga-track">
107+
<span class="lever"></span><span class="i18n">on</span>
108+
</label>
109+
</div>
110+
<span class="i18n">groupInspectorTabs</span>
111+
</li>
103112
<li class="collection-item">
104113
<div class="switch right">
105114
<label><span class="i18n">off</span>

0 commit comments

Comments
 (0)