chrome-devtools-frontend 1.0.1565595 → 1.0.1566234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/front_end/Images/src/lock-person.svg +1 -0
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/DOMModel.ts +32 -2
- package/front_end/core/sdk/NetworkManager.ts +13 -0
- package/front_end/core/sdk/ResourceTreeModel.ts +11 -6
- package/front_end/generated/InspectorBackendCommands.ts +9 -0
- package/front_end/generated/SupportedCSSProperties.js +19 -23
- package/front_end/generated/protocol-mapping.d.ts +4 -0
- package/front_end/generated/protocol-proxy-api.d.ts +5 -0
- package/front_end/generated/protocol.ts +199 -0
- package/front_end/panels/application/ApplicationPanelSidebar.ts +28 -0
- package/front_end/panels/application/ApplicationPanelTreeElement.ts +12 -0
- package/front_end/panels/application/DeviceBoundSessionsModel.ts +127 -0
- package/front_end/panels/application/DeviceBoundSessionsTreeElement.ts +170 -0
- package/front_end/panels/application/DeviceBoundSessionsView.ts +252 -0
- package/front_end/panels/application/ResourcesPanel.ts +12 -0
- package/front_end/panels/application/application.ts +6 -0
- package/front_end/panels/application/deviceBoundSessionsView.css +18 -0
- package/front_end/panels/console/ConsoleInsightTeaser.ts +24 -5
- package/front_end/panels/console/ConsoleViewMessage.ts +20 -13
- package/front_end/panels/elements/ElementsTreeOutline.ts +13 -0
- package/front_end/panels/elements/MetricsSidebarPane.ts +3 -1
- package/front_end/panels/security/SecurityPanelSidebar.ts +0 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts +8 -1
- package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ import * as Common from '../../core/common/common.js';
|
|
|
37
37
|
import * as Host from '../../core/host/host.js';
|
|
38
38
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
39
39
|
import * as Platform from '../../core/platform/platform.js';
|
|
40
|
+
import * as Root from '../../core/root/root.js';
|
|
40
41
|
import * as SDK from '../../core/sdk/sdk.js';
|
|
41
42
|
import * as Protocol from '../../generated/protocol.js';
|
|
42
43
|
import * as IssuesManager from '../../models/issues_manager/issues_manager.js';
|
|
@@ -51,6 +52,8 @@ import {BackForwardCacheTreeElement} from './BackForwardCacheTreeElement.js';
|
|
|
51
52
|
import {BackgroundServiceModel} from './BackgroundServiceModel.js';
|
|
52
53
|
import {BackgroundServiceView} from './BackgroundServiceView.js';
|
|
53
54
|
import {BounceTrackingMitigationsTreeElement} from './BounceTrackingMitigationsTreeElement.js';
|
|
55
|
+
import {DeviceBoundSessionsModel} from './DeviceBoundSessionsModel.js';
|
|
56
|
+
import {RootTreeElement as DeviceBoundSessionsRootTreeElement} from './DeviceBoundSessionsTreeElement.js';
|
|
54
57
|
import {type DOMStorage, DOMStorageModel, Events as DOMStorageModelEvents} from './DOMStorageModel.js';
|
|
55
58
|
import {
|
|
56
59
|
Events as ExtensionStorageModelEvents,
|
|
@@ -343,6 +346,8 @@ export class ApplicationPanelSidebar extends UI.Widget.VBox implements SDK.Targe
|
|
|
343
346
|
periodicBackgroundSyncTreeElement: BackgroundServiceTreeElement;
|
|
344
347
|
pushMessagingTreeElement: BackgroundServiceTreeElement;
|
|
345
348
|
reportingApiTreeElement: ReportingApiTreeElement;
|
|
349
|
+
deviceBoundSessionsRootTreeElement: DeviceBoundSessionsRootTreeElement|undefined;
|
|
350
|
+
deviceBoundSessionsModel: DeviceBoundSessionsModel|undefined;
|
|
346
351
|
preloadingSummaryTreeElement: PreloadingSummaryTreeElement|undefined;
|
|
347
352
|
private readonly resourcesSection: ResourcesSection;
|
|
348
353
|
private domStorageTreeElements: Map<DOMStorage, DOMStorageTreeElement>;
|
|
@@ -481,6 +486,13 @@ export class ApplicationPanelSidebar extends UI.Widget.VBox implements SDK.Targe
|
|
|
481
486
|
this.reportingApiTreeElement = new ReportingApiTreeElement(panel);
|
|
482
487
|
backgroundServiceTreeElement.appendChild(this.reportingApiTreeElement);
|
|
483
488
|
|
|
489
|
+
if (Root.Runtime.hostConfig.deviceBoundSessionsDebugging?.enabled) {
|
|
490
|
+
this.deviceBoundSessionsModel = new DeviceBoundSessionsModel();
|
|
491
|
+
this.deviceBoundSessionsRootTreeElement =
|
|
492
|
+
new DeviceBoundSessionsRootTreeElement(panel, this.deviceBoundSessionsModel);
|
|
493
|
+
backgroundServiceTreeElement.appendChild(this.deviceBoundSessionsRootTreeElement);
|
|
494
|
+
}
|
|
495
|
+
|
|
484
496
|
const resourcesSectionTitle = i18nString(UIStrings.frames);
|
|
485
497
|
const resourcesTreeElement = this.addSidebarSection(resourcesSectionTitle, 'frames');
|
|
486
498
|
this.resourcesSection = new ResourcesSection(panel, resourcesTreeElement);
|
|
@@ -760,6 +772,7 @@ export class ApplicationPanelSidebar extends UI.Widget.VBox implements SDK.Targe
|
|
|
760
772
|
this.domains = {};
|
|
761
773
|
this.cookieListTreeElement.removeChildren();
|
|
762
774
|
this.interestGroupTreeElement.clearEvents();
|
|
775
|
+
this.deviceBoundSessionsModel?.clearVisibleSites();
|
|
763
776
|
}
|
|
764
777
|
|
|
765
778
|
private frameNavigated(event: Common.EventTarget.EventTargetEvent<SDK.ResourceTreeModel.ResourceTreeFrame>): void {
|
|
@@ -791,6 +804,21 @@ export class ApplicationPanelSidebar extends UI.Widget.VBox implements SDK.Targe
|
|
|
791
804
|
this.domains[domain] = true;
|
|
792
805
|
const cookieDomainTreeElement = new CookieTreeElement(this.panel, frame, parsedURL);
|
|
793
806
|
this.cookieListTreeElement.appendChild(cookieDomainTreeElement);
|
|
807
|
+
|
|
808
|
+
// Update device bound session visibility for new cookie domain.
|
|
809
|
+
if (this.deviceBoundSessionsModel) {
|
|
810
|
+
const target = frame.resourceTreeModel().target();
|
|
811
|
+
const networkAgent = target.networkAgent();
|
|
812
|
+
void networkAgent.invoke_fetchSchemefulSite({origin: domain}).then(response => {
|
|
813
|
+
if (response.getError() || !this.deviceBoundSessionsModel) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
// Confirm the domain is still present first.
|
|
817
|
+
if (this.domains[domain]) {
|
|
818
|
+
this.deviceBoundSessionsModel.addVisibleSite(response.schemefulSite);
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
}
|
|
794
822
|
}
|
|
795
823
|
}
|
|
796
824
|
|
|
@@ -10,6 +10,7 @@ import type {ResourcesPanel} from './ResourcesPanel.js';
|
|
|
10
10
|
|
|
11
11
|
export class ApplicationPanelTreeElement extends UI.TreeOutline.TreeElement {
|
|
12
12
|
protected readonly resourcesPanel: ResourcesPanel;
|
|
13
|
+
private customItemURL?: Platform.DevToolsPath.UrlString;
|
|
13
14
|
|
|
14
15
|
constructor(resourcesPanel: ResourcesPanel, title: string, expandable: boolean, jslogContext: string) {
|
|
15
16
|
super(title, expandable, jslogContext);
|
|
@@ -24,9 +25,16 @@ export class ApplicationPanelTreeElement extends UI.TreeOutline.TreeElement {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
get itemURL(): Platform.DevToolsPath.UrlString {
|
|
28
|
+
if (this.customItemURL) {
|
|
29
|
+
return this.customItemURL;
|
|
30
|
+
}
|
|
27
31
|
throw new Error('Unimplemented Method');
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
set itemURL(value: Platform.DevToolsPath.UrlString) {
|
|
35
|
+
this.customItemURL = value;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
override onselect(selectedByUser: boolean|undefined): boolean {
|
|
31
39
|
if (!selectedByUser) {
|
|
32
40
|
return false;
|
|
@@ -76,6 +84,10 @@ export class ExpandableApplicationPanelTreeElement extends ApplicationPanelTreeE
|
|
|
76
84
|
return 'category://' + this.categoryName as Platform.DevToolsPath.UrlString;
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
override set itemURL(value: Platform.DevToolsPath.UrlString) {
|
|
88
|
+
super.itemURL = value;
|
|
89
|
+
}
|
|
90
|
+
|
|
79
91
|
setLink(link: Platform.DevToolsPath.UrlString): void {
|
|
80
92
|
this.categoryLink = link;
|
|
81
93
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Copyright 2026 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import * as Common from '../../core/common/common.js';
|
|
6
|
+
import * as SDK from '../../core/sdk/sdk.js';
|
|
7
|
+
import type * as Protocol from '../../generated/protocol.js';
|
|
8
|
+
|
|
9
|
+
interface EventWithTimestamp {
|
|
10
|
+
event: Protocol.Network.DeviceBoundSessionEventOccurredEvent;
|
|
11
|
+
timestamp: Date;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionAndEvents {
|
|
14
|
+
session?: Protocol.Network.DeviceBoundSession;
|
|
15
|
+
eventsById: Map<string, EventWithTimestamp>;
|
|
16
|
+
}
|
|
17
|
+
type SessionIdToSessionMap = Map<string|undefined, SessionAndEvents>;
|
|
18
|
+
|
|
19
|
+
export class DeviceBoundSessionsModel extends Common.ObjectWrapper.ObjectWrapper<DeviceBoundSessionModelEventTypes>
|
|
20
|
+
implements SDK.TargetManager.SDKModelObserver<SDK.NetworkManager.NetworkManager> {
|
|
21
|
+
#siteSessions = new Map<string, SessionIdToSessionMap>();
|
|
22
|
+
#visibleSites = new Set<string>();
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
SDK.TargetManager.TargetManager.instance().observeModels(SDK.NetworkManager.NetworkManager, this, {scoped: true});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
modelAdded(networkManager: SDK.NetworkManager.NetworkManager): void {
|
|
30
|
+
networkManager.addEventListener(SDK.NetworkManager.Events.DeviceBoundSessionsAdded, this.#onSessionsSet, this);
|
|
31
|
+
networkManager.addEventListener(
|
|
32
|
+
SDK.NetworkManager.Events.DeviceBoundSessionEventOccurred, this.#onEventOccurred, this);
|
|
33
|
+
void networkManager.enableDeviceBoundSessions();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
modelRemoved(networkManager: SDK.NetworkManager.NetworkManager): void {
|
|
37
|
+
networkManager.removeEventListener(SDK.NetworkManager.Events.DeviceBoundSessionsAdded, this.#onSessionsSet, this);
|
|
38
|
+
networkManager.removeEventListener(
|
|
39
|
+
SDK.NetworkManager.Events.DeviceBoundSessionEventOccurred, this.#onEventOccurred, this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
addVisibleSite(site: string): void {
|
|
43
|
+
if (this.#visibleSites.has(site)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.#visibleSites.add(site);
|
|
47
|
+
this.dispatchEventToListeners(DeviceBoundSessionModelEvents.ADD_VISIBLE_SITE, {site});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
clearVisibleSites(): void {
|
|
51
|
+
this.#visibleSites.clear();
|
|
52
|
+
this.dispatchEventToListeners(DeviceBoundSessionModelEvents.CLEAR_VISIBLE_SITES);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isSiteVisible(site: string): boolean {
|
|
56
|
+
return this.#visibleSites.has(site);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getSession(site: string, sessionId?: string): SessionAndEvents|undefined {
|
|
60
|
+
return this.#siteSessions.get(site)?.get(sessionId);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#onSessionsSet({data: sessions}: {data: Protocol.Network.DeviceBoundSession[]}): void {
|
|
64
|
+
for (const session of sessions) {
|
|
65
|
+
const sessionAndEvents = this.#ensureSiteAndSessionInitialized(session.key.site, session.key.id);
|
|
66
|
+
sessionAndEvents.session = session;
|
|
67
|
+
}
|
|
68
|
+
this.dispatchEventToListeners(DeviceBoundSessionModelEvents.INITIALIZE_SESSIONS, {sessions});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#ensureSiteAndSessionInitialized(site: string, sessionId?: string): SessionAndEvents {
|
|
72
|
+
let sessionIdToSessionMap = this.#siteSessions.get(site);
|
|
73
|
+
if (!sessionIdToSessionMap) {
|
|
74
|
+
sessionIdToSessionMap = new Map();
|
|
75
|
+
this.#siteSessions.set(site, sessionIdToSessionMap);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let sessionAndEvent = sessionIdToSessionMap.get(sessionId);
|
|
79
|
+
if (!sessionAndEvent) {
|
|
80
|
+
sessionAndEvent = {session: undefined, eventsById: new Map<string, EventWithTimestamp>()};
|
|
81
|
+
sessionIdToSessionMap.set(sessionId, sessionAndEvent);
|
|
82
|
+
}
|
|
83
|
+
return sessionAndEvent;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#onEventOccurred({data: event}: {data: Protocol.Network.DeviceBoundSessionEventOccurredEvent}): void {
|
|
87
|
+
const sessionAndEvent = this.#ensureSiteAndSessionInitialized(event.site, event.sessionId);
|
|
88
|
+
|
|
89
|
+
// If this eventId has already been tracked, quit early.
|
|
90
|
+
if (sessionAndEvent.eventsById.has(event.eventId)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Add the new event.
|
|
95
|
+
const eventWithTimestamp = {event, timestamp: new Date()};
|
|
96
|
+
sessionAndEvent.eventsById.set(event.eventId, eventWithTimestamp);
|
|
97
|
+
|
|
98
|
+
// Add the new session if there is one.
|
|
99
|
+
const newSession = event.creationEventDetails?.newSession || event.refreshEventDetails?.newSession;
|
|
100
|
+
if (newSession) {
|
|
101
|
+
sessionAndEvent.session = newSession;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Add the new challenge onto the session if there is one.
|
|
105
|
+
if (event.succeeded && sessionAndEvent.session && event.challengeEventDetails) {
|
|
106
|
+
sessionAndEvent.session.cachedChallenge = event.challengeEventDetails.challenge;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.dispatchEventToListeners(
|
|
110
|
+
DeviceBoundSessionModelEvents.EVENT_OCCURRED,
|
|
111
|
+
{site: eventWithTimestamp.event.site, sessionId: eventWithTimestamp.event.sessionId});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const enum DeviceBoundSessionModelEvents {
|
|
116
|
+
INITIALIZE_SESSIONS = 'INITIALIZE_SESSIONS',
|
|
117
|
+
ADD_VISIBLE_SITE = 'ADD_VISIBLE_SITE',
|
|
118
|
+
CLEAR_VISIBLE_SITES = 'CLEAR_VISIBLE_SITES',
|
|
119
|
+
EVENT_OCCURRED = 'EVENT_OCCURRED',
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface DeviceBoundSessionModelEventTypes {
|
|
123
|
+
[DeviceBoundSessionModelEvents.INITIALIZE_SESSIONS]: {sessions: Protocol.Network.DeviceBoundSession[]};
|
|
124
|
+
[DeviceBoundSessionModelEvents.ADD_VISIBLE_SITE]: {site: string};
|
|
125
|
+
[DeviceBoundSessionModelEvents.CLEAR_VISIBLE_SITES]: void;
|
|
126
|
+
[DeviceBoundSessionModelEvents.EVENT_OCCURRED]: {site: string, sessionId?: string};
|
|
127
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// Copyright 2026 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import type * as Common from '../../core/common/common.js';
|
|
6
|
+
import * as i18n from '../../core/i18n/i18n.js';
|
|
7
|
+
import type * as Platform from '../../core/platform/platform.js';
|
|
8
|
+
import {createIcon} from '../../ui/kit/kit.js';
|
|
9
|
+
|
|
10
|
+
import {ApplicationPanelTreeElement, ExpandableApplicationPanelTreeElement} from './ApplicationPanelTreeElement.js';
|
|
11
|
+
import {
|
|
12
|
+
DeviceBoundSessionModelEvents,
|
|
13
|
+
type DeviceBoundSessionModelEventTypes,
|
|
14
|
+
type DeviceBoundSessionsModel
|
|
15
|
+
} from './DeviceBoundSessionsModel.js';
|
|
16
|
+
import type {ResourcesPanel} from './ResourcesPanel.js';
|
|
17
|
+
|
|
18
|
+
const UIStrings = {
|
|
19
|
+
/**
|
|
20
|
+
*@description Text for section title Application panel sidebar. A website
|
|
21
|
+
* may decide to create a session for a user, for example when the user logs
|
|
22
|
+
* in. They can use a protocol to make it a "device bound session". That
|
|
23
|
+
* means that when the session expires, it is only possible for it to be
|
|
24
|
+
* extended on the device it was created on. Thus the session is considered
|
|
25
|
+
* to be bound to that device. For more details on the protocol, see
|
|
26
|
+
* https://github.com/w3c/webappsec-dbsc/blob/main/README.md and
|
|
27
|
+
* https://w3c.github.io/webappsec-dbsc/.
|
|
28
|
+
*/
|
|
29
|
+
deviceBoundSessions: 'Device bound sessions',
|
|
30
|
+
/**
|
|
31
|
+
*@description Empty state description for root tree element and site tree
|
|
32
|
+
* elements. A website may decide to create a session for a user, for example
|
|
33
|
+
* when the user logs in. They can use a protocol to make it a "device bound
|
|
34
|
+
* session". That means that when the session expires, it is only possible
|
|
35
|
+
* for it to be extended on the device it was created on. Thus the session
|
|
36
|
+
* is considered to be bound to that device. A session can have various events,
|
|
37
|
+
* such as when it's first created, when it's extended, or when it's
|
|
38
|
+
* terminated. For more details on the protocol, see
|
|
39
|
+
* https://github.com/w3c/webappsec-dbsc/blob/main/README.md and
|
|
40
|
+
* https://w3c.github.io/webappsec-dbsc/.
|
|
41
|
+
*/
|
|
42
|
+
deviceBoundSessionsCategoryDescription: 'On this page you can view device bound sessions and associated events',
|
|
43
|
+
/**
|
|
44
|
+
*@description Events are sometimes linked to sessions. These are grouped
|
|
45
|
+
* visually either by session name or by 'No session' if any events are not
|
|
46
|
+
* linked to a session.
|
|
47
|
+
*/
|
|
48
|
+
noSession: 'No session',
|
|
49
|
+
} as const;
|
|
50
|
+
|
|
51
|
+
const str_ = i18n.i18n.registerUIStrings('panels/application/DeviceBoundSessionsTreeElement.ts', UIStrings);
|
|
52
|
+
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
53
|
+
|
|
54
|
+
export class RootTreeElement extends ExpandableApplicationPanelTreeElement {
|
|
55
|
+
#model: DeviceBoundSessionsModel;
|
|
56
|
+
#sites = new Map<string, {siteTreeElement: ExpandableApplicationPanelTreeElement, sessions: Set<string|undefined>}>();
|
|
57
|
+
|
|
58
|
+
constructor(storagePanel: ResourcesPanel, model: DeviceBoundSessionsModel) {
|
|
59
|
+
super(
|
|
60
|
+
storagePanel, i18nString(UIStrings.deviceBoundSessions), i18nString(UIStrings.deviceBoundSessions),
|
|
61
|
+
i18nString(UIStrings.deviceBoundSessionsCategoryDescription), 'device-bound-sessions-root');
|
|
62
|
+
this.setLeadingIcons([createIcon('lock-person')]);
|
|
63
|
+
this.#model = model;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override get itemURL(): Platform.DevToolsPath.UrlString {
|
|
67
|
+
return 'device-bound-sessions://' as Platform.DevToolsPath.UrlString;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override onbind(): void {
|
|
71
|
+
super.onbind();
|
|
72
|
+
this.#model.addEventListener(DeviceBoundSessionModelEvents.INITIALIZE_SESSIONS, this.#onNewSessions, this);
|
|
73
|
+
this.#model.addEventListener(DeviceBoundSessionModelEvents.ADD_VISIBLE_SITE, this.#onVisibleSiteAdded, this);
|
|
74
|
+
this.#model.addEventListener(DeviceBoundSessionModelEvents.CLEAR_VISIBLE_SITES, this.#onVisibleSitesCleared, this);
|
|
75
|
+
this.#model.addEventListener(DeviceBoundSessionModelEvents.EVENT_OCCURRED, this.#onEventOccurred, this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override onunbind(): void {
|
|
79
|
+
super.onunbind();
|
|
80
|
+
this.#model.removeEventListener(DeviceBoundSessionModelEvents.INITIALIZE_SESSIONS, this.#onNewSessions, this);
|
|
81
|
+
this.#model.removeEventListener(DeviceBoundSessionModelEvents.ADD_VISIBLE_SITE, this.#onVisibleSiteAdded, this);
|
|
82
|
+
this.#model.removeEventListener(
|
|
83
|
+
DeviceBoundSessionModelEvents.CLEAR_VISIBLE_SITES, this.#onVisibleSitesCleared, this);
|
|
84
|
+
this.#model.removeEventListener(DeviceBoundSessionModelEvents.EVENT_OCCURRED, this.#onEventOccurred, this);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#updateSiteTreeElementVisibility(site: string): void {
|
|
88
|
+
const siteMapEntry = this.#sites.get(site);
|
|
89
|
+
if (!siteMapEntry) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const siteTreeElement = siteMapEntry.siteTreeElement;
|
|
94
|
+
const isElementPresent = this.indexOfChild(siteTreeElement) >= 0;
|
|
95
|
+
const isSiteAllowed = this.#model.isSiteVisible(site);
|
|
96
|
+
|
|
97
|
+
if (isSiteAllowed && !isElementPresent) {
|
|
98
|
+
// Appending a child element that already has children requires a workaround of
|
|
99
|
+
// detaching and repopulating them so that the selection background color UI works.
|
|
100
|
+
// TODO(crbug.com/471021582): Can this fix safely be moved to Treeoutline.ts?
|
|
101
|
+
this.appendChild(siteTreeElement);
|
|
102
|
+
const children = [...siteTreeElement.children()];
|
|
103
|
+
siteTreeElement.removeChildren();
|
|
104
|
+
for (const child of children) {
|
|
105
|
+
siteTreeElement.appendChild(child);
|
|
106
|
+
}
|
|
107
|
+
} else if (!isSiteAllowed && isElementPresent) {
|
|
108
|
+
this.removeChild(siteTreeElement);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#addSiteSessionIfMissing(site: string, sessionId: string|undefined): void {
|
|
113
|
+
let siteMapEntry = this.#sites.get(site);
|
|
114
|
+
if (!siteMapEntry) {
|
|
115
|
+
const siteElement = new ExpandableApplicationPanelTreeElement(
|
|
116
|
+
this.resourcesPanel, site, i18nString(UIStrings.deviceBoundSessions),
|
|
117
|
+
i18nString(UIStrings.deviceBoundSessionsCategoryDescription), 'device-bound-sessions-site');
|
|
118
|
+
siteElement.setLeadingIcons([createIcon('cloud')]);
|
|
119
|
+
siteElement.itemURL = `device-bound-sessions://${site}` as Platform.DevToolsPath.UrlString;
|
|
120
|
+
siteMapEntry = {siteTreeElement: siteElement, sessions: new Set()};
|
|
121
|
+
this.#sites.set(site, siteMapEntry);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!siteMapEntry.sessions.has(sessionId)) {
|
|
125
|
+
const sessionElement = new ApplicationPanelTreeElement(
|
|
126
|
+
this.resourcesPanel, sessionId ?? i18nString(UIStrings.noSession), false, 'device-bound-sessions-session');
|
|
127
|
+
sessionElement.setLeadingIcons([createIcon('database')]);
|
|
128
|
+
sessionElement.itemURL = `device-bound-sessions://${site}/${sessionId || ''}` as Platform.DevToolsPath.UrlString;
|
|
129
|
+
const defaultOnSelect = sessionElement.onselect.bind(sessionElement);
|
|
130
|
+
sessionElement.onselect = (selectedByUser?: boolean): boolean => {
|
|
131
|
+
defaultOnSelect(selectedByUser);
|
|
132
|
+
this.resourcesPanel.showDeviceBoundSession(this.#model, site, sessionId);
|
|
133
|
+
return false;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (sessionId === undefined) {
|
|
137
|
+
// The "No session" session is always listed at the top.
|
|
138
|
+
siteMapEntry.siteTreeElement.insertChild(sessionElement, 0);
|
|
139
|
+
} else {
|
|
140
|
+
siteMapEntry.siteTreeElement.appendChild(sessionElement);
|
|
141
|
+
}
|
|
142
|
+
siteMapEntry.sessions.add(sessionId);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.#updateSiteTreeElementVisibility(site);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#onNewSessions({data: {sessions}}: Common.EventTarget.EventTargetEvent<
|
|
149
|
+
DeviceBoundSessionModelEventTypes[DeviceBoundSessionModelEvents.INITIALIZE_SESSIONS]>): void {
|
|
150
|
+
for (const session of sessions) {
|
|
151
|
+
this.#addSiteSessionIfMissing(session.key.site, session.key.id);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#onVisibleSiteAdded(
|
|
156
|
+
{data: {site}}: Common.EventTarget
|
|
157
|
+
.EventTargetEvent<DeviceBoundSessionModelEventTypes[DeviceBoundSessionModelEvents.ADD_VISIBLE_SITE]>): void {
|
|
158
|
+
this.#updateSiteTreeElementVisibility(site);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#onVisibleSitesCleared(): void {
|
|
162
|
+
this.removeChildren();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#onEventOccurred(
|
|
166
|
+
{data: {site, sessionId}}: Common.EventTarget
|
|
167
|
+
.EventTargetEvent<DeviceBoundSessionModelEventTypes[DeviceBoundSessionModelEvents.EVENT_OCCURRED]>): void {
|
|
168
|
+
this.#addSiteSessionIfMissing(site, sessionId);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// Copyright 2026 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import '../../ui/components/report_view/report_view.js';
|
|
6
|
+
import '../../ui/legacy/components/data_grid/data_grid.js';
|
|
7
|
+
|
|
8
|
+
import * as i18n from '../../core/i18n/i18n.js';
|
|
9
|
+
import * as Protocol from '../../generated/protocol.js';
|
|
10
|
+
import * as UI from '../../ui/legacy/legacy.js';
|
|
11
|
+
import {html, nothing, render} from '../../ui/lit/lit.js';
|
|
12
|
+
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
DeviceBoundSessionModelEvents,
|
|
16
|
+
type DeviceBoundSessionsModel,
|
|
17
|
+
type SessionAndEvents
|
|
18
|
+
} from './DeviceBoundSessionsModel.js';
|
|
19
|
+
import deviceBoundSessionsViewStyles from './deviceBoundSessionsView.css.js';
|
|
20
|
+
|
|
21
|
+
const UIStrings = {
|
|
22
|
+
/**
|
|
23
|
+
*@description Label for a site, e.g. https://example.com/.
|
|
24
|
+
*/
|
|
25
|
+
keySite: 'Site',
|
|
26
|
+
/**
|
|
27
|
+
*@description Label for the ID of a session.
|
|
28
|
+
*/
|
|
29
|
+
keyId: 'ID',
|
|
30
|
+
/**
|
|
31
|
+
*@description Label that shows the URL that can be used to refresh a session.
|
|
32
|
+
*/
|
|
33
|
+
refreshUrl: 'Refresh URL',
|
|
34
|
+
/**
|
|
35
|
+
*@description Section header for how a session's scope is defined.
|
|
36
|
+
*/
|
|
37
|
+
scope: 'Scope',
|
|
38
|
+
/**
|
|
39
|
+
*@description Section header for HTTP cookies.
|
|
40
|
+
*/
|
|
41
|
+
cookieCravings: 'Cookies',
|
|
42
|
+
/**
|
|
43
|
+
*@description Label for the name of an HTTP cookie.
|
|
44
|
+
*/
|
|
45
|
+
name: 'Name',
|
|
46
|
+
/**
|
|
47
|
+
*@description Label for an expiration date.
|
|
48
|
+
*/
|
|
49
|
+
expiryDate: 'Expiry date',
|
|
50
|
+
/**
|
|
51
|
+
*@description Label for a cryptographic string challenge that has been cached for a session.
|
|
52
|
+
*/
|
|
53
|
+
cachedChallenge: 'Cached challenge',
|
|
54
|
+
/**
|
|
55
|
+
*@description Label for the HTTP initiator that is allowed to trigger a refresh of a session.
|
|
56
|
+
*/
|
|
57
|
+
allowedRefreshInitiators: 'Allowed refresh initiators',
|
|
58
|
+
/**
|
|
59
|
+
*@description Section header for a session's basic configuration.
|
|
60
|
+
*/
|
|
61
|
+
sessionConfig: 'Session config',
|
|
62
|
+
/**
|
|
63
|
+
*@description Label for an HTTP origin.
|
|
64
|
+
*/
|
|
65
|
+
origin: 'Origin',
|
|
66
|
+
/**
|
|
67
|
+
*@description Text for whether a site is included.
|
|
68
|
+
*/
|
|
69
|
+
includeSite: 'Include site',
|
|
70
|
+
/**
|
|
71
|
+
*@description Value for a label that indicates that a site is included.
|
|
72
|
+
*/
|
|
73
|
+
yes: 'Yes',
|
|
74
|
+
/**
|
|
75
|
+
*@description Value for a label that indicates that a site is not included.
|
|
76
|
+
*/
|
|
77
|
+
no: 'No',
|
|
78
|
+
/**
|
|
79
|
+
*@description Label the host pattern of a URL, e.g. *.example.com
|
|
80
|
+
*/
|
|
81
|
+
ruleHostPattern: 'Host pattern',
|
|
82
|
+
/**
|
|
83
|
+
*@description Label for the path prefix of a URL, e.g. /path/1/2/3
|
|
84
|
+
*/
|
|
85
|
+
rulePathPrefix: 'Path prefix',
|
|
86
|
+
/**
|
|
87
|
+
*@description The type of a rule. The possible types are "exclude" or "include".
|
|
88
|
+
*/
|
|
89
|
+
ruleType: 'Rule type',
|
|
90
|
+
/**
|
|
91
|
+
*@description Text describing that a rule excludes something.
|
|
92
|
+
*/
|
|
93
|
+
ruleTypeExclude: 'Exclude',
|
|
94
|
+
/**
|
|
95
|
+
*@description Text describing that a rule includes something.
|
|
96
|
+
*/
|
|
97
|
+
ruleTypeInclude: 'Include',
|
|
98
|
+
} as const;
|
|
99
|
+
const str_ = i18n.i18n.registerUIStrings('panels/application/DeviceBoundSessionsView.ts', UIStrings);
|
|
100
|
+
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
101
|
+
|
|
102
|
+
interface ViewInput {
|
|
103
|
+
sessionAndEvents?: SessionAndEvents;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type ViewOutput = object;
|
|
107
|
+
|
|
108
|
+
function ruleTypeToString(ruleType: Protocol.Network.DeviceBoundSessionUrlRuleRuleType): string {
|
|
109
|
+
switch (ruleType) {
|
|
110
|
+
case Protocol.Network.DeviceBoundSessionUrlRuleRuleType.Exclude:
|
|
111
|
+
return i18nString(UIStrings.ruleTypeExclude);
|
|
112
|
+
case Protocol.Network.DeviceBoundSessionUrlRuleRuleType.Include:
|
|
113
|
+
return i18nString(UIStrings.ruleTypeInclude);
|
|
114
|
+
default:
|
|
115
|
+
return ruleType;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const DEFAULT_VIEW = (input: ViewInput, _output: ViewOutput, target: HTMLElement): void => {
|
|
120
|
+
const {sessionAndEvents} = input;
|
|
121
|
+
|
|
122
|
+
if (!sessionAndEvents?.session) {
|
|
123
|
+
render(nothing, target);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const {key, inclusionRules, cookieCravings} = sessionAndEvents.session;
|
|
128
|
+
const sessionDetails = html`
|
|
129
|
+
<devtools-report>
|
|
130
|
+
<devtools-report-section-header>${i18nString(UIStrings.sessionConfig)}</devtools-report-section-header>
|
|
131
|
+
<devtools-report-key>${i18nString(UIStrings.keySite)}</devtools-report-key>
|
|
132
|
+
<devtools-report-value>${key.site}</devtools-report-value>
|
|
133
|
+
<devtools-report-key>${i18nString(UIStrings.keyId)}</devtools-report-key>
|
|
134
|
+
<devtools-report-value>${key.id}</devtools-report-value>
|
|
135
|
+
<devtools-report-key>${i18nString(UIStrings.refreshUrl)}</devtools-report-key>
|
|
136
|
+
<devtools-report-value>${sessionAndEvents.session.refreshUrl}</devtools-report-value>
|
|
137
|
+
<devtools-report-key>${i18nString(UIStrings.expiryDate)}</devtools-report-key>
|
|
138
|
+
<devtools-report-value>${
|
|
139
|
+
new Date(sessionAndEvents.session.expiryDate * 1000).toLocaleString()}</devtools-report-value>
|
|
140
|
+
<devtools-report-key>${i18nString(UIStrings.cachedChallenge)}</devtools-report-key>
|
|
141
|
+
<devtools-report-value>${sessionAndEvents.session.cachedChallenge || ''}</devtools-report-value>
|
|
142
|
+
<devtools-report-key>${i18nString(UIStrings.allowedRefreshInitiators)}</devtools-report-key>
|
|
143
|
+
<devtools-report-value>${sessionAndEvents.session.allowedRefreshInitiators.join(', ')}</devtools-report-value>
|
|
144
|
+
<devtools-report-section-header>${i18nString(UIStrings.scope)}</devtools-report-section-header>
|
|
145
|
+
<devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key>
|
|
146
|
+
<devtools-report-value>${inclusionRules.origin}</devtools-report-value>
|
|
147
|
+
<devtools-report-key>${i18nString(UIStrings.includeSite)}</devtools-report-key>
|
|
148
|
+
<devtools-report-value>${
|
|
149
|
+
inclusionRules.includeSite ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}</devtools-report-value>
|
|
150
|
+
</devtools-report>
|
|
151
|
+
${
|
|
152
|
+
inclusionRules.urlRules.length > 0 ? html`
|
|
153
|
+
<div class="device-bound-session-grid-wrapper">
|
|
154
|
+
<devtools-data-grid class="device-bound-session-url-rules-grid" striped inline>
|
|
155
|
+
<table>
|
|
156
|
+
<thead>
|
|
157
|
+
<tr>
|
|
158
|
+
<th id="should-include" weight="1" sortable>${i18nString(UIStrings.ruleType)}</th>
|
|
159
|
+
<th id="host-pattern" weight="2" sortable>${i18nString(UIStrings.ruleHostPattern)}</th>
|
|
160
|
+
<th id="path-prefix" weight="2" sortable>${i18nString(UIStrings.rulePathPrefix)}</th>
|
|
161
|
+
</tr>
|
|
162
|
+
</thead>
|
|
163
|
+
<tbody>
|
|
164
|
+
${inclusionRules.urlRules.map(rule => html`
|
|
165
|
+
<tr>
|
|
166
|
+
<td>${ruleTypeToString(rule.ruleType)}</td>
|
|
167
|
+
<td>${rule.hostPattern}</td>
|
|
168
|
+
<td>${rule.pathPrefix}</td>
|
|
169
|
+
</tr>
|
|
170
|
+
`)}
|
|
171
|
+
</tbody>
|
|
172
|
+
</table>
|
|
173
|
+
</devtools-data-grid>
|
|
174
|
+
</div>
|
|
175
|
+
` :
|
|
176
|
+
nothing}
|
|
177
|
+
<devtools-report-section-header>${i18nString(UIStrings.cookieCravings)}</devtools-report-section-header>
|
|
178
|
+
${
|
|
179
|
+
cookieCravings.length > 0 ? html`
|
|
180
|
+
<div class="device-bound-session-grid-wrapper">
|
|
181
|
+
<devtools-data-grid class="device-bound-session-cookie-cravings-grid" striped inline>
|
|
182
|
+
<table>
|
|
183
|
+
<thead>
|
|
184
|
+
<tr>
|
|
185
|
+
<th id="name" weight="2" sortable>${i18nString(UIStrings.name)}</th>
|
|
186
|
+
<th id="domain" weight="2" sortable>${i18n.i18n.lockedString('Domain')}</th>
|
|
187
|
+
<th id="path" weight="2" sortable>${i18n.i18n.lockedString('Path')}</th>
|
|
188
|
+
<th id="secure" type="boolean" align="center" weight="1" sortable>${
|
|
189
|
+
i18n.i18n.lockedString('Secure')}</th>
|
|
190
|
+
<th id="http-only" type="boolean" align="center" weight="1" sortable>${
|
|
191
|
+
i18n.i18n.lockedString('HttpOnly')}</th>
|
|
192
|
+
<th id="same-site" weight="1" sortable>${i18n.i18n.lockedString('SameSite')}</th>
|
|
193
|
+
</tr>
|
|
194
|
+
</thead>
|
|
195
|
+
<tbody>
|
|
196
|
+
${cookieCravings.map(craving => html`
|
|
197
|
+
<tr>
|
|
198
|
+
<td>${craving.name}</td>
|
|
199
|
+
<td>${craving.domain}</td>
|
|
200
|
+
<td>${craving.path}</td>
|
|
201
|
+
<td>${craving.secure}</td>
|
|
202
|
+
<td>${craving.httpOnly}</td>
|
|
203
|
+
<td>${craving.sameSite}</td>
|
|
204
|
+
</tr>
|
|
205
|
+
`)}
|
|
206
|
+
</tbody>
|
|
207
|
+
</table>
|
|
208
|
+
</devtools-data-grid>
|
|
209
|
+
</div>
|
|
210
|
+
` :
|
|
211
|
+
nothing}`;
|
|
212
|
+
|
|
213
|
+
render(
|
|
214
|
+
html`
|
|
215
|
+
<style>${UI.inspectorCommonStyles}</style>
|
|
216
|
+
<style>${deviceBoundSessionsViewStyles}</style>
|
|
217
|
+
<div class="device-bound-session-view-wrapper">
|
|
218
|
+
${sessionDetails}
|
|
219
|
+
</div>`,
|
|
220
|
+
target);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export class DeviceBoundSessionsView extends UI.Widget.VBox {
|
|
224
|
+
#site?: string;
|
|
225
|
+
#sessionId?: string;
|
|
226
|
+
#model?: DeviceBoundSessionsModel;
|
|
227
|
+
#view: typeof DEFAULT_VIEW;
|
|
228
|
+
|
|
229
|
+
constructor(view: typeof DEFAULT_VIEW = DEFAULT_VIEW) {
|
|
230
|
+
super({jslog: `${VisualLogging.pane('device-bound-sessions')}`});
|
|
231
|
+
this.#view = view;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
showSession(model: DeviceBoundSessionsModel, site: string, sessionId?: string): void {
|
|
235
|
+
this.#site = site;
|
|
236
|
+
this.#sessionId = sessionId;
|
|
237
|
+
if (this.#model) {
|
|
238
|
+
this.#model.removeEventListener(DeviceBoundSessionModelEvents.EVENT_OCCURRED, this.performUpdate, this);
|
|
239
|
+
}
|
|
240
|
+
this.#model = model;
|
|
241
|
+
this.#model.addEventListener(DeviceBoundSessionModelEvents.EVENT_OCCURRED, this.performUpdate, this);
|
|
242
|
+
this.performUpdate();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
override performUpdate(): void {
|
|
246
|
+
let sessionAndEvents: SessionAndEvents|undefined;
|
|
247
|
+
if (this.#site && this.#model) {
|
|
248
|
+
sessionAndEvents = this.#model.getSession(this.#site, this.#sessionId);
|
|
249
|
+
}
|
|
250
|
+
this.#view({sessionAndEvents}, {}, this.contentElement);
|
|
251
|
+
}
|
|
252
|
+
}
|