Skip to content

Commit

Permalink
DevTools: automatically populate 'More tools' submenu with the drawer…
Browse files Browse the repository at this point in the history
… views.

NOTRY=true
NOPRESUBMIT=true

Committed: https://crrev.com/51a628c40b3f8e25e35bb45f94f9417ff8b7fc37
Review-Url: https://codereview.chromium.org/2137763002
Cr-Original-Commit-Position: refs/heads/master@{#404838}
Cr-Commit-Position: refs/heads/master@{#404849}
  • Loading branch information
pavelfeldman authored and Commit bot committed Jul 12, 2016
1 parent 83d68a9 commit e02009f
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 199 deletions.
1 change: 0 additions & 1 deletion devtools.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@
],
'devtools_devices_js_files': [
'front_end/devices/devicesView.css',
'front_end/devices/DevicesDialog.js',
'front_end/devices/DevicesView.js',
],
'devtools_diff_js_files': [
Expand Down
32 changes: 27 additions & 5 deletions front_end/Runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,16 @@ Runtime._assert = function(value, message)
Runtime._originalAssert.call(Runtime._console, value, message + " " + new Error().stack);
}

Runtime._platform = "";

/**
* @param {string} platform
*/
Runtime.setPlatform = function(platform)
{
Runtime._platform = platform;
}

Runtime.prototype = {
useTestBase: function()
{
Expand Down Expand Up @@ -563,11 +573,12 @@ Runtime.prototype = {
/**
* @param {*} type
* @param {?Object=} context
* @param {boolean=} sortByTitle
* @return {!Array.<!Runtime.Extension>}
*/
extensions: function(type, context)
extensions: function(type, context, sortByTitle)
{
return this._extensions.filter(filter).sort(orderComparator);
return this._extensions.filter(filter).sort(sortByTitle ? titleComparator : orderComparator);

/**
* @param {!Runtime.Extension} extension
Expand All @@ -593,6 +604,18 @@ Runtime.prototype = {
var order2 = extension2.descriptor()["order"] || 0;
return order1 - order2;
}

/**
* @param {!Runtime.Extension} extension1
* @param {!Runtime.Extension} extension2
* @return {number}
*/
function titleComparator(extension1, extension2)
{
var title1 = extension1.title() || "";
var title2 = extension2.title() || "";
return title1.localeCompare(title2);
}
},

/**
Expand Down Expand Up @@ -978,13 +1001,12 @@ Runtime.Extension.prototype = {
},

/**
* @param {string} platform
* @return {string}
*/
title: function(platform)
title: function()
{
// FIXME: should be WebInspector.UIString() but runtime is not l10n aware yet.
return this._descriptor["title-" + platform] || this._descriptor["title"];
return this._descriptor["title-" + Runtime._platform] || this._descriptor["title"];
}
}

Expand Down
26 changes: 0 additions & 26 deletions front_end/animation/AnimationTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,29 +758,3 @@ WebInspector.AnimationTimeline.StepTimingFunction.parse = function(text) {
return new WebInspector.AnimationTimeline.StepTimingFunction(parseInt(match[1], 10), match[2]);
return null;
}

/**
* @constructor
* @implements {WebInspector.ToolbarItem.Provider}
*/
WebInspector.AnimationTimeline.ButtonProvider = function()
{
this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Animations"), "animation-toolbar-item");
this._button.addEventListener("click", this._clicked, this);
}

WebInspector.AnimationTimeline.ButtonProvider.prototype = {
_clicked: function()
{
WebInspector.inspectorView.showViewInDrawer("animations");
},

/**
* @override
* @return {!WebInspector.ToolbarItem}
*/
item: function()
{
return this._button;
}
}
6 changes: 0 additions & 6 deletions front_end/animation/module.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"extensions": [
{
"type": "@WebInspector.ToolbarItem.Provider",
"className": "WebInspector.AnimationTimeline.ButtonProvider",
"order": 2,
"location": "styles-sidebarpane-toolbar"
},
{
"type": "drawer-view",
"name": "animations",
Expand Down
2 changes: 1 addition & 1 deletion front_end/components/DOMPresentationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ WebInspector.DOMPresentationUtils.MarkerDecorator.prototype = {
*/
WebInspector.DOMPresentationUtils.GenericDecorator = function(extension)
{
this._title = WebInspector.UIString(extension.title(WebInspector.platform()));
this._title = WebInspector.UIString(extension.title());
this._color = extension.descriptor()["color"];
}

Expand Down
44 changes: 0 additions & 44 deletions front_end/devices/DevicesDialog.js

This file was deleted.

14 changes: 11 additions & 3 deletions front_end/devices/devicesView.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
white-space: pre;
}

.discovery-view {
overflow: auto;
}

.discovery-view > * {
flex: none;
}

.usb-checkbox {
padding-bottom: 8px;
margin-top: 20px;
Expand Down Expand Up @@ -113,7 +121,7 @@
.port-forwarding-list {
margin: 10px 0 0 25px;
max-width: 500px;
flex: 0 1 auto;
flex: none;
}

.port-forwarding-list-empty {
Expand Down Expand Up @@ -206,7 +214,7 @@
flex: auto;
overflow: auto;
padding-right: 10px;
margin-top: 20px;
margin-top: 30px;
}

.device-browser-list > div {
Expand Down Expand Up @@ -273,7 +281,7 @@
}

.device-page-url {
margin: 3px 0;
margin: 3px 100px 3px 0;
}

.device-page-url a {
Expand Down
19 changes: 7 additions & 12 deletions front_end/devices/module.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{
"extensions": [
{
"type": "@WebInspector.ActionDelegate",
"category": "Mobile",
"actionId": "devices.dialog.show",
"className": "WebInspector.DevicesDialog.ActionDelegate",
"title": "Inspect devices\u2026"
},
{
"type": "context-menu-item",
"location": "mainMenu/tools/open",
"type": "drawer-view",
"name": "remote-devices",
"title": "Remote devices",
"persistence": "closeable",
"order": 50,
"actionId": "devices.dialog.show"
"className": "WebInspector.DevicesView",
"tags": "usb, android, mobile"
}
],
"dependencies": ["platform", "ui", "host", "components"],
"scripts": [
"DevicesView.js",
"DevicesDialog.js"
"DevicesView.js"
],
"resources": [
"devicesView.css"
Expand Down
6 changes: 0 additions & 6 deletions front_end/emulation/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@
"title": "Sensors",
"className": "WebInspector.SensorsView.ShowActionDelegate"
},
{
"type": "context-menu-item",
"location": "mainMenu/tools/open",
"order": 100,
"actionId": "emulation.show-sensors"
},
{
"type": "drawer-view",
"name": "sensors",
Expand Down
8 changes: 8 additions & 0 deletions front_end/main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ WebInspector.Main.prototype = {

if (InspectorFrontendHost.isUnderTest())
self.runtime.useTestBase();
Runtime.setPlatform(WebInspector.platform());
InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this));
},

Expand Down Expand Up @@ -883,6 +884,13 @@ WebInspector.Main.MainMenuItem.prototype = {

contextMenu.appendAction("main.toggle-drawer", WebInspector.inspectorView.drawerVisible() ? WebInspector.UIString("Hide console") : WebInspector.UIString("Show console"));
contextMenu.appendItemsAtLocation("mainMenu");
var moreTools = contextMenu.namedSubMenu("mainMenuMoreTools");
var extensions = self.runtime.extensions("drawer-view", undefined, true);
for (var extension of extensions) {
var descriptor = extension.descriptor();
moreTools.appendItem(extension.title(), WebInspector.inspectorView.showViewInDrawer.bind(WebInspector.inspectorView, descriptor["name"]));
}

contextMenu.show();
}
}
Expand Down
22 changes: 0 additions & 22 deletions front_end/main/RenderingOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,3 @@ WebInspector.RenderingOptionsView.instance = function()
WebInspector.RenderingOptionsView._instanceObject = new WebInspector.RenderingOptionsView();
return WebInspector.RenderingOptionsView._instanceObject;
}

/**
* @constructor
* @implements {WebInspector.ActionDelegate}
*/
WebInspector.RenderingOptionsView.ShowActionDelegate = function()
{
}

WebInspector.RenderingOptionsView.ShowActionDelegate.prototype = {
/**
* @override
* @param {!WebInspector.Context} context
* @param {string} actionId
* @return {boolean}
*/
handleAction: function(context, actionId)
{
WebInspector.inspectorView.showViewInDrawer("rendering");
return true;
}
}
14 changes: 1 addition & 13 deletions front_end/main/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@
}
]
},
{
"type": "@WebInspector.ActionDelegate",
"actionId": "main.show-rendering-options",
"title": "Rendering settings",
"className": "WebInspector.RenderingOptionsView.ShowActionDelegate"
},
{
"type": "@WebInspector.ToolbarItem.Provider",
"separator": true,
Expand Down Expand Up @@ -321,15 +315,9 @@
"type": "context-menu-item",
"location": "mainMenu/navigate",
"title": "More tools",
"subMenuId": "mainMenu/tools",
"subMenuId": "mainMenuMoreTools",
"order": 80
},
{
"type": "context-menu-item",
"location": "mainMenu/tools/open",
"order": 80,
"actionId": "main.show-rendering-options"
},
{
"type": "drawer-view",
"name": "rendering",
Expand Down
22 changes: 0 additions & 22 deletions front_end/network/NetworkConfigView.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,3 @@ WebInspector.NetworkConfigView._userAgentGroups = [
]
}
]

/**
* @constructor
* @implements {WebInspector.ActionDelegate}
*/
WebInspector.NetworkConfigView.ShowActionDelegate = function()
{
}

WebInspector.NetworkConfigView.ShowActionDelegate.prototype = {
/**
* @override
* @param {!WebInspector.Context} context
* @param {string} actionId
* @return {boolean}
*/
handleAction: function(context, actionId)
{
WebInspector.inspectorView.showViewInDrawer("network.config");
return true;
}
}
12 changes: 0 additions & 12 deletions front_end/network/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@
"className": "WebInspector.BlockedURLsPane",
"experiment": "requestBlocking"
},
{
"type": "@WebInspector.ActionDelegate",
"actionId": "network.show-config",
"title": "Network conditions",
"className": "WebInspector.NetworkConfigView.ShowActionDelegate"
},
{
"type": "context-menu-item",
"location": "mainMenu/tools/open",
"order": 60,
"actionId": "network.show-config"
},
{
"type": "drawer-view",
"name": "network.config",
Expand Down
2 changes: 1 addition & 1 deletion front_end/screencast/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"type": "context-menu-item",
"condition": "remoteFrontend",
"location": "mainMenu/tools",
"location": "mainMenu",
"order": 10,
"actionId": "components.request-app-banner"
}
Expand Down
2 changes: 1 addition & 1 deletion front_end/settings/SettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ WebInspector.GenericSettingsTab.prototype = {
var sectionName = descriptor["category"];
var settingName = descriptor["settingName"];
var setting = WebInspector.moduleSetting(settingName);
var uiTitle = WebInspector.UIString(extension.title(WebInspector.platform()));
var uiTitle = WebInspector.UIString(extension.title());

var sectionElement = this._sectionElement(sectionName);
var settingControl;
Expand Down
Loading

0 comments on commit e02009f

Please sign in to comment.