Commit 8a617e1f authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

DefaultReportingWhiteList -> IgnoredReportingList.

This is more clear than DefaultReportingAllowList because companies on
the list do NOT get reported.

Also added a unit test for the function.

R=csharp

Bug: 842296
Change-Id: I3ec6141d587f7e90782d7d6051f3a96a677ba2b6
Reviewed-on: https://chromium-review.googlesource.com/c/1464458
Commit-Queue: Joe Mason <joenotcharles@google.com>
Reviewed-by: default avatarChris Sharp <csharp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632321}
parent a06100a9
......@@ -62,7 +62,7 @@ const wchar_t kWindowsCurrentVersionRegKeyName[] =
// "C:\Program Files\Common Files\".
const wchar_t kCommonProgramW6432[] = L"%CommonProgramW6432%";
constexpr const base::char16* kCompanyWhiteList[] = {
constexpr const base::char16* kCompanyIgnoredReportingList[] = {
STRING16_LITERAL("Google LLC"),
STRING16_LITERAL("Google Inc"),
STRING16_LITERAL("Google Inc."),
......@@ -502,31 +502,34 @@ base::string16 FileInformationToString(
return content;
}
bool IsExecutableOnDefaultReportingWhiteList(const base::FilePath& file_path) {
bool IsCompanyOnIgnoredReportingList(const base::string16& company_name) {
return base::ContainsValue(kCompanyIgnoredReportingList, company_name);
}
bool IsExecutableOnIgnoredReportingList(const base::FilePath& file_path) {
std::unique_ptr<FileVersionInfo> file_information(
FileVersionInfo::CreateFileVersionInfo(file_path));
return file_information &&
base::ContainsValue(kCompanyWhiteList,
file_information->company_name());
IsCompanyOnIgnoredReportingList(file_information->company_name());
}
bool RetrieveDetailedFileInformation(
const base::FilePath& file_path,
internal::FileInformation* file_information,
bool* white_listed,
ReportingWhiteListCallback white_list_callback) {
bool* ignored_reporting,
IgnoredReportingCallback ignored_reporting_callback) {
DCHECK(file_information);
DCHECK(white_listed);
DCHECK(ignored_reporting);
base::FilePath expanded_path;
if (!TryToExpandPath(file_path, &expanded_path))
return false;
if (std::move(white_list_callback).Run(file_path)) {
*white_listed = true;
if (std::move(ignored_reporting_callback).Run(file_path)) {
*ignored_reporting = true;
return false;
}
*white_listed = false;
*ignored_reporting = false;
// Retrieve the basic file information.
RetrievePathInformation(expanded_path, file_information);
......@@ -570,9 +573,9 @@ bool RetrieveFileInformation(const base::FilePath& file_path,
bool include_details,
internal::FileInformation* file_information) {
if (include_details) {
bool whitelisted_unused = false;
bool ignored_reporting_unused = false;
return RetrieveDetailedFileInformation(file_path, file_information,
&whitelisted_unused);
&ignored_reporting_unused);
} else {
return RetrieveBasicFileInformation(file_path, file_information);
}
......
......@@ -30,7 +30,7 @@ namespace chrome_cleaner {
class LayeredServiceProviderAPI;
typedef base::OnceCallback<bool(const base::FilePath&)>
ReportingWhiteListCallback;
IgnoredReportingCallback;
// Return the full path of the relative path |input_path| when expanded to the
// 64 bits program files path. Return an empty path when not running on 64 bits
......@@ -97,20 +97,24 @@ void ExpandWow64Path(const base::FilePath& path, base::FilePath* expanded_path);
base::string16 FileInformationToString(
const internal::FileInformation& file_information);
// Returns true if the given |path| refers to an executable which is
// whitelisted so that its details should not be reported.
bool IsExecutableOnDefaultReportingWhiteList(const base::FilePath& file_path);
// Returns true if the given |company_name| is on the list of companies whose
// executables' details should not be reported.
bool IsCompanyOnIgnoredReportingList(const base::string16& company_name);
// Returns true if the given |path| refers to an executable whose details
// should not be reported.
bool IsExecutableOnIgnoredReportingList(const base::FilePath& file_path);
// Retrieve the detailed information for the executable |file_path| and append
// the fields to |file_information|. If the executable is |white_listed|
// according to the given |white_list_callback|, |file_information| stays
// the fields to |file_information|. If the executable sets |ignored_reporting|
// according to the given |ignored_reporting_callback|, |file_information| stays
// unchanged.
bool RetrieveDetailedFileInformation(
const base::FilePath& file_path,
internal::FileInformation* file_information,
bool* white_listed,
ReportingWhiteListCallback white_list_callback =
base::BindOnce(&IsExecutableOnDefaultReportingWhiteList));
bool* ignored_reporting,
IgnoredReportingCallback ignored_reporting_callback =
base::BindOnce(&IsExecutableOnIgnoredReportingList));
// Retrieve the file information path, dates and size into |file_information|.
bool RetrieveBasicFileInformation(const base::FilePath& file_path,
......
......@@ -1239,4 +1239,10 @@ TEST(DiskUtilTests, TruncateLogFileToTail_NotExisting) {
EXPECT_FALSE(base::PathExists(file_path));
}
TEST(DiskUtilTests, IgnoredReportingList) {
EXPECT_TRUE(IsCompanyOnIgnoredReportingList(L"Google LLC"));
EXPECT_FALSE(IsCompanyOnIgnoredReportingList(L"google llc"));
EXPECT_FALSE(IsCompanyOnIgnoredReportingList(L"Unrecognized Inc"));
}
} // namespace chrome_cleaner
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