Commit 049e50ca authored by Che-yu Wu's avatar Che-yu Wu Committed by Commit Bot

Highlight filename in filepaths detected by Chrome Cleanup Tool.

Highlight the file name with strong tag, so that users can scan the list easily.

Bug: crbug.com/883737
Change-Id: Iaccf05983efe0414ce39fe35c1c89be4b4102d12
Reviewed-on: https://chromium-review.googlesource.com/1231835
Commit-Queue: Che-yu Wu <cheyuw@google.com>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarproberge <proberge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592912}
parent 25a5ed92
...@@ -90,19 +90,22 @@ ...@@ -90,19 +90,22 @@
id="files-to-remove-list" id="files-to-remove-list"
hidden="[[!hasFilesToShow_]]" hidden="[[!hasFilesToShow_]]"
title="$i18n{chromeCleanupDetailsFilesAndPrograms}" title="$i18n{chromeCleanupDetailsFilesAndPrograms}"
items-to-show="[[scannerResults_.files]]"> items-to-show="[[
getListEntriesFromFilePaths_(scannerResults_.files)]]">
</items-to-remove-list> </items-to-remove-list>
<items-to-remove-list <items-to-remove-list
id="registry-keys-list" id="registry-keys-list"
hidden="[[!hasRegistryKeysToShow_]]" hidden="[[!hasRegistryKeysToShow_]]"
title="$i18n{chromeCleanupDetailsRegistryEntries}" title="$i18n{chromeCleanupDetailsRegistryEntries}"
items-to-show="[[scannerResults_.registryKeys]]"> items-to-show="[[
getListEntriesFromStrings_(scannerResults_.registryKeys)]]">
</items-to-remove-list> </items-to-remove-list>
<items-to-remove-list <items-to-remove-list
id="extensions-list" id="extensions-list"
hidden="[[!hasExtensionsToShow_]]" hidden="[[!hasExtensionsToShow_]]"
title="$i18n{chromeCleanupDetailsExtensions}" title="$i18n{chromeCleanupDetailsExtensions}"
items-to-show="[[scannerResults_.extensions]]"> items-to-show="[[
getListEntriesFromStrings_(scannerResults_.extensions)]]">
</items-to-remove-list> </items-to-remove-list>
<div class="settings-box continuation"> <div class="settings-box continuation">
<div class="secondary"> <div class="secondary">
......
...@@ -77,8 +77,18 @@ settings.ChromeCleanupCardActionButton; ...@@ -77,8 +77,18 @@ settings.ChromeCleanupCardActionButton;
settings.ChromeCleanupCardComponents; settings.ChromeCleanupCardComponents;
/** /**
* Represents the file path structure of a base::FilePath.
* dirname ends with a separator.
* @typedef {{ * @typedef {{
* files: Array<string>, * dirname: string,
* basename: string,
* }}
*/
settings.ChromeCleanupFilePath;
/**
* @typedef {{
* files: Array<settings.ChromeCleanupFilePath>,
* registryKeys: Array<string>, * registryKeys: Array<string>,
* extensions: Array<string>, * extensions: Array<string>,
* }} * }}
...@@ -741,4 +751,23 @@ Polymer({ ...@@ -741,4 +751,23 @@ Polymer({
], ],
]); ]);
}, },
/**
* @param {!Array<string>} list
* @return {!Array<settings.ChromeCleanupRemovalListItem>}
* @private
*/
getListEntriesFromStrings_: function(list) {
return list.map(entry => ({text: entry, highlightSuffix: null}));
},
/**
* @param {!Array<settings.ChromeCleanupFilePath>} paths
* @return {!Array<settings.ChromeCleanupRemovalListItem>}
* @private
*/
getListEntriesFromFilePaths_: function(paths) {
return paths.map(
path => ({text: path.dirname, highlightSuffix: path.basename}));
},
}); });
...@@ -25,11 +25,21 @@ ...@@ -25,11 +25,21 @@
margin-top: -1em; margin-top: -1em;
} }
.highlight-suffix {
font-weight: bold;
}
</style> </style>
<div id="title" class="secondary">[[title]]</div> <div id="title" class="secondary">[[title]]</div>
<ul class="secondary"> <ul class="secondary">
<template is="dom-repeat" items="[[initialItems_]]"> <template is="dom-repeat" items="[[initialItems_]]">
<li class="visible-item">[[item]]</li> <li class="visible-item">
<span>[[item.text]]</span><!--
--><span class="highlight-suffix"
hidden="[[!hasHighlightSuffix_(item)]]"><!--
-->[[item.highlightSuffix]]
</span>
</li>
</template> </template>
<li id="more-items-link" hidden="[[expanded_]]" on-click="expandList_"> <li id="more-items-link" hidden="[[expanded_]]" on-click="expandList_">
[[moreItemsLinkText_]] [[moreItemsLinkText_]]
...@@ -44,7 +54,13 @@ ...@@ -44,7 +54,13 @@
expected action. --> expected action. -->
<ul id="remaining-list" hidden="[[!expanded_]]" class="secondary"> <ul id="remaining-list" hidden="[[!expanded_]]" class="secondary">
<template is="dom-repeat" items="[[remainingItems_]]"> <template is="dom-repeat" items="[[remainingItems_]]">
<li class$="[[remainingItemsClass_(expanded_)]]">[[item]]</li> <li class$="[[remainingItemsClass_(expanded_)]]">
<span>[[item.text]]</span><!--
--><span class="highlight-suffix"
hidden="[[!hasHighlightSuffix_(item)]]"><!--
-->[[item.highlightSuffix]]
</span>
</li>
</template> </template>
</ul> </ul>
</template> </template>
......
...@@ -4,6 +4,17 @@ ...@@ -4,6 +4,17 @@
cr.exportPath('settings'); cr.exportPath('settings');
/**
* For each line in the item list, the text field will be shown in normal style
* at front of the line. The highlightSuffix will be appended to the end of line
* and emphasized with bold font.
* @typedef {{
* text: string,
* highlightSuffix: ?string,
* }}
*/
settings.ChromeCleanupRemovalListItem;
/** /**
* The default number of items to show for files, registry keys and extensions * The default number of items to show for files, registry keys and extensions
* on the detailed view when user-initiated cleanups are enabled. * on the detailed view when user-initiated cleanups are enabled.
...@@ -37,7 +48,7 @@ Polymer({ ...@@ -37,7 +48,7 @@ Polymer({
value: '', value: '',
}, },
/** @type {!Array<string>} */ /** @type {!Array<settings.ChromeCleanupRemovalListItem>} */
itemsToShow: { itemsToShow: {
type: Array, type: Array,
observer: 'updateVisibleState_', observer: 'updateVisibleState_',
...@@ -55,7 +66,7 @@ Polymer({ ...@@ -55,7 +66,7 @@ Polymer({
/** /**
* The first |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items of |itemsToShow| * The first |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items of |itemsToShow|
* if the list is longer than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|. * if the list is longer than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|.
* @private {?Array<string>} * @private {?Array<settings.ChromeCleanupRemovalListItem>}
*/ */
initialItems_: Array, initialItems_: Array,
...@@ -63,7 +74,7 @@ Polymer({ ...@@ -63,7 +74,7 @@ Polymer({
* The remaining items to be presented that are not included in * The remaining items to be presented that are not included in
* |initialItems_|. Items in this list are only shown to the user if * |initialItems_|. Items in this list are only shown to the user if
* |expanded_| is true. * |expanded_| is true.
* @private {?Array<string>} * @private {?Array<settings.ChromeCleanupRemovalListItem>}
*/ */
remainingItems_: Array, remainingItems_: Array,
...@@ -95,7 +106,7 @@ Polymer({ ...@@ -95,7 +106,7 @@ Polymer({
* the user will contain exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| * the user will contain exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* elements, and the last one will be the "show more" link. * elements, and the last one will be the "show more" link.
* *
* @param {!Array<string>} itemsToShow * @param {!Array<settings.ChromeCleanupRemovalListItem>} itemsToShow
*/ */
updateVisibleState_: function(itemsToShow) { updateVisibleState_: function(itemsToShow) {
// Start expanded if there are less than // Start expanded if there are less than
...@@ -130,4 +141,13 @@ Polymer({ ...@@ -130,4 +141,13 @@ Polymer({
remainingItemsClass_: function(expanded) { remainingItemsClass_: function(expanded) {
return expanded ? 'visible-item' : 'hidden-item'; return expanded ? 'visible-item' : 'hidden-item';
}, },
/**
* @param {settings.ChromeCleanupRemovalListItem} item
* @return {boolean} Whether a highlight suffix exists.
* @private
*/
hasHighlightSuffix_: function(item) {
return item.highlightSuffix !== null;
},
}); });
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
...@@ -38,9 +39,12 @@ namespace { ...@@ -38,9 +39,12 @@ namespace {
std::unique_ptr<base::ListValue> GetFilesAsListStorage( std::unique_ptr<base::ListValue> GetFilesAsListStorage(
const std::set<base::FilePath>& files) { const std::set<base::FilePath>& files) {
auto value = std::make_unique<base::ListValue>(); auto value = std::make_unique<base::ListValue>();
for (const base::FilePath& path : files) for (const base::FilePath& path : files) {
value->AppendString(path.value()); auto item = std::make_unique<base::DictionaryValue>();
item->SetString("dirname", path.DirName().AsEndingWithSeparator().value());
item->SetString("basename", path.BaseName().value());
value->Append(std::move(item));
}
return value; return value;
} }
......
...@@ -71,9 +71,15 @@ let chromeCleanupPage = null; ...@@ -71,9 +71,15 @@ let chromeCleanupPage = null;
/** @type {?TestDownloadsBrowserProxy} */ /** @type {?TestDownloadsBrowserProxy} */
let chromeCleanupProxy = null; let chromeCleanupProxy = null;
const shortFileList = ['file 1', 'file 2', 'file 3']; const shortFileList = [
const exactSizeFileList = ['file 1', 'file 2', 'file 3', 'file 4']; {'dirname': 'C:\\', 'basename': 'file 1'},
const longFileList = ['file 1', 'file 2', 'file 3', 'file 4', 'file 5']; {'dirname': 'C:\\', 'basename': 'file 2'},
{'dirname': 'C:\\', 'basename': 'file 3'},
];
const exactSizeFileList =
shortFileList.concat([{'dirname': 'C:\\', 'basename': 'file 4'}]);
const longFileList =
exactSizeFileList.concat([{'dirname': 'C:\\', 'basename': 'file 5'}]);
const shortRegistryKeysList = ['key 1', 'key 2']; const shortRegistryKeysList = ['key 1', 'key 2'];
const exactSizeRegistryKeysList = ['key 1', 'key 2', 'key 3', 'key 4']; const exactSizeRegistryKeysList = ['key 1', 'key 2', 'key 3', 'key 4'];
const longRegistryKeysList = const longRegistryKeysList =
...@@ -126,6 +132,22 @@ function validateVisibleItemsList(originalItems, visibleItems) { ...@@ -126,6 +132,22 @@ function validateVisibleItemsList(originalItems, visibleItems) {
} }
} }
/**
* @param {!Array} originalItems
* @param {!Element} container
* @param {boolean} expectSuffix Whether a highlight suffix should exist.
*/
function validateHighlightSuffix(originalItems, container, expectSuffix) {
let itemList =
container.shadowRoot.querySelectorAll('li:not(#more-items-link)');
assertEquals(originalItems.length, itemList.length);
for (let item of itemList) {
let suffixes = item.querySelectorAll('.highlight-suffix');
assertEquals(suffixes.length, 1);
assertEquals(expectSuffix, !suffixes[0].hidden);
}
}
/** /**
* @param {!Array} files The list of files to be cleaned. * @param {!Array} files The list of files to be cleaned.
* @param {!Array} registryKeys The list of registry entries to be cleaned. * @param {!Array} registryKeys The list of registry entries to be cleaned.
...@@ -151,6 +173,7 @@ function startCleanupFromInfected(files, registryKeys, extensions) { ...@@ -151,6 +173,7 @@ function startCleanupFromInfected(files, registryKeys, extensions) {
const filesToRemoveList = chromeCleanupPage.$$('#files-to-remove-list'); const filesToRemoveList = chromeCleanupPage.$$('#files-to-remove-list');
assertTrue(!!filesToRemoveList); assertTrue(!!filesToRemoveList);
validateVisibleItemsList(files, filesToRemoveList); validateVisibleItemsList(files, filesToRemoveList);
validateHighlightSuffix(files, filesToRemoveList, true /* expectSuffix */);
const registryKeysListContainer = chromeCleanupPage.$$('#registry-keys-list'); const registryKeysListContainer = chromeCleanupPage.$$('#registry-keys-list');
assertTrue(!!registryKeysListContainer); assertTrue(!!registryKeysListContainer);
...@@ -158,6 +181,8 @@ function startCleanupFromInfected(files, registryKeys, extensions) { ...@@ -158,6 +181,8 @@ function startCleanupFromInfected(files, registryKeys, extensions) {
assertFalse(registryKeysListContainer.hidden); assertFalse(registryKeysListContainer.hidden);
assertTrue(!!registryKeysListContainer); assertTrue(!!registryKeysListContainer);
validateVisibleItemsList(registryKeys, registryKeysListContainer); validateVisibleItemsList(registryKeys, registryKeysListContainer);
validateHighlightSuffix(
registryKeys, registryKeysListContainer, false /* expectSuffix */);
} else { } else {
assertTrue(registryKeysListContainer.hidden); assertTrue(registryKeysListContainer.hidden);
} }
...@@ -168,6 +193,8 @@ function startCleanupFromInfected(files, registryKeys, extensions) { ...@@ -168,6 +193,8 @@ function startCleanupFromInfected(files, registryKeys, extensions) {
assertFalse(extensionsListContainer.hidden); assertFalse(extensionsListContainer.hidden);
assertTrue(!!extensionsListContainer); assertTrue(!!extensionsListContainer);
validateVisibleItemsList(extensions, extensionsListContainer); validateVisibleItemsList(extensions, extensionsListContainer);
validateHighlightSuffix(
extensions, extensionsListContainer, false /* expectSuffix */);
} else { } else {
assertTrue(extensionsListContainer.hidden); assertTrue(extensionsListContainer.hidden);
} }
......
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