Skip to content

Commit c83ee4b

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[AI Assistance] Alert after copy
Fixed: 406078894 Change-Id: I6c5a030ab793139535ca03f18b73d5f10445ebb8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6433741 Reviewed-by: Danil Somsikov <dsv@chromium.org> Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
1 parent bec3dc1 commit c83ee4b

File tree

14 files changed

+72
-15
lines changed

14 files changed

+72
-15
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ grd_files_release_sources = [
746746
"front_end/ui/components/cards/cards.js",
747747
"front_end/ui/components/chrome_link/chrome_link.js",
748748
"front_end/ui/components/code_highlighter/code_highlighter.js",
749+
"front_end/ui/components/copy_to_clipboard/copy_to_clipboard.js",
749750
"front_end/ui/components/dialogs/dialogs.js",
750751
"front_end/ui/components/diff_view/diff_view.js",
751752
"front_end/ui/components/expandable_list/expandable_list.js",
@@ -2278,6 +2279,7 @@ grd_files_debug_sources = [
22782279
"front_end/ui/components/chrome_link/chromeLink.css.js",
22792280
"front_end/ui/components/code_highlighter/CodeHighlighter.js",
22802281
"front_end/ui/components/code_highlighter/codeHighlighter.css.js",
2282+
"front_end/ui/components/copy_to_clipboard/copyToClipboard.js",
22812283
"front_end/ui/components/dialogs/ButtonDialog.js",
22822284
"front_end/ui/components/dialogs/Dialog.js",
22832285
"front_end/ui/components/dialogs/ShortcutDialog.js",

front_end/core/host/InspectorFrontendHostAPI.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ export interface InspectorFrontendHostAPI {
299299

300300
closeWindow(): void;
301301

302+
/**
303+
* Don't use directly - use {@link CopyToClipboard.copyTextToClipboard} instead.
304+
* @deprecated Marked to restrict usage.
305+
*/
302306
copyText(text: string|null|undefined): void;
303307

304308
inspectedURLChanged(url: Platform.DevToolsPath.UrlString): void;

front_end/core/sdk/DOMModel.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
3737
import * as Protocol from '../../generated/protocol.js';
3838
import * as Common from '../common/common.js';
39-
import * as Host from '../host/host.js';
4039
import * as Platform from '../platform/platform.js';
4140
import * as Root from '../root/root.js';
4241

@@ -574,14 +573,6 @@ export class DOMNode {
574573
});
575574
}
576575

577-
async copyNode(): Promise<string|null> {
578-
const {outerHTML} = await this.#agent.invoke_getOuterHTML({nodeId: this.id});
579-
if (outerHTML !== null) {
580-
Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(outerHTML);
581-
}
582-
return outerHTML;
583-
}
584-
585576
path(): string {
586577
function getNodeKey(node: DOMNode): number|'u'|'a'|'d'|null {
587578
if (!node.#nodeNameInternal.length) {

front_end/panels/changes/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ devtools_module("changes") {
3434
"../../panels/snippets:bundle",
3535
"../../panels/utils:bundle",
3636
"../../third_party/diff:bundle",
37+
"../../ui/components/copy_to_clipboard:bundle",
3738
"../../ui/components/diff_view:bundle",
3839
"../../ui/legacy:bundle",
3940
"../../ui/lit:bundle",

front_end/panels/changes/CombinedDiffView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/* eslint-disable rulesdir/no-lit-render-outside-of-view */
55

66
import * as Common from '../../core/common/common.js';
7-
import * as Host from '../../core/host/host.js';
87
import * as i18n from '../../core/i18n/i18n.js';
98
import * as Platform from '../../core/platform/platform.js';
109
import * as Persistence from '../../models/persistence/persistence.js';
1110
import type * as Workspace from '../../models/workspace/workspace.js';
1211
import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js';
1312
import type * as Diff from '../../third_party/diff/diff.js';
1413
import * as Buttons from '../../ui/components/buttons/buttons.js';
14+
import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js';
1515
import type * as DiffView from '../../ui/components/diff_view/diff_view.js';
1616
import * as UI from '../../ui/legacy/legacy.js';
1717
import * as Lit from '../../ui/lit/lit.js';
@@ -133,7 +133,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
133133
return;
134134
}
135135

136-
Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(content.text);
136+
CopyToClipboard.copyTextToClipboard(content.text, i18nString(UIStrings.copied));
137137
this.#copiedFiles[fileUrl] = true;
138138
this.requestUpdate();
139139
setTimeout(() => {

front_end/panels/elements/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ devtools_module("elements") {
9090
"../../panels/utils:bundle",
9191
"../../ui/components/adorners:bundle",
9292
"../../ui/components/code_highlighter:bundle",
93+
"../../ui/components/copy_to_clipboard:bundle",
9394
"../../ui/components/floating_button:bundle",
9495
"../../ui/components/highlighting:bundle",
9596
"../../ui/components/text_editor:bundle",

front_end/panels/elements/ElementsTreeOutline.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import * as SDK from '../../core/sdk/sdk.js';
4141
import * as IssuesManager from '../../models/issues_manager/issues_manager.js';
4242
import * as Adorners from '../../ui/components/adorners/adorners.js';
4343
import * as CodeHighlighter from '../../ui/components/code_highlighter/code_highlighter.js';
44+
import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js';
4445
import * as IconButton from '../../ui/components/icon_button/icon_button.js';
4546
import * as IssueCounter from '../../ui/components/issue_counter/issue_counter.js';
4647
import * as UI from '../../ui/legacy/legacy.js';
@@ -376,8 +377,11 @@ export class ElementsTreeOutline extends
376377
if (isCut && (node.isShadowRoot() || node.ancestorUserAgentShadowRoot())) {
377378
return;
378379
}
379-
380-
void node.copyNode();
380+
void node.getOuterHTML().then(outerHTML => {
381+
if (outerHTML !== null) {
382+
CopyToClipboard.copyTextToClipboard(outerHTML);
383+
}
384+
});
381385
this.setClipboardData({node, isCut});
382386
}
383387

front_end/panels/timeline/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ devtools_module("timeline") {
116116
"../../services/trace_bounds:bundle",
117117
"../../ui/components/buttons:bundle",
118118
"../../ui/components/code_highlighter:bundle", # trace event highlighting
119+
"../../ui/components/copy_to_clipboard:bundle",
119120
"../../ui/components/icon_button:bundle",
120121
"../../ui/components/linkifier:bundle",
121122
"../../ui/components/menus:bundle",

front_end/panels/timeline/TimelineSelectorStatsView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as i18n from '../../core/i18n/i18n.js';
1111
import * as SDK from '../../core/sdk/sdk.js';
1212
import type * as Protocol from '../../generated/protocol.js';
1313
import * as Trace from '../../models/trace/trace.js';
14+
import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js';
1415
import type * as Linkifier from '../../ui/components/linkifier/linkifier.js';
1516
import * as UI from '../../ui/legacy/legacy.js';
1617
import {html, render} from '../../ui/lit/lit.js';
@@ -215,8 +216,7 @@ export class TimelineSelectorStatsView extends UI.Widget.VBox {
215216
].join('\t'));
216217
}
217218
const data = tableData.join('\n');
218-
void navigator.clipboard.writeText(data);
219-
UI.ARIAUtils.alert(i18nString(UIStrings.tableCopiedToClipboard));
219+
CopyToClipboard.copyTextToClipboard(data, i18nString(UIStrings.tableCopiedToClipboard));
220220
});
221221
}
222222

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
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("../../../../scripts/build/ninja/devtools_entrypoint.gni")
6+
import("../../../../scripts/build/ninja/devtools_module.gni")
7+
import("../../../../scripts/build/ninja/generate_css.gni")
8+
import("../../../../scripts/build/typescript/typescript.gni")
9+
import("../visibility.gni")
10+
11+
devtools_module("copy_to_clipboard") {
12+
sources = [ "copyToClipboard.ts" ]
13+
14+
deps = [
15+
"../../../core/host:bundle",
16+
"../../../ui/legacy:bundle",
17+
]
18+
}
19+
20+
devtools_entrypoint("bundle") {
21+
entrypoint = "copy_to_clipboard.ts"
22+
23+
deps = [ ":copy_to_clipboard" ]
24+
25+
visibility = default_components_visibility
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
// Copyright 2025 The Chromium Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style license that can be
4+
// found in the LICENSE file.
5+
6+
import * as Host from '../../../core/host/host.js';
7+
import * as UI from '../../legacy/legacy.js';
8+
9+
/**
10+
* @param text Text to copy to clipboard
11+
* @param alert Message to send for a11y
12+
*/
13+
export function copyTextToClipboard(text: string, alert?: string): void {
14+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(text);
15+
// TODO: make alert required.
16+
if (alert) {
17+
UI.ARIAUtils.alert(alert);
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
export {copyTextToClipboard} from './copyToClipboard.js';

front_end/ui/legacy/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ devtools_entrypoint("bundle") {
144144
"../../panels/*",
145145
"../../services/window_bounds/*",
146146
"../../testing/*",
147+
"../components/copy_to_clipboard:*",
147148
"../components/data_grid:*",
148149
"../components/docs/combo_box/*",
149150
"../components/docs/performance_panel/*",

front_end/ui/visual_logging/KnownContextValues.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ export const knownContextValues = new Set([
489489
'autofill-view',
490490
'autofill-view-documentation',
491491
'autofill-view-feedback',
492+
'automatic-workspace-folders',
492493
'automatic-workspace-folders.connect',
493494
'automatically-ignore-list-known-third-party-scripts',
494495
'auxclick',
@@ -3345,6 +3346,7 @@ export const knownContextValues = new Set([
33453346
'src',
33463347
'srgb',
33473348
'stack-trace',
3349+
'stage-to-workspace',
33483350
'stalled',
33493351
'standard-emulated-device-list',
33503352
'start',

0 commit comments

Comments
 (0)