Commit dc50caf6 authored by rchlodnicki's avatar rchlodnicki Committed by Commit bot

[net-internals] Fix JS exception on stopping capturing while in Capture view

Store a map of link enabled states so that we can use it to enable next
visibile view on hidding active view. Map is ordered so it works to iterate it.

BUG=616382
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2121763002
Cr-Commit-Position: refs/heads/master@{#405942}
parent 1f909cea
...@@ -31,8 +31,8 @@ var TabSwitcherView = (function() { ...@@ -31,8 +31,8 @@ var TabSwitcherView = (function() {
this.tabIdToView_ = {}; this.tabIdToView_ = {};
this.tabIdToLink_ = {}; this.tabIdToLink_ = {};
// Ordered list of views. // Map from tab id to the views link visiblity.
this.viewList_ = []; this.tabIdsLinkVisibility_ = new Map();
this.activeTabId_ = null; this.activeTabId_ = null;
this.onTabSwitched_ = opt_onTabSwitched; this.onTabSwitched_ = opt_onTabSwitched;
...@@ -98,7 +98,7 @@ var TabSwitcherView = (function() { ...@@ -98,7 +98,7 @@ var TabSwitcherView = (function() {
} }
this.tabIdToView_[tabId] = view; this.tabIdToView_[tabId] = view;
this.viewList_.push(view); this.tabIdsLinkVisibility_.set(tabId, true);
var node = addNodeWithText($(TAB_LIST_ID), 'a', name); var node = addNodeWithText($(TAB_LIST_ID), 'a', name);
node.href = hash; node.href = hash;
...@@ -115,13 +115,16 @@ var TabSwitcherView = (function() { ...@@ -115,13 +115,16 @@ var TabSwitcherView = (function() {
var wasActive = this.activeTabId_ == tabId; var wasActive = this.activeTabId_ == tabId;
setNodeDisplay(this.tabIdToLink_[tabId], isVisible); setNodeDisplay(this.tabIdToLink_[tabId], isVisible);
this.tabIdsLinkVisibility_.set(tabId, isVisible);
if (wasActive && !isVisible) { if (wasActive && !isVisible) {
// If the link for active tab is being hidden, then switch to the first // If the link for active tab is being hidden, then switch to the first
// tab which is still visible. // tab which is still visible.
for (var view in this.viewList_) { for (var [localTabId, enabled] of this.tabIdsLinkVisibility_) {
if (view.isVisible()) if (enabled) {
this.switchToTab(option.value); this.switchToTab(localTabId);
break;
}
} }
} }
}, },
......
Markdown is supported
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