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

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

Issue 2205123003: DevTools: introduce view locations, allow opening views by id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fixed 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 /** 1261 /**
1262 * @param {string} tabId 1262 * @param {string} tabId
1263 * @param {!WebInspector.ContextMenu} contextMenu 1263 * @param {!WebInspector.ContextMenu} contextMenu
1264 */ 1264 */
1265 onContextMenu: function(tabId, contextMenu) { } 1265 onContextMenu: function(tabId, contextMenu) { }
1266 } 1266 }
1267 1267
1268 /** 1268 /**
1269 * @constructor 1269 * @constructor
1270 * @extends {WebInspector.VBox} 1270 * @extends {WebInspector.VBox}
1271 * @implements {WebInspector.ViewLocation}
1271 * @param {string} location 1272 * @param {string} location
1272 * @param {boolean=} restoreSelection 1273 * @param {boolean=} restoreSelection
1273 */ 1274 */
1274 WebInspector.ExtensibleTabbedPane = function(location, restoreSelection) 1275 WebInspector.ExtensibleTabbedPane = function(location, restoreSelection)
1275 { 1276 {
1276 WebInspector.VBox.call(this); 1277 WebInspector.VBox.call(this);
1277 this.element.classList.add("flex-auto"); 1278 this.element.classList.add("flex-auto");
1278 this._tabbedPane = new WebInspector.TabbedPane(); 1279 this._tabbedPane = new WebInspector.TabbedPane();
1279 this._tabbedPane.show(this.contentElement); 1280 this._tabbedPane.show(this.contentElement);
1280 this._location = location; 1281 this._location = location;
(...skipping 20 matching lines...) Expand all
1301 _initialize: function() 1302 _initialize: function()
1302 { 1303 {
1303 /** @type {!Map.<string, !Runtime.Extension>} */ 1304 /** @type {!Map.<string, !Runtime.Extension>} */
1304 this._extensions = new Map(); 1305 this._extensions = new Map();
1305 var extensions = self.runtime.extensions("view"); 1306 var extensions = self.runtime.extensions("view");
1306 1307
1307 for (var i = 0; i < extensions.length; ++i) { 1308 for (var i = 0; i < extensions.length; ++i) {
1308 var location = extensions[i].descriptor()["location"]; 1309 var location = extensions[i].descriptor()["location"];
1309 if (location !== this._location) 1310 if (location !== this._location)
1310 continue; 1311 continue;
1311 var id = extensions[i].descriptor()["name"]; 1312 var id = extensions[i].descriptor()["id"];
1312 this._extensions.set(id, extensions[i]); 1313 this._extensions.set(id, extensions[i]);
1313 if (this._isPermanentTab(id)) 1314 if (this._isPermanentTab(id))
1314 this._appendTab(extensions[i]); 1315 this._appendTab(extensions[i]);
1315 else if (this._isCloseableTab(id) && this._closeableTabSetting.get() [id]) 1316 else if (this._isCloseableTab(id) && this._closeableTabSetting.get() [id])
1316 this._appendTab(extensions[i]); 1317 this._appendTab(extensions[i]);
1317 } 1318 }
1318 }, 1319 },
1319 1320
1320 wasShown: function() 1321 wasShown: function()
1321 { 1322 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 /** 1356 /**
1356 * @param {!WebInspector.ContextMenu} contextMenu 1357 * @param {!WebInspector.ContextMenu} contextMenu
1357 */ 1358 */
1358 _appendTabsToMenu: function(contextMenu) 1359 _appendTabsToMenu: function(contextMenu)
1359 { 1360 {
1360 var extensions = self.runtime.extensions("view", undefined, true); 1361 var extensions = self.runtime.extensions("view", undefined, true);
1361 for (var extension of extensions) { 1362 for (var extension of extensions) {
1362 if (extension.descriptor()["location"] !== this._location) 1363 if (extension.descriptor()["location"] !== this._location)
1363 continue; 1364 continue;
1364 var title = WebInspector.UIString(extension.title()); 1365 var title = WebInspector.UIString(extension.title());
1365 contextMenu.appendItem(title, this.showTab.bind(this, extension.desc riptor()["name"])); 1366 contextMenu.appendItem(title, this.showView.bind(this, extension.des criptor()["id"]));
1366 } 1367 }
1367 }, 1368 },
1368 1369
1369 /** 1370 /**
1370 * @param {!Runtime.Extension} extension 1371 * @param {!Runtime.Extension} extension
1371 */ 1372 */
1372 _appendTab: function(extension) 1373 _appendTab: function(extension)
1373 { 1374 {
1374 var descriptor = extension.descriptor(); 1375 var descriptor = extension.descriptor();
1375 var id = descriptor["name"]; 1376 var id = descriptor["id"];
1376 var title = WebInspector.UIString(extension.title()); 1377 var title = WebInspector.UIString(extension.title());
1377 var closeable = descriptor["persistence"] === "closeable" || descriptor[ "persistence"] === "temporary"; 1378 var closeable = descriptor["persistence"] === "closeable" || descriptor[ "persistence"] === "temporary";
1378 this._tabbedPane.appendTab(id, title, new WebInspector.Widget(), undefin ed, false, closeable); 1379 this._tabbedPane.appendTab(id, title, new WebInspector.Widget(), undefin ed, false, closeable);
1379 }, 1380 },
1380 1381
1381 /** 1382 /**
1383 * @override
1382 * @param {string} id 1384 * @param {string} id
1383 */ 1385 */
1384 showTab: function(id) 1386 showView: function(id)
1385 { 1387 {
1386 if (!this._tabbedPane.hasTab(id)) 1388 if (!this._tabbedPane.hasTab(id))
1387 this._appendTab(/** @type {!Runtime.Extension} */(this._extensions.g et(id))); 1389 this._appendTab(/** @type {!Runtime.Extension} */(this._extensions.g et(id)));
1390 this._tabbedPane.focus();
1388 this._tabbedPane.selectTab(id); 1391 this._tabbedPane.selectTab(id);
1389 }, 1392 },
1390 1393
1391 /** 1394 /**
1392 * @param {!WebInspector.Event} event 1395 * @param {!WebInspector.Event} event
1393 */ 1396 */
1394 _tabSelected: function(event) 1397 _tabSelected: function(event)
1395 { 1398 {
1396 var tabId = /** @type {string} */ (event.data.tabId); 1399 var tabId = /** @type {string} */ (event.data.tabId);
1397 if (this._lastSelectedTabSetting && event.data["isUserGesture"]) 1400 if (this._lastSelectedTabSetting && event.data["isUserGesture"])
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 function cacheView(object) 1448 function cacheView(object)
1446 { 1449 {
1447 var view = /** @type {!WebInspector.Widget} */ (object); 1450 var view = /** @type {!WebInspector.Widget} */ (object);
1448 this._tabbedPane.changeTabView(id, view); 1451 this._tabbedPane.changeTabView(id, view);
1449 return view; 1452 return view;
1450 } 1453 }
1451 }, 1454 },
1452 1455
1453 __proto__: WebInspector.VBox.prototype 1456 __proto__: WebInspector.VBox.prototype
1454 } 1457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698