| 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 <objbase.h> | 8 #include <objbase.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <wbemidl.h> | 10 #include <wbemidl.h> |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 390 |
| 391 // See definition of PRODUCT_STATE structure above for how this is being | 391 // See definition of PRODUCT_STATE structure above for how this is being |
| 392 // used. | 392 // used. |
| 393 base::win::ScopedVariant product_state; | 393 base::win::ScopedVariant product_state; |
| 394 hr = class_object->Get(L"productState", 0, product_state.Receive(), 0, 0); | 394 hr = class_object->Get(L"productState", 0, product_state.Receive(), 0, 0); |
| 395 | 395 |
| 396 if (FAILED(hr) || product_state.type() != VT_I4) | 396 if (FAILED(hr) || product_state.type() != VT_I4) |
| 397 return RESULT_FAILED_TO_GET_PRODUCT_STATE; | 397 return RESULT_FAILED_TO_GET_PRODUCT_STATE; |
| 398 | 398 |
| 399 LONG state_val = V_I4(product_state.ptr()); | 399 LONG state_val = V_I4(product_state.ptr()); |
| 400 // Map the values from product_state to the proto values. | 400 PRODUCT_STATE product_state_struct; |
| 401 switch (reinterpret_cast<PRODUCT_STATE*>(&state_val)->security_state) { | 401 std::copy(reinterpret_cast<const char*>(&state_val), |
| 402 reinterpret_cast<const char*>(&state_val) + sizeof state_val, |
| 403 reinterpret_cast<char*>(&product_state_struct)); |
| 404 // Map the values from product_state_struct to the proto values. |
| 405 switch (product_state_struct.security_state) { |
| 402 case 0: | 406 case 0: |
| 403 av_product.set_product_state( | 407 av_product.set_product_state( |
| 404 metrics::SystemProfileProto::AntiVirusState:: | 408 metrics::SystemProfileProto::AntiVirusState:: |
| 405 SystemProfileProto_AntiVirusState_STATE_OFF); | 409 SystemProfileProto_AntiVirusState_STATE_OFF); |
| 406 break; | 410 break; |
| 407 case 1: | 411 case 1: |
| 408 av_product.set_product_state( | 412 av_product.set_product_state( |
| 409 metrics::SystemProfileProto::AntiVirusState:: | 413 metrics::SystemProfileProto::AntiVirusState:: |
| 410 SystemProfileProto_AntiVirusState_STATE_ON); | 414 SystemProfileProto_AntiVirusState_STATE_ON); |
| 411 break; | 415 break; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 std::string product_name("Trusteer Endpoint Protection"); | 503 std::string product_name("Trusteer Endpoint Protection"); |
| 500 if (ShouldReportFullNames()) { | 504 if (ShouldReportFullNames()) { |
| 501 av_product.set_product_name(product_name); | 505 av_product.set_product_name(product_name); |
| 502 av_product.set_product_version(product_version); | 506 av_product.set_product_version(product_version); |
| 503 } | 507 } |
| 504 av_product.set_product_name_hash(metrics::HashName(product_name)); | 508 av_product.set_product_name_hash(metrics::HashName(product_name)); |
| 505 av_product.set_product_version_hash(metrics::HashName(product_version)); | 509 av_product.set_product_version_hash(metrics::HashName(product_version)); |
| 506 | 510 |
| 507 products->push_back(av_product); | 511 products->push_back(av_product); |
| 508 } | 512 } |
| OLD | NEW |