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[] = ...@@ -62,7 +62,7 @@ const wchar_t kWindowsCurrentVersionRegKeyName[] =
// "C:\Program Files\Common Files\". // "C:\Program Files\Common Files\".
const wchar_t kCommonProgramW6432[] = L"%CommonProgramW6432%"; const wchar_t kCommonProgramW6432[] = L"%CommonProgramW6432%";
constexpr const base::char16* kCompanyWhiteList[] = { constexpr const base::char16* kCompanyIgnoredReportingList[] = {
STRING16_LITERAL("Google LLC"), STRING16_LITERAL("Google LLC"),
STRING16_LITERAL("Google Inc"), STRING16_LITERAL("Google Inc"),
STRING16_LITERAL("Google Inc."), STRING16_LITERAL("Google Inc."),
...@@ -502,31 +502,34 @@ base::string16 FileInformationToString( ...@@ -502,31 +502,34 @@ base::string16 FileInformationToString(
return content; 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( std::unique_ptr<FileVersionInfo> file_information(
FileVersionInfo::CreateFileVersionInfo(file_path)); FileVersionInfo::CreateFileVersionInfo(file_path));
return file_information && return file_information &&
base::ContainsValue(kCompanyWhiteList, IsCompanyOnIgnoredReportingList(file_information->company_name());
file_information->company_name());
} }
bool RetrieveDetailedFileInformation( bool RetrieveDetailedFileInformation(
const base::FilePath& file_path, const base::FilePath& file_path,
internal::FileInformation* file_information, internal::FileInformation* file_information,
bool* white_listed, bool* ignored_reporting,
ReportingWhiteListCallback white_list_callback) { IgnoredReportingCallback ignored_reporting_callback) {
DCHECK(file_information); DCHECK(file_information);
DCHECK(white_listed); DCHECK(ignored_reporting);
base::FilePath expanded_path; base::FilePath expanded_path;
if (!TryToExpandPath(file_path, &expanded_path)) if (!TryToExpandPath(file_path, &expanded_path))
return false; return false;
if (std::move(white_list_callback).Run(file_path)) { if (std::move(ignored_reporting_callback).Run(file_path)) {
*white_listed = true; *ignored_reporting = true;
return false; return false;
} }
*white_listed = false; *ignored_reporting = false;
// Retrieve the basic file information. // Retrieve the basic file information.
RetrievePathInformation(expanded_path, file_information); RetrievePathInformation(expanded_path, file_information);
...@@ -570,9 +573,9 @@ bool RetrieveFileInformation(const base::FilePath& file_path, ...@@ -570,9 +573,9 @@ bool RetrieveFileInformation(const base::FilePath& file_path,
bool include_details, bool include_details,
internal::FileInformation* file_information) { internal::FileInformation* file_information) {
if (include_details) { if (include_details) {
bool whitelisted_unused = false; bool ignored_reporting_unused = false;
return RetrieveDetailedFileInformation(file_path, file_information, return RetrieveDetailedFileInformation(file_path, file_information,
&whitelisted_unused); &ignored_reporting_unused);
} else { } else {
return RetrieveBasicFileInformation(file_path, file_information); return RetrieveBasicFileInformation(file_path, file_information);
} }
......
...@@ -30,7 +30,7 @@ namespace chrome_cleaner { ...@@ -30,7 +30,7 @@ namespace chrome_cleaner {
class LayeredServiceProviderAPI; class LayeredServiceProviderAPI;
typedef base::OnceCallback<bool(const base::FilePath&)> typedef base::OnceCallback<bool(const base::FilePath&)>
ReportingWhiteListCallback; IgnoredReportingCallback;
// Return the full path of the relative path |input_path| when expanded to the // 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 // 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); ...@@ -97,20 +97,24 @@ void ExpandWow64Path(const base::FilePath& path, base::FilePath* expanded_path);
base::string16 FileInformationToString( base::string16 FileInformationToString(
const internal::FileInformation& file_information); const internal::FileInformation& file_information);
// Returns true if the given |path| refers to an executable which is // Returns true if the given |company_name| is on the list of companies whose
// whitelisted so that its details should not be reported. // executables' details should not be reported.
bool IsExecutableOnDefaultReportingWhiteList(const base::FilePath& file_path); 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 // Retrieve the detailed information for the executable |file_path| and append
// the fields to |file_information|. If the executable is |white_listed| // the fields to |file_information|. If the executable sets |ignored_reporting|
// according to the given |white_list_callback|, |file_information| stays // according to the given |ignored_reporting_callback|, |file_information| stays
// unchanged. // unchanged.
bool RetrieveDetailedFileInformation( bool RetrieveDetailedFileInformation(
const base::FilePath& file_path, const base::FilePath& file_path,
internal::FileInformation* file_information, internal::FileInformation* file_information,
bool* white_listed, bool* ignored_reporting,
ReportingWhiteListCallback white_list_callback = IgnoredReportingCallback ignored_reporting_callback =
base::BindOnce(&IsExecutableOnDefaultReportingWhiteList)); base::BindOnce(&IsExecutableOnIgnoredReportingList));
// Retrieve the file information path, dates and size into |file_information|. // Retrieve the file information path, dates and size into |file_information|.
bool RetrieveBasicFileInformation(const base::FilePath& file_path, bool RetrieveBasicFileInformation(const base::FilePath& file_path,
......
...@@ -1239,4 +1239,10 @@ TEST(DiskUtilTests, TruncateLogFileToTail_NotExisting) { ...@@ -1239,4 +1239,10 @@ TEST(DiskUtilTests, TruncateLogFileToTail_NotExisting) {
EXPECT_FALSE(base::PathExists(file_path)); 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 } // 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