| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return RESULT_PRODUCT_STATE_INVALID; | 289 return RESULT_PRODUCT_STATE_INVALID; |
| 290 | 290 |
| 291 av_product.set_product_state( | 291 av_product.set_product_state( |
| 292 static_cast<metrics::SystemProfileProto::AntiVirusState>( | 292 static_cast<metrics::SystemProfileProto::AntiVirusState>( |
| 293 product_state)); | 293 product_state)); |
| 294 | 294 |
| 295 base::win::ScopedBstr product_name; | 295 base::win::ScopedBstr product_name; |
| 296 result = product->get_ProductName(product_name.Receive()); | 296 result = product->get_ProductName(product_name.Receive()); |
| 297 if (FAILED(result)) | 297 if (FAILED(result)) |
| 298 return RESULT_FAILED_TO_GET_PRODUCT_NAME; | 298 return RESULT_FAILED_TO_GET_PRODUCT_NAME; |
| 299 std::string name = | 299 std::string name = TrimVersionOfAvProductName( |
| 300 base::SysWideToUTF8(std::wstring(product_name, product_name.Length())); | 300 base::SysWideToUTF8(std::wstring(product_name, product_name.Length()))); |
| 301 product_name.Release(); | 301 product_name.Release(); |
| 302 if (ShouldReportFullNames()) | 302 if (ShouldReportFullNames()) |
| 303 av_product.set_product_name(name); | 303 av_product.set_product_name(name); |
| 304 av_product.set_product_name_hash(metrics::HashName(name)); | 304 av_product.set_product_name_hash(metrics::HashName(name)); |
| 305 | 305 |
| 306 base::win::ScopedBstr remediation_path; | 306 base::win::ScopedBstr remediation_path; |
| 307 result = product->get_RemediationPath(remediation_path.Receive()); | 307 result = product->get_RemediationPath(remediation_path.Receive()); |
| 308 if (FAILED(result)) | 308 if (FAILED(result)) |
| 309 return RESULT_FAILED_TO_GET_REMEDIATION_PATH; | 309 return RESULT_FAILED_TO_GET_REMEDIATION_PATH; |
| 310 std::wstring path_str(remediation_path, remediation_path.Length()); | 310 std::wstring path_str(remediation_path, remediation_path.Length()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 base::win::ScopedVariant display_name; | 422 base::win::ScopedVariant display_name; |
| 423 hr = class_object->Get(L"displayName", 0, display_name.Receive(), 0, 0); | 423 hr = class_object->Get(L"displayName", 0, display_name.Receive(), 0, 0); |
| 424 | 424 |
| 425 if (FAILED(hr) || display_name.type() != VT_BSTR) | 425 if (FAILED(hr) || display_name.type() != VT_BSTR) |
| 426 return RESULT_FAILED_TO_GET_PRODUCT_NAME; | 426 return RESULT_FAILED_TO_GET_PRODUCT_NAME; |
| 427 | 427 |
| 428 // Owned by ScopedVariant. | 428 // Owned by ScopedVariant. |
| 429 BSTR temp_bstr = V_BSTR(display_name.ptr()); | 429 BSTR temp_bstr = V_BSTR(display_name.ptr()); |
| 430 std::string name(base::SysWideToUTF8( | 430 std::string name = TrimVersionOfAvProductName(base::SysWideToUTF8( |
| 431 std::wstring(temp_bstr, ::SysStringLen(temp_bstr)))); | 431 std::wstring(temp_bstr, ::SysStringLen(temp_bstr)))); |
| 432 | 432 |
| 433 if (ShouldReportFullNames()) | 433 if (ShouldReportFullNames()) |
| 434 av_product.set_product_name(name); | 434 av_product.set_product_name(name); |
| 435 av_product.set_product_name_hash(metrics::HashName(name)); | 435 av_product.set_product_name_hash(metrics::HashName(name)); |
| 436 | 436 |
| 437 base::win::ScopedVariant exe_path; | 437 base::win::ScopedVariant exe_path; |
| 438 hr = class_object->Get(L"pathToSignedProductExe", 0, exe_path.Receive(), 0, | 438 hr = class_object->Get(L"pathToSignedProductExe", 0, exe_path.Receive(), 0, |
| 439 0); | 439 0); |
| 440 | 440 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 std::string product_name("Trusteer Endpoint Protection"); | 498 std::string product_name("Trusteer Endpoint Protection"); |
| 499 if (ShouldReportFullNames()) { | 499 if (ShouldReportFullNames()) { |
| 500 av_product.set_product_name(product_name); | 500 av_product.set_product_name(product_name); |
| 501 av_product.set_product_version(product_version); | 501 av_product.set_product_version(product_version); |
| 502 } | 502 } |
| 503 av_product.set_product_name_hash(metrics::HashName(product_name)); | 503 av_product.set_product_name_hash(metrics::HashName(product_name)); |
| 504 av_product.set_product_version_hash(metrics::HashName(product_version)); | 504 av_product.set_product_version_hash(metrics::HashName(product_version)); |
| 505 | 505 |
| 506 products->push_back(av_product); | 506 products->push_back(av_product); |
| 507 } | 507 } |
| OLD | NEW |