Skip to content

Commit 2e3e2b2

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[network] Improve discoverability of unsanitized HAR download.
The previous UX used the long click functionality, which isn't particularly discoverable. This is now replaced with a button that opens a menu in case the option to generate HAR files with sensitive data is enabled. Screenshot: https://i.imgur.com/ksvY4tn.png Fixed: 378076279 Bug: 361717594 Change-Id: Ic2dc7c34a672b942705123dee225ddb82706a36d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6012182 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Simon Zünd <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]>
1 parent 2af1fdd commit 2e3e2b2

File tree

1 file changed

+40
-32
lines changed

1 file changed

+40
-32
lines changed

front_end/panels/network/NetworkPanel.ts

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,29 @@ const UIStrings = {
125125
*/
126126
importHarFile: 'Import `HAR` file...',
127127
/**
128-
* @description Tooltip text that appears when hovering over the largeicon download button in the
129-
* Network Panel. HAR is a file format (HTTP Archive) and should not be translated. This action
130-
* triggers the download of a HAR file.
128+
* @description Tooltip text that appears when hovering over the download button in the Network
129+
* panel, when the setting to allow generating HAR files with sensitive data is enabled. HAR is
130+
* a file format (HTTP Archive) and should not be translated. This action triggers a context
131+
* menu with two options, one to download HAR sanitized and one to download HAR with sensitive
132+
* data.
133+
*/
134+
exportHar: 'Export `HAR` (either sanitized or with sensitive data)',
135+
/**
136+
* @description Tooltip text that appears when hovering over the download button in the Network
137+
* panel, when the setting to allow generating HAR files with sensitive data is disabled. HAR is
138+
* a file format (HTTP Archive) and should not be translated. This action triggers the download
139+
* of a HAR file.
140+
*
141+
* This string is also used as the first item in the context menu for the download button in
142+
* the Network panel, when the setting to allow generating HAR files with sensitive data is
143+
* enabled.
131144
*/
132145
exportHarSanitized: 'Export `HAR` (sanitized)...',
133146
/**
134-
* @description Context menu item in the export long click button of the Network panel, which is
135-
* only available when the Network setting to allow generating HAR with sensitive data is active.
136-
* HAR is a file format (HTTP Archive) and should not be translated. This action triggers the
137-
* download of a HAR file with sensitive data included.
147+
* @description Context menu item in the context menu for the download button of the Network panel,
148+
* which is only available when the Network setting to allow generating HAR with sensitive data
149+
* is active. HAR is a file format (HTTP Archive) and should not be translated. This action
150+
* triggers the download of a HAR file with sensitive data included.
138151
*/
139152
exportHarWithSensitiveData: 'Export `HAR` (with sensitive data)...',
140153
/**
@@ -470,6 +483,19 @@ export class NetworkPanel extends UI.Panel.Panel implements
470483
this.networkRecordFilmStripSetting, i18nString(UIStrings.captureScreenshotsWhenLoadingA),
471484
i18nString(UIStrings.captureScreenshots)));
472485

486+
const exportHarContextMenu = (contextMenu: UI.ContextMenu.ContextMenu): void => {
487+
contextMenu.defaultSection().appendItem(
488+
i18nString(UIStrings.exportHarSanitized),
489+
this.networkLogView.exportAll.bind(this.networkLogView, {sanitize: true}),
490+
{jslogContext: 'export-har'},
491+
);
492+
contextMenu.defaultSection().appendItem(
493+
i18nString(UIStrings.exportHarWithSensitiveData),
494+
this.networkLogView.exportAll.bind(this.networkLogView, {sanitize: false}),
495+
{jslogContext: 'export-har-with-sensitive-data'},
496+
);
497+
};
498+
473499
this.panelToolbar.appendSeparator();
474500
const importHarButton =
475501
new UI.Toolbar.ToolbarButton(i18nString(UIStrings.importHarFile), 'import', undefined, 'import-har');
@@ -482,35 +508,17 @@ export class NetworkPanel extends UI.Panel.Panel implements
482508
UI.Toolbar.ToolbarButton.Events.CLICK,
483509
this.networkLogView.exportAll.bind(this.networkLogView, {sanitize: true}), this);
484510
this.panelToolbar.appendToolbarItem(exportHarButton);
511+
const exportHarMenuButton = new UI.Toolbar.ToolbarMenuButton(
512+
exportHarContextMenu, /* isIconDropdown */ true, /* useSoftMenu */ false, 'export-har-menu', 'download');
513+
exportHarMenuButton.setTitle(i18nString(UIStrings.exportHar));
514+
this.panelToolbar.appendToolbarItem(exportHarMenuButton);
485515

486-
// Support for exporting HAR (with sensitive data), which is added via a long-click
487-
// context menu on the Export button in the Network panel.
488-
// Checkout https://goo.gle/devtools-har-exclude-cookies-design for more details.
489516
const networkShowOptionsToGenerateHarWithSensitiveData = Common.Settings.Settings.instance().createSetting(
490517
'network.show-options-to-generate-har-with-sensitive-data', false);
491-
let controller: UI.UIUtils.LongClickController|null = null;
492518
const updateShowOptionsToGenerateHarWithSensitiveData = (): void => {
493-
exportHarButton.setLongClickable(networkShowOptionsToGenerateHarWithSensitiveData.get());
494-
if (controller !== null) {
495-
controller.dispose();
496-
controller = null;
497-
}
498-
if (networkShowOptionsToGenerateHarWithSensitiveData.get()) {
499-
controller = new UI.UIUtils.LongClickController(exportHarButton.element, event => {
500-
const contextMenu = new UI.ContextMenu.ContextMenu(event);
501-
contextMenu.defaultSection().appendItem(
502-
i18nString(UIStrings.exportHarSanitized),
503-
this.networkLogView.exportAll.bind(this.networkLogView, {sanitize: true}),
504-
{jslogContext: 'export-har'},
505-
);
506-
contextMenu.defaultSection().appendItem(
507-
i18nString(UIStrings.exportHarWithSensitiveData),
508-
this.networkLogView.exportAll.bind(this.networkLogView, {sanitize: false}),
509-
{jslogContext: 'export-har-with-sensitive-data'},
510-
);
511-
void contextMenu.show();
512-
});
513-
}
519+
const showOptionsToGenerateHarWithSensitiveData = networkShowOptionsToGenerateHarWithSensitiveData.get();
520+
exportHarButton.setVisible(!showOptionsToGenerateHarWithSensitiveData);
521+
exportHarMenuButton.setVisible(showOptionsToGenerateHarWithSensitiveData);
514522
};
515523
networkShowOptionsToGenerateHarWithSensitiveData.addChangeListener(updateShowOptionsToGenerateHarWithSensitiveData);
516524
updateShowOptionsToGenerateHarWithSensitiveData();

0 commit comments

Comments
 (0)