diff --git a/devtools.gypi b/devtools.gypi index 97666e3eae..f4a0c08f94 100644 --- a/devtools.gypi +++ b/devtools.gypi @@ -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': [ diff --git a/front_end/Runtime.js b/front_end/Runtime.js index a1e681fb33..e79325f04c 100644 --- a/front_end/Runtime.js +++ b/front_end/Runtime.js @@ -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() { @@ -563,11 +573,12 @@ Runtime.prototype = { /** * @param {*} type * @param {?Object=} context + * @param {boolean=} sortByTitle * @return {!Array.} */ - 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 @@ -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); + } }, /** @@ -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"]; } } diff --git a/front_end/animation/AnimationTimeline.js b/front_end/animation/AnimationTimeline.js index 16653bc5de..6db738a7cc 100644 --- a/front_end/animation/AnimationTimeline.js +++ b/front_end/animation/AnimationTimeline.js @@ -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; - } -} diff --git a/front_end/animation/module.json b/front_end/animation/module.json index 236b4762ae..0e03f4751f 100644 --- a/front_end/animation/module.json +++ b/front_end/animation/module.json @@ -1,11 +1,5 @@ { "extensions": [ - { - "type": "@WebInspector.ToolbarItem.Provider", - "className": "WebInspector.AnimationTimeline.ButtonProvider", - "order": 2, - "location": "styles-sidebarpane-toolbar" - }, { "type": "drawer-view", "name": "animations", diff --git a/front_end/components/DOMPresentationUtils.js b/front_end/components/DOMPresentationUtils.js index a299b322c0..2e2a94bc63 100644 --- a/front_end/components/DOMPresentationUtils.js +++ b/front_end/components/DOMPresentationUtils.js @@ -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"]; } diff --git a/front_end/devices/DevicesDialog.js b/front_end/devices/DevicesDialog.js deleted file mode 100644 index 05fdade17b..0000000000 --- a/front_end/devices/DevicesDialog.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * @constructor - */ -WebInspector.DevicesDialog = function() -{ -} - -/** - * @constructor - * @implements {WebInspector.ActionDelegate} - */ -WebInspector.DevicesDialog.ActionDelegate = function() -{ - /** @type {?WebInspector.DevicesView} */ - this._view = null; -} - -WebInspector.DevicesDialog.ActionDelegate.prototype = { - /** - * @override - * @param {!WebInspector.Context} context - * @param {string} actionId - * @return {boolean} - */ - handleAction: function(context, actionId) - { - if (actionId === "devices.dialog.show") { - if (!this._view) - this._view = new WebInspector.DevicesView(); - - var dialog = new WebInspector.Dialog(); - dialog.addCloseButton(); - this._view.show(dialog.element); - dialog.setMaxSize(new Size(700, 500)); - dialog.show(); - return true; - } - return false; - } -} diff --git a/front_end/devices/devicesView.css b/front_end/devices/devicesView.css index e9930d6e54..19cf4761ab 100644 --- a/front_end/devices/devicesView.css +++ b/front_end/devices/devicesView.css @@ -85,6 +85,14 @@ white-space: pre; } +.discovery-view { + overflow: auto; +} + +.discovery-view > * { + flex: none; +} + .usb-checkbox { padding-bottom: 8px; margin-top: 20px; @@ -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 { @@ -206,7 +214,7 @@ flex: auto; overflow: auto; padding-right: 10px; - margin-top: 20px; + margin-top: 30px; } .device-browser-list > div { @@ -273,7 +281,7 @@ } .device-page-url { - margin: 3px 0; + margin: 3px 100px 3px 0; } .device-page-url a { diff --git a/front_end/devices/module.json b/front_end/devices/module.json index 42a7695b5c..f2533274b4 100644 --- a/front_end/devices/module.json +++ b/front_end/devices/module.json @@ -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" diff --git a/front_end/emulation/module.json b/front_end/emulation/module.json index 45c8602090..b1381de573 100644 --- a/front_end/emulation/module.json +++ b/front_end/emulation/module.json @@ -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", diff --git a/front_end/main/Main.js b/front_end/main/Main.js index 8c8748bfb8..1e7cf982fa 100644 --- a/front_end/main/Main.js +++ b/front_end/main/Main.js @@ -57,6 +57,7 @@ WebInspector.Main.prototype = { if (InspectorFrontendHost.isUnderTest()) self.runtime.useTestBase(); + Runtime.setPlatform(WebInspector.platform()); InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this)); }, @@ -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(); } } diff --git a/front_end/main/RenderingOptions.js b/front_end/main/RenderingOptions.js index 83ffccc83e..05914662f7 100644 --- a/front_end/main/RenderingOptions.js +++ b/front_end/main/RenderingOptions.js @@ -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; - } -} diff --git a/front_end/main/module.json b/front_end/main/module.json index 9c4c3090b6..cb9cd42cdd 100644 --- a/front_end/main/module.json +++ b/front_end/main/module.json @@ -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, @@ -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", diff --git a/front_end/network/NetworkConfigView.js b/front_end/network/NetworkConfigView.js index 36ebc177b8..ba8ae54c2d 100644 --- a/front_end/network/NetworkConfigView.js +++ b/front_end/network/NetworkConfigView.js @@ -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; - } -} diff --git a/front_end/network/module.json b/front_end/network/module.json index 63f5ac7939..45e112699f 100644 --- a/front_end/network/module.json +++ b/front_end/network/module.json @@ -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", diff --git a/front_end/screencast/module.json b/front_end/screencast/module.json index 64f46d99e7..e2d451f033 100644 --- a/front_end/screencast/module.json +++ b/front_end/screencast/module.json @@ -14,7 +14,7 @@ { "type": "context-menu-item", "condition": "remoteFrontend", - "location": "mainMenu/tools", + "location": "mainMenu", "order": 10, "actionId": "components.request-app-banner" } diff --git a/front_end/settings/SettingsScreen.js b/front_end/settings/SettingsScreen.js index 38aa0d4138..e4a5580b48 100644 --- a/front_end/settings/SettingsScreen.js +++ b/front_end/settings/SettingsScreen.js @@ -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; diff --git a/front_end/sources/module.json b/front_end/sources/module.json index c9b5685e9a..a6c37c9fa5 100644 --- a/front_end/sources/module.json +++ b/front_end/sources/module.json @@ -150,11 +150,6 @@ "location": "mainMenu/navigate", "actionId": "sources.search.toggle" }, - { - "type": "context-menu-item", - "location": "mainMenu/navigate", - "actionId": "sources.search.toggle" - }, { "type": "context-menu-item", "location": "navigatorMenu/navigate", diff --git a/front_end/ui/ActionRegistry.js b/front_end/ui/ActionRegistry.js index e21053c5e4..afc737b6be 100644 --- a/front_end/ui/ActionRegistry.js +++ b/front_end/ui/ActionRegistry.js @@ -170,7 +170,7 @@ WebInspector.Action.prototype = { */ title: function() { - var title = this._extension.title(WebInspector.platform()); + var title = this._extension.title(); var options = this._extension.descriptor()["options"]; if (options) { for (var pair of options) { diff --git a/front_end/ui/ContextMenu.js b/front_end/ui/ContextMenu.js index b46e31b1d9..c48d5c8701 100644 --- a/front_end/ui/ContextMenu.js +++ b/front_end/ui/ContextMenu.js @@ -171,11 +171,14 @@ WebInspector.ContextSubMenuItem.prototype = { /** * @param {string} label * @param {boolean=} disabled + * @param {string=} subMenuId * @return {!WebInspector.ContextSubMenuItem} */ - appendSubMenuItem: function(label, disabled) + appendSubMenuItem: function(label, disabled, subMenuId) { var item = new WebInspector.ContextSubMenuItem(this._contextMenu, label, disabled); + if (subMenuId) + this._contextMenu._namedSubMenus.set(subMenuId, item); this._pushItem(item); return item; }, @@ -246,7 +249,7 @@ WebInspector.ContextSubMenuItem.prototype = { { var subMenuId = extension.descriptor()["subMenuId"]; if (subMenuId) { - var subMenuItem = menu.appendSubMenuItem(extension.title(WebInspector.platform())); + var subMenuItem = menu.appendSubMenuItem(extension.title(), false, subMenuId); subMenuItem.appendItemsAtLocation(subMenuId); } else { menu.appendAction(extension.descriptor()["actionId"]); @@ -309,6 +312,8 @@ WebInspector.ContextMenu = function(event, useSoftMenu, x, y) this._y = y === undefined ? event.y : y; this._handlers = {}; this._id = 0; + /** @type {!Map} */ + this._namedSubMenus = new Map(); } WebInspector.ContextMenu.initialize = function() @@ -483,6 +488,15 @@ WebInspector.ContextMenu.prototype = { this._pendingTargets.push(target); }, + /** + * @param {string} name + * @return {?WebInspector.ContextSubMenuItem} + */ + namedSubMenu: function(name) + { + return this._namedSubMenus.get(name) || null; + }, + __proto__: WebInspector.ContextSubMenuItem.prototype } diff --git a/front_end/ui/SoftContextMenu.js b/front_end/ui/SoftContextMenu.js index c20310caae..d4aaba33cc 100644 --- a/front_end/ui/SoftContextMenu.js +++ b/front_end/ui/SoftContextMenu.js @@ -391,7 +391,8 @@ WebInspector.SoftContextMenu.prototype = { { if (this._subMenu) this._subMenu._discardSubMenus(); - this.element.remove(); + if (this.element) + this.element.remove(); if (this._parentMenu) delete this._parentMenu._subMenu; } diff --git a/front_end/ui/TabbedPane.js b/front_end/ui/TabbedPane.js index 9f3fb088f7..5ab070652d 100644 --- a/front_end/ui/TabbedPane.js +++ b/front_end/ui/TabbedPane.js @@ -1273,11 +1273,7 @@ WebInspector.ExtensibleTabbedPaneController.prototype = { this._extensions.set(id, extensions[i]); if (this._isPermanentTab(id)) this._appendTab(extensions[i]); - } - - for (var i = 0; i < extensions.length; i++) { - var id = extensions[i].descriptor()["name"]; - if (this._isCloseableTab(id) && this._closeableTabSetting.get()[id]) + else if (this._isCloseableTab(id) && this._closeableTabSetting.get()[id]) this._appendTab(extensions[i]); } }, @@ -1313,13 +1309,10 @@ WebInspector.ExtensibleTabbedPaneController.prototype = { */ _appendTabsToMenu: function(contextMenu) { - for (var id of this._extensions.keysArray().filter(this._isPermanentTab.bind(this))) { - var title = WebInspector.UIString(this._extensions.get(id).title(WebInspector.platform())); - contextMenu.appendItem(title, this.showTab.bind(this, id)); - } - for (var id of this._extensions.keysArray().filter(this._isCloseableTab.bind(this))) { - var title = WebInspector.UIString(this._extensions.get(id).title(WebInspector.platform())); - contextMenu.appendItem(title, this.showTab.bind(this, id)); + var extensions = self.runtime.extensions(this._extensionPoint, undefined, true); + for (var extension of extensions) { + var title = WebInspector.UIString(extension.title()); + contextMenu.appendItem(title, this.showTab.bind(this, extension.descriptor()["name"])); } }, @@ -1330,7 +1323,7 @@ WebInspector.ExtensibleTabbedPaneController.prototype = { { var descriptor = extension.descriptor(); var id = descriptor["name"]; - var title = WebInspector.UIString(extension.title(WebInspector.platform())); + var title = WebInspector.UIString(extension.title()); var closeable = descriptor["persistence"] === "closeable" || descriptor["persistence"] === "temporary"; this._tabbedPane.appendTab(id, title, this._views.get(id) || new WebInspector.Widget(), undefined, false, closeable); }, diff --git a/front_end/ui_lazy/CommandMenu.js b/front_end/ui_lazy/CommandMenu.js index 76bac863e0..39788fa5e4 100644 --- a/front_end/ui_lazy/CommandMenu.js +++ b/front_end/ui_lazy/CommandMenu.js @@ -307,7 +307,7 @@ WebInspector.CommandMenu.createRevealPanelCommand = function(extension) { var panelName = extension.descriptor()["name"]; var tags = extension.descriptor()["tags"] || ""; - return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Panel"), tags, WebInspector.UIString("Show %s", extension.title(WebInspector.platform())), "", executeHandler, availableHandler); + return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Panel"), tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler, availableHandler); /** * @return {boolean} @@ -332,7 +332,7 @@ WebInspector.CommandMenu.createRevealDrawerCommand = function(extension) var drawerId = extension.descriptor()["name"]; var executeHandler = WebInspector.inspectorView.showViewInDrawer.bind(WebInspector.inspectorView, drawerId); var tags = extension.descriptor()["tags"] || ""; - return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Drawer"), tags, WebInspector.UIString("Show %s", extension.title(WebInspector.platform())), "", executeHandler); + return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Drawer"), tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler); } /** @type {!WebInspector.CommandMenu} */