Chromium Code Reviews| Index: base/win/win_util.cc |
| diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
| index a1b7f8985590dd709c89ba6cb1b579e14222e0ce..3dab6cb155e435cc9f9f326554a452327d0e62b0 100644 |
| --- a/base/win/win_util.cc |
| +++ b/base/win/win_util.cc |
| @@ -10,6 +10,7 @@ |
| #include <shobjidl.h> // Must be before propkey. |
| #include <initguid.h> |
| #include <inspectable.h> |
| +#include <mdmregistration.h> |
| #include <propkey.h> |
| #include <propvarutil.h> |
| #include <psapi.h> |
| @@ -496,6 +497,37 @@ bool IsEnrolledToDomain() { |
| return g_domain_state == ENROLLED; |
| } |
| +bool IsDeviceRegisteredWithManagement() { |
| + static auto is_device_registered_with_management = []() { |
| + using IsDeviceRegisteredWithManagementFunction = |
| + decltype(&::IsDeviceRegisteredWithManagement); |
| + |
| + static IsDeviceRegisteredWithManagementFunction fn = nullptr; |
|
grt (UTC plus 2)
2017/02/13 21:06:25
my remark about avoiding abbreviation was in regar
Roger Tawa OOO till Jul 10th
2017/02/14 19:23:44
Done.
|
| + if (!fn) { |
| + HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); |
| + fn = reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( |
| + ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); |
| + if (!fn) |
| + return false; |
| + } |
| + |
| + BOOL is_managed = false; |
| + HRESULT hr = fn(&is_managed, 0, nullptr); |
| + return SUCCEEDED(hr) && is_managed; |
| + }(); |
| + return is_device_registered_with_management; |
| +} |
| + |
| +bool IsEnterpriseManaged() { |
| + // TODO(rogerta): this function should really be: |
| + // |
| + // return IsEnrolledToDomain() || IsDeviceRegisteredWithManagement(); |
| + // |
| + // However, for now it is decided to collect some UMA metrics about |
| + // IsDeviceRegisteredWithMdm() before changing chrome's behavior. |
| + return IsEnrolledToDomain(); |
| +} |
| + |
| void SetDomainStateForTesting(bool state) { |
| g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
| } |