Skip to content

Commit fed93c7

Browse files
paulirishDevtools-frontend LUCI CQ
authored andcommitted
Document HostedMode, canDock, and remoteBase
Change-Id: Ib56ab92284144e376b51e1d7aaf64ff2bdcbfa82 Bug: none Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6765826 Auto-Submit: Paul Irish <[email protected]> Commit-Queue: Paul Irish <[email protected]> Reviewed-by: Danil Somsikov <[email protected]>
1 parent 41d8bbb commit fed93c7

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

front_end/core/host/InspectorFrontendHost.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,20 @@ export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
486486
throw new Error('Soft context menu should be used');
487487
}
488488

489+
/**
490+
* **Hosted mode** is when DevTools is loaded over `http(s)://` rather than from `devtools://`.
491+
* It does **not** indicate whether the frontend is connected to a valid CDP target.
492+
*
493+
* | Example case | Mode | Example URL |
494+
* | :--------------------------------------------------- | :------------- | :---------------------------------------------------------------------------- |
495+
* | typical devtools: (un)docked w/ native CDP bindings | **NOT Hosted** | `devtools://devtools/bundled/devtools_app.html?targetType=tab&...` |
496+
* | tab href is `devtools://…?ws=…` | **NOT Hosted** | `devtools://devtools/bundled/devtools_app.html?ws=localhost:9228/...` |
497+
* | tab href is `devtools://…` but no connection | **NOT Hosted** | `devtools://devtools/bundled/devtools_app.html` |
498+
* | tab href is `https://…?ws=` (connected) | **Hosted** | `https://chrome-devtools-frontend.appspot.com/serve_rev/@.../worker_app.html` |
499+
* | tab href is `http://…` but no connection | **Hosted** | `http://localhost:9222/devtools/inspector.html?ws=localhost:9222/...` |
500+
*
501+
* See also `canDock` which has similar semantics.
502+
*/
489503
isHostedMode(): boolean {
490504
return true;
491505
}

front_end/core/root/Runtime.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ let runtimePlatform = '';
1111
let runtimeInstance: Runtime|undefined;
1212
let isNode: boolean|undefined;
1313

14+
/** Returns the base URL (similar to `<base>`).
15+
* Used to resolve the relative URLs of any additional DevTools files (locale strings, etc) needed.
16+
* See: https://cs.chromium.org/remoteBase+f:devtools_window
17+
*/
1418
export function getRemoteBase(location: string = self.location.toString()): {
1519
base: string,
1620
version: string,

front_end/core/sdk/Connections.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ function createMainConnection(onConnectionLost: (message: Platform.UIString.Loca
296296
return new WebSocketConnection(ws, onConnectionLost);
297297
}
298298
if (Host.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode()) {
299+
// Hosted mode (e.g. `http://localhost:9222/devtools/inspector.html`) but no WebSocket URL.
299300
return new StubConnection();
300301
}
301302

front_end/entrypoints/node_app/NodeMain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class NodeMainImpl implements Common.Runnable.Runnable {
4444
Host.userMetrics.actionTaken(Host.UserMetrics.Action.ConnectToNodeJSFromFrontend);
4545
void SDK.Connections.initMainConnection(async () => {
4646
const target = SDK.TargetManager.TargetManager.instance().createTarget(
47+
// TODO: Use SDK.Target.Type.NODE rather thatn BROWSER once DevTools is loaded appropriately in that case.
4748
'main', i18nString(UIStrings.main), SDK.Target.Type.BROWSER, null);
4849
target.setInspectedURL('Node.js' as Platform.DevToolsPath.UrlString);
4950
}, Components.TargetDetachedDialog.TargetDetachedDialog.connectionLost);

front_end/ui/legacy/DockController.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ export class DockController extends Common.ObjectWrapper.ObjectWrapper<EventType
123123
return this.dockSideInternal;
124124
}
125125

126+
/** Whether the DevTools can be docked, used to determine if we show docking UI.
127+
* Set via `Root.Runtime.Runtime.queryParam('can_dock')`. See https://cs.chromium.org/can_dock+f:window
128+
*
129+
* Shouldn't be used as a heuristic for target connection state.
130+
*/
126131
canDock(): boolean {
127132
return this.canDockInternal;
128133
}

0 commit comments

Comments
 (0)