| Index: chrome/browser/metrics/antivirus_metrics_provider_win.cc
|
| diff --git a/chrome/browser/metrics/antivirus_metrics_provider_win.cc b/chrome/browser/metrics/antivirus_metrics_provider_win.cc
|
| index ada7c8a7cb55c818c32112f70b28ed83d687dc03..2328b73abbf04ebe869d2babbb6d76bd6bf7a649 100644
|
| --- a/chrome/browser/metrics/antivirus_metrics_provider_win.cc
|
| +++ b/chrome/browser/metrics/antivirus_metrics_provider_win.cc
|
| @@ -10,6 +10,7 @@
|
| #include <windows.h>
|
| #include <wscapi.h>
|
|
|
| +#include <algorithm>
|
| #include <string>
|
|
|
| #include "base/bind.h"
|
| @@ -21,6 +22,7 @@
|
| #include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/path_service.h"
|
| +#include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/task_runner_util.h"
|
| @@ -57,6 +59,20 @@ struct PRODUCT_STATE {
|
|
|
| static_assert(sizeof(PRODUCT_STATE) == 4, "Wrong packing!");
|
|
|
| +// Filter any part of a product string that looks like it might be a version
|
| +// number. Returns true if the part should be removed from the product name.
|
| +bool ShouldFilterPart(const std::string& str) {
|
| + // Special case for "360" (used by Norton), "365" (used by Kaspersky) and
|
| + // "NOD32" (used by ESET).
|
| + if (str == "365" || str == "360" || str == "NOD32")
|
| + return false;
|
| + for (const auto ch : str) {
|
| + if (isdigit(ch))
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| bool ShouldReportFullNames() {
|
| // The expectation is that this will be disabled for the majority of users,
|
| // but this allows a small group to be enabled on other channels if there are
|
| @@ -185,6 +201,22 @@ AntiVirusMetricsProvider::GetAntiVirusProductsOnFileThread() {
|
| return av_products;
|
| }
|
|
|
| +std::string AntiVirusMetricsProvider::TrimVersionOfAvProductName(
|
| + const std::string& av_product) {
|
| + auto av_product_parts = base::SplitString(
|
| + av_product, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
| +
|
| + if (av_product_parts.size() >= 2) {
|
| + // Skipping first element, remove any that look like version numbers.
|
| + av_product_parts.erase(
|
| + std::remove_if(av_product_parts.begin() + 1, av_product_parts.end(),
|
| + ShouldFilterPart),
|
| + av_product_parts.end());
|
| + }
|
| +
|
| + return base::JoinString(av_product_parts, " ");
|
| +}
|
| +
|
| void AntiVirusMetricsProvider::GotAntiVirusProducts(
|
| const base::Closure& done_callback,
|
| const std::vector<AvProduct>& av_products) {
|
|
|