Commit 868a741e authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: introduce dedicated module for node front-end, get rid of nodeFrontend flag.

Change-Id: I87dcf0326403df335e2331d97f8182384c124d59
Reviewed-on: https://chromium-review.googlesource.com/903545
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534659}
parent 408acd92
......@@ -84,6 +84,8 @@ base::LazyInstance<std::vector<base::Callback<void(DevToolsWindow*)>>>::Leaky
static const char kKeyUpEventName[] = "keyup";
static const char kKeyDownEventName[] = "keydown";
static const char kNodeFrontendURL[] =
"chrome-devtools://devtools/bundled/node_app.html";
bool FindInspectedBrowserAndTabIndex(
WebContents* inspected_web_contents, Browser** browser, int* tab) {
......@@ -988,8 +990,12 @@ GURL DevToolsWindow::GetDevToolsURL(Profile* profile,
bool can_dock,
const std::string& panel,
bool has_other_clients) {
std::string url(!frontend_url.empty() ? frontend_url
: chrome::kChromeUIDevToolsURL);
std::string url = frontend_url;
if (url.empty()) {
url = frontend_type == kFrontendNode ? kNodeFrontendURL
: chrome::kChromeUIDevToolsURL;
}
std::string url_string(url +
((url.find("?") == std::string::npos) ? "?" : "&"));
switch (frontend_type) {
......@@ -999,9 +1005,6 @@ GURL DevToolsWindow::GetDevToolsURL(Profile* profile,
case kFrontendWorker:
url_string += "&isSharedWorker=true";
break;
case kFrontendNode:
url_string += "&nodeFrontend=true";
FALLTHROUGH;
case kFrontendV8:
url_string += "&v8only=true";
break;
......
......@@ -408,6 +408,7 @@ all_devtools_files = [
"front_end/network_test_runner/ProductRegistryTestRunner.js",
"front_end/node_main/NodeConnectionsPanel.js",
"front_end/node_main/nodeConnectionsPanel.css",
"front_end/node_main/NodeMain.js",
"front_end/node_main/module.json",
"front_end/object_ui/customPreviewComponent.css",
"front_end/object_ui/CustomPreviewComponent.js",
......@@ -941,14 +942,16 @@ generated_scripts = [
]
generated_applications = [
"$resources_out_dir/shell.js",
"$resources_out_dir/audits2_worker.js",
"$resources_out_dir/formatter_worker.js",
"$resources_out_dir/heap_snapshot_worker.js",
"$resources_out_dir/inspector.html",
"$resources_out_dir/inspector.js",
"$resources_out_dir/node_app.html",
"$resources_out_dir/node_app.js",
"$resources_out_dir/shell.js",
"$resources_out_dir/toolbox.html",
"$resources_out_dir/toolbox.js",
"$resources_out_dir/audits2_worker.js",
"$resources_out_dir/formatter_worker.js",
"$resources_out_dir/heap_snapshot_worker.js",
]
generated_non_autostart_non_remote_modules = [
......@@ -973,7 +976,6 @@ generated_non_autostart_non_remote_modules = [
"$resources_out_dir/layer_viewer/layer_viewer_module.js",
"$resources_out_dir/layers/layers_module.js",
"$resources_out_dir/network/network_module.js",
"$resources_out_dir/node_main/node_main_module.js",
"$resources_out_dir/object_ui/object_ui_module.js",
"$resources_out_dir/perf_ui/perf_ui_module.js",
"$resources_out_dir/profiler/profiler_module.js",
......@@ -1011,6 +1013,7 @@ devtools_applications = [
"audits2_worker",
"heap_snapshot_worker",
"ndb",
"node_app",
]
#-------------------------------------------------------------------------------
......@@ -1148,9 +1151,10 @@ action("build_release_devtools") {
inputs = helper_scripts + all_devtools_files + generated_scripts + [
"front_end/inspector.html",
"front_end/toolbox.html",
"front_end/ndb.html",
"front_end/integration_test_runner.html",
"front_end/node_app.html",
"front_end/ndb.html",
"front_end/toolbox.html",
]
outputs = generated_resources + generated_remote_modules
......@@ -1175,16 +1179,18 @@ if (debug_devtools) {
inputs = all_devtools_files + [
"front_end/inspector.html",
"front_end/toolbox.html",
"front_end/ndb.html",
"front_end/integration_test_runner.html",
"front_end/ndb.html",
"front_end/node_app.html",
"front_end/toolbox.html",
]
outputs = [
"$resources_out_debug_dir/inspector.html",
"$resources_out_debug_dir/toolbox.html",
"$resources_out_debug_dir/ndb.html",
"$resources_out_debug_dir/integration_test_runner.html",
"$resources_out_debug_dir/ndb.html",
"$resources_out_debug_dir/node_app.html",
"$resources_out_debug_dir/toolbox.html",
]
args = devtools_applications + [
......
......@@ -15,7 +15,6 @@
{ "name": "layers", "condition": "!v8only" },
{ "name": "layer_viewer", "condition": "!v8only" },
{ "name": "network", "condition": "!v8only" },
{ "name": "node_main", "condition": "nodeFrontend" },
{ "name": "product_registry_impl", "condition": "!v8only", "type": "remote" },
{ "name": "resources", "condition": "!v8only" },
{ "name": "screencast", "condition": "remoteFrontend", "type": "remote" },
......
......@@ -25,17 +25,13 @@ InspectorMain.InspectorMain = class extends Common.Object {
}
_connectAndCreateMainTarget() {
if (Runtime.queryParam('nodeFrontend'))
Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFrontend);
else if (Runtime.queryParam('v8only'))
if (Runtime.queryParam('v8only'))
Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSDirectly);
var target = SDK.targetManager.createTarget(
'main', Common.UIString('Main'), this._capabilitiesForMainTarget(), this._createMainConnection.bind(this),
null);
if (Runtime.queryParam('nodeFrontend'))
target.setInspectedURL('Node.js');
if (target.hasJSCapability())
target.runtimeAgent().runIfWaitingForDebugger();
}
......@@ -44,9 +40,6 @@ InspectorMain.InspectorMain = class extends Common.Object {
* @return {number}
*/
_capabilitiesForMainTarget() {
if (Runtime.queryParam('nodeFrontend'))
return SDK.Target.Capability.Target;
if (Runtime.queryParam('isSharedWorker')) {
return SDK.Target.Capability.Browser | SDK.Target.Capability.Inspector | SDK.Target.Capability.Log |
SDK.Target.Capability.Network | SDK.Target.Capability.Target;
......@@ -292,130 +285,7 @@ InspectorMain.BrowserChildTargetManager = class extends SDK.SDKModel {
InspectorMain.BrowserChildTargetManager._lastAnonymousTargetId = 0;
/**
* @implements {Protocol.TargetDispatcher}
*/
InspectorMain.NodeChildTargetManager = class extends SDK.SDKModel {
/**
* @param {!SDK.Target} parentTarget
*/
constructor(parentTarget) {
super(parentTarget);
this._targetManager = parentTarget.targetManager();
this._parentTarget = parentTarget;
this._targetAgent = parentTarget.targetAgent();
/** @type {!Map<string, !SDK.ChildConnection>} */
this._childConnections = new Map();
parentTarget.registerTargetDispatcher(this);
this._targetAgent.setDiscoverTargets(true);
InspectorFrontendHost.setDevicesUpdatesEnabled(true);
InspectorFrontendHost.events.addEventListener(
InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
}
/**
* @param {!Common.Event} event
*/
_devicesDiscoveryConfigChanged(event) {
var config = /** @type {!Adb.Config} */ (event.data);
var locations = [];
for (var address of config.networkDiscoveryConfig) {
var parts = address.split(':');
var port = parseInt(parts[1], 10);
if (parts[0] && port)
locations.push({host: parts[0], port: port});
}
this._targetAgent.setRemoteLocations(locations);
}
/**
* @override
*/
dispose() {
InspectorFrontendHost.events.removeEventListener(
InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
for (var sessionId of this._childConnections.keys())
this.detachedFromTarget(sessionId, undefined);
}
/**
* @override
* @param {!Protocol.Target.TargetInfo} targetInfo
*/
targetCreated(targetInfo) {
if (targetInfo.type === 'node' && !targetInfo.attached)
this._targetAgent.attachToTarget(targetInfo.targetId);
}
/**
* @override
* @param {!Protocol.Target.TargetInfo} targetInfo
*/
targetInfoChanged(targetInfo) {
}
/**
* @override
* @param {string} targetId
*/
targetDestroyed(targetId) {
}
/**
* @override
* @param {string} sessionId
* @param {!Protocol.Target.TargetInfo} targetInfo
* @param {boolean} waitingForDebugger
*/
attachedToTarget(sessionId, targetInfo, waitingForDebugger) {
var target = this._targetManager.createTarget(
targetInfo.targetId, Common.UIString('Node.js: %s', targetInfo.url), SDK.Target.Capability.JS,
this._createChildConnection.bind(this, this._targetAgent, sessionId), this._parentTarget);
target.runtimeAgent().runIfWaitingForDebugger();
}
/**
* @override
* @param {string} sessionId
* @param {string=} childTargetId
*/
detachedFromTarget(sessionId, childTargetId) {
this._childConnections.get(sessionId).onDisconnect.call(null, 'target terminated');
this._childConnections.delete(sessionId);
}
/**
* @override
* @param {string} sessionId
* @param {string} message
* @param {string=} childTargetId
*/
receivedMessageFromTarget(sessionId, message, childTargetId) {
var connection = this._childConnections.get(sessionId);
if (connection)
connection.onMessage.call(null, message);
}
/**
* @param {!Protocol.TargetAgent} agent
* @param {string} sessionId
* @param {!Protocol.InspectorBackend.Connection.Params} params
* @return {!Protocol.InspectorBackend.Connection}
*/
_createChildConnection(agent, sessionId, params) {
var connection = new SDK.ChildConnection(agent, sessionId, params);
this._childConnections.set(sessionId, connection);
return connection;
}
};
if (Runtime.queryParam('nodeFrontend'))
SDK.SDKModel.register(InspectorMain.NodeChildTargetManager, SDK.Target.Capability.Target, true);
else
SDK.SDKModel.register(InspectorMain.BrowserChildTargetManager, SDK.Target.Capability.Target, true);
SDK.SDKModel.register(InspectorMain.BrowserChildTargetManager, SDK.Target.Capability.Target, true);
/**
* @implements {Protocol.InspectorDispatcher}
......
......@@ -47,8 +47,7 @@
"type": "@UI.ToolbarItem.Provider",
"className": "InspectorMain.NodeIndicator",
"order": 2,
"location": "main-toolbar-left",
"condition": "!nodeFrontend"
"location": "main-toolbar-left"
},
{
"type": "setting",
......
<!--
* Copyright 2018 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.
-->
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
<meta name="referrer" content="no-referrer">
<script type="text/javascript" src="Runtime.js"></script>
<script type="text/javascript" src="node_app.js"></script>
</head>
<body class="undocked" id="-blink-dev-tools"></body>
</html>
// Copyright 2018 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.
Runtime.startApplication('node_app');
{
"modules" : [
{ "name": "node_main", "type": "autostart" }
],
"extends": "shell",
"has_html": true
}
// Copyright 2018 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.
/**
* @implements {Common.Runnable}
*/
NodeMain.NodeMain = class extends Common.Object {
constructor() {
}
/**
* @override
*/
run() {
Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFrontend);
var target = SDK.targetManager.createTarget(
'main', Common.UIString('Main'), SDK.Target.Capability.Target, params => new SDK.MainConnection(params), null);
target.setInspectedURL('Node.js');
InspectorFrontendHost.connectionReady();
}
};
/**
* @implements {Protocol.TargetDispatcher}
*/
NodeMain.NodeChildTargetManager = class extends SDK.SDKModel {
/**
* @param {!SDK.Target} parentTarget
*/
constructor(parentTarget) {
super(parentTarget);
this._targetManager = parentTarget.targetManager();
this._parentTarget = parentTarget;
this._targetAgent = parentTarget.targetAgent();
/** @type {!Map<string, !SDK.ChildConnection>} */
this._childConnections = new Map();
parentTarget.registerTargetDispatcher(this);
this._targetAgent.setDiscoverTargets(true);
InspectorFrontendHost.setDevicesUpdatesEnabled(true);
InspectorFrontendHost.events.addEventListener(
InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
}
/**
* @param {!Common.Event} event
*/
_devicesDiscoveryConfigChanged(event) {
var config = /** @type {!Adb.Config} */ (event.data);
var locations = [];
for (var address of config.networkDiscoveryConfig) {
var parts = address.split(':');
var port = parseInt(parts[1], 10);
if (parts[0] && port)
locations.push({host: parts[0], port: port});
}
this._targetAgent.setRemoteLocations(locations);
}
/**
* @override
*/
dispose() {
InspectorFrontendHost.events.removeEventListener(
InspectorFrontendHostAPI.Events.DevicesDiscoveryConfigChanged, this._devicesDiscoveryConfigChanged, this);
for (var sessionId of this._childConnections.keys())
this.detachedFromTarget(sessionId, undefined);
}
/**
* @override
* @param {!Protocol.Target.TargetInfo} targetInfo
*/
targetCreated(targetInfo) {
if (targetInfo.type === 'node' && !targetInfo.attached)
this._targetAgent.attachToTarget(targetInfo.targetId);
}
/**
* @override
* @param {!Protocol.Target.TargetInfo} targetInfo
*/
targetInfoChanged(targetInfo) {
}
/**
* @override
* @param {string} targetId
*/
targetDestroyed(targetId) {
}
/**
* @override
* @param {string} sessionId
* @param {!Protocol.Target.TargetInfo} targetInfo
* @param {boolean} waitingForDebugger
*/
attachedToTarget(sessionId, targetInfo, waitingForDebugger) {
var target = this._targetManager.createTarget(
targetInfo.targetId, Common.UIString('Node.js: %s', targetInfo.url), SDK.Target.Capability.JS,
this._createChildConnection.bind(this, this._targetAgent, sessionId), this._parentTarget);
target.runtimeAgent().runIfWaitingForDebugger();
}
/**
* @override
* @param {string} sessionId
* @param {string=} childTargetId
*/
detachedFromTarget(sessionId, childTargetId) {
this._childConnections.get(sessionId).onDisconnect.call(null, 'target terminated');
this._childConnections.delete(sessionId);
}
/**
* @override
* @param {string} sessionId
* @param {string} message
* @param {string=} childTargetId
*/
receivedMessageFromTarget(sessionId, message, childTargetId) {
var connection = this._childConnections.get(sessionId);
if (connection)
connection.onMessage.call(null, message);
}
/**
* @param {!Protocol.TargetAgent} agent
* @param {string} sessionId
* @param {!Protocol.InspectorBackend.Connection.Params} params
* @return {!Protocol.InspectorBackend.Connection}
*/
_createChildConnection(agent, sessionId, params) {
var connection = new SDK.ChildConnection(agent, sessionId, params);
this._childConnections.set(sessionId, connection);
return connection;
}
};
SDK.SDKModel.register(NodeMain.NodeChildTargetManager, SDK.Target.Capability.Target, true);
{
"extensions": [
{
"type": "early-initialization",
"className": "NodeMain.NodeMain"
},
{
"type": "view",
"location": "panel",
......
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