OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h" | 5 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h" |
6 | 6 |
7 #include <iwscapi.h> | 7 #include <iwscapi.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <wbemidl.h> | 9 #include <wbemidl.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } else { | 169 } else { |
170 // The WSC interface is preferred here as it's fully documented, but only | 170 // The WSC interface is preferred here as it's fully documented, but only |
171 // available on Windows 8 and above, so instead use the undocumented WMI | 171 // available on Windows 8 and above, so instead use the undocumented WMI |
172 // interface on Windows 7 and below. | 172 // interface on Windows 7 and below. |
173 if (os_info->version() >= base::win::VERSION_WIN8) | 173 if (os_info->version() >= base::win::VERSION_WIN8) |
174 result = FillAntiVirusProductsFromWSC(&av_products); | 174 result = FillAntiVirusProductsFromWSC(&av_products); |
175 else | 175 else |
176 result = FillAntiVirusProductsFromWMI(&av_products); | 176 result = FillAntiVirusProductsFromWMI(&av_products); |
177 } | 177 } |
178 | 178 |
| 179 MaybeAddUnregisteredAntiVirusProducts(&av_products); |
| 180 |
179 UMA_HISTOGRAM_ENUMERATION("UMA.AntiVirusMetricsProvider.Result", | 181 UMA_HISTOGRAM_ENUMERATION("UMA.AntiVirusMetricsProvider.Result", |
180 result, | 182 result, |
181 RESULT_COUNT); | 183 RESULT_COUNT); |
182 | 184 |
183 return av_products; | 185 return av_products; |
184 } | 186 } |
185 | 187 |
186 void AntiVirusMetricsProvider::GotAntiVirusProducts( | 188 void AntiVirusMetricsProvider::GotAntiVirusProducts( |
187 const base::Closure& done_callback, | 189 const base::Closure& done_callback, |
188 const std::vector<AvProduct>& av_products) { | 190 const std::vector<AvProduct>& av_products) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 av_product.set_product_version_hash(metrics::HashName(product_version)); | 421 av_product.set_product_version_hash(metrics::HashName(product_version)); |
420 } | 422 } |
421 | 423 |
422 result_list.push_back(av_product); | 424 result_list.push_back(av_product); |
423 } | 425 } |
424 | 426 |
425 *products = std::move(result_list); | 427 *products = std::move(result_list); |
426 | 428 |
427 return RESULT_SUCCESS; | 429 return RESULT_SUCCESS; |
428 } | 430 } |
| 431 |
| 432 void AntiVirusMetricsProvider::MaybeAddUnregisteredAntiVirusProducts( |
| 433 std::vector<AvProduct>* products) { |
| 434 base::ThreadRestrictions::AssertIOAllowed(); |
| 435 |
| 436 // Trusteer Rapport does not register with WMI or Security Center so do some |
| 437 // "best efforts" detection here. |
| 438 |
| 439 // Rapport always installs into 32-bit Program Files in directory |
| 440 // %DIR_PROGRAM_FILESX86%\Trusteer\Rapport |
| 441 base::FilePath binary_path; |
| 442 if (!PathService::Get(base::DIR_PROGRAM_FILESX86, &binary_path)) |
| 443 return; |
| 444 |
| 445 binary_path = binary_path.AppendASCII("Trusteer") |
| 446 .AppendASCII("Rapport") |
| 447 .AppendASCII("bin") |
| 448 .AppendASCII("RapportService.exe"); |
| 449 |
| 450 if (!base::PathExists(binary_path)) |
| 451 return; |
| 452 |
| 453 std::wstring mutable_path_str(binary_path.value()); |
| 454 std::string product_version; |
| 455 |
| 456 if (!GetProductVersion(&mutable_path_str, &product_version)) |
| 457 return; |
| 458 |
| 459 AvProduct av_product; |
| 460 |
| 461 // Assume enabled, no easy way of knowing for sure. |
| 462 av_product.set_product_state(metrics::SystemProfileProto::AntiVirusState:: |
| 463 SystemProfileProto_AntiVirusState_STATE_ON); |
| 464 |
| 465 // Taken from Add/Remove programs as the product name. |
| 466 std::string product_name("Trusteer Endpoint Protection"); |
| 467 if (ShouldReportFullNames()) { |
| 468 av_product.set_product_name(product_name); |
| 469 av_product.set_product_version(product_version); |
| 470 } |
| 471 av_product.set_product_name_hash(metrics::HashName(product_name)); |
| 472 av_product.set_product_version_hash(metrics::HashName(product_version)); |
| 473 |
| 474 products->push_back(av_product); |
| 475 } |
OLD | NEW |