Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js

Issue 2204303003: DevTools: encapsulate extensible tabbed widget into the view manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js b/third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js
index 7f189faccfe3509a661e0bb7015a81abf6249014..1eb800418bd8150b18aa4b88aa0cf357b4b7f635 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js
@@ -1264,194 +1264,3 @@ WebInspector.TabbedPaneTabDelegate.prototype = {
*/
onContextMenu: function(tabId, contextMenu) { }
}
-
-/**
- * @constructor
- * @extends {WebInspector.VBox}
- * @implements {WebInspector.ViewLocation}
- * @param {string} location
- * @param {boolean=} restoreSelection
- */
-WebInspector.ExtensibleTabbedPane = function(location, restoreSelection)
-{
- WebInspector.VBox.call(this);
- this.element.classList.add("flex-auto");
- this._tabbedPane = new WebInspector.TabbedPane();
- this._tabbedPane.show(this.contentElement);
- this._location = location;
- /** @type {!Object.<string, !Promise.<?WebInspector.Widget>>} */
- this._promiseForId = {};
-
- this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
- this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabClosed, this._tabClosed, this);
- this._closeableTabSetting = WebInspector.settings.createSetting(location + "-closeableTabs", {});
- if (restoreSelection)
- this._lastSelectedTabSetting = WebInspector.settings.createSetting(location + "-selectedTab", "");
- this._initialize();
-}
-
-WebInspector.ExtensibleTabbedPane.prototype = {
- /**
- * @return {!WebInspector.TabbedPane}
- */
- tabbedPane: function()
- {
- return this._tabbedPane;
- },
-
- _initialize: function()
- {
- /** @type {!Map.<string, !Runtime.Extension>} */
- this._extensions = new Map();
- var extensions = self.runtime.extensions("view");
-
- for (var i = 0; i < extensions.length; ++i) {
- var location = extensions[i].descriptor()["location"];
- if (location !== this._location)
- continue;
- var id = extensions[i].descriptor()["id"];
- this._extensions.set(id, extensions[i]);
- if (this._isPermanentTab(id))
- this._appendTab(extensions[i]);
- else if (this._isCloseableTab(id) && this._closeableTabSetting.get()[id])
- this._appendTab(extensions[i]);
- }
- },
-
- wasShown: function()
- {
- if (this._wasAlreadyShown || !this._lastSelectedTabSetting)
- return;
- this._wasAlreadyShown = true;
- if (this._tabbedPane.hasTab(this._lastSelectedTabSetting.get()))
- this._tabbedPane.selectTab(this._lastSelectedTabSetting.get());
- },
-
- /**
- * @param {string} id
- * @return {boolean}
- */
- _isPermanentTab: function(id)
- {
- return this._extensions.get(id).descriptor()["persistence"] === "permanent" || !this._extensions.get(id).descriptor()["persistence"];
- },
-
- /**
- * @param {string} id
- * @return {boolean}
- */
- _isCloseableTab: function(id)
- {
- return this._extensions.get(id).descriptor()["persistence"] === "closeable";
- },
-
- enableMoreTabsButton: function()
- {
- var toolbar = new WebInspector.Toolbar("drawer-toolbar");
- toolbar.appendToolbarItem(new WebInspector.ToolbarMenuButton(this._appendTabsToMenu.bind(this)));
- this._tabbedPane.insertBeforeTabStrip(toolbar.element);
- this._tabbedPane.disableOverflowMenu();
- },
-
- /**
- * @param {!WebInspector.ContextMenu} contextMenu
- */
- _appendTabsToMenu: function(contextMenu)
- {
- var extensions = self.runtime.extensions("view", undefined, true);
- for (var extension of extensions) {
- if (extension.descriptor()["location"] !== this._location)
- continue;
- var title = WebInspector.UIString(extension.title());
- contextMenu.appendItem(title, this.showView.bind(this, extension.descriptor()["id"]));
- }
- },
-
- /**
- * @param {!Runtime.Extension} extension
- */
- _appendTab: function(extension)
- {
- var descriptor = extension.descriptor();
- var id = descriptor["id"];
- var title = WebInspector.UIString(extension.title());
- var closeable = descriptor["persistence"] === "closeable" || descriptor["persistence"] === "temporary";
- this._tabbedPane.appendTab(id, title, new WebInspector.Widget(), undefined, false, closeable);
- },
-
- /**
- * @override
- * @param {string} id
- */
- showView: function(id)
- {
- if (!this._tabbedPane.hasTab(id))
- this._appendTab(/** @type {!Runtime.Extension} */(this._extensions.get(id)));
- this._tabbedPane.focus();
- this._tabbedPane.selectTab(id);
- },
-
- /**
- * @param {!WebInspector.Event} event
- */
- _tabSelected: function(event)
- {
- var tabId = /** @type {string} */ (event.data.tabId);
- if (this._lastSelectedTabSetting && event.data["isUserGesture"])
- this._lastSelectedTabSetting.set(tabId);
- if (!this._extensions.has(tabId))
- return;
-
- this._viewForId(tabId);
-
- var descriptor = this._extensions.get(tabId).descriptor();
- if (descriptor["persistence"] === "closeable") {
- var tabs = this._closeableTabSetting.get();
- if (!tabs[tabId]) {
- tabs[tabId] = true;
- this._closeableTabSetting.set(tabs);
- }
- }
- },
-
- /**
- * @param {!WebInspector.Event} event
- */
- _tabClosed: function(event)
- {
- var id = /** @type {string} */ (event.data["tabId"]);
- var tabs = this._closeableTabSetting.get();
- if (tabs[id]) {
- delete tabs[id];
- this._closeableTabSetting.set(tabs);
- }
- delete this._promiseForId[id];
- },
-
- /**
- * @param {string} id
- * @return {!Promise.<?WebInspector.Widget>}
- */
- _viewForId: function(id)
- {
- if (this._promiseForId[id])
- return this._promiseForId[id];
-
- var promise = this._extensions.get(id).instance();
- this._promiseForId[id] = /** @type {!Promise.<?WebInspector.Widget>} */ (promise);
- return promise.then(cacheView.bind(this));
-
- /**
- * @param {!Object} object
- * @this {WebInspector.ExtensibleTabbedPane}
- */
- function cacheView(object)
- {
- var view = /** @type {!WebInspector.Widget} */ (object);
- this._tabbedPane.changeTabView(id, view);
- return view;
- }
- },
-
- __proto__: WebInspector.VBox.prototype
-}

Powered by Google App Engine
This is Rietveld 408576698