Index: base/win/win_util.cc |
diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
index a1b7f8985590dd709c89ba6cb1b579e14222e0ce..c2b0869a15cab4ed88e906fd77c43594f95c1400 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,40 @@ bool IsEnrolledToDomain() { |
return g_domain_state == ENROLLED; |
} |
+bool IsDeviceRegisteredWithManagement() { |
+ static auto is_device_registered_with_management = []() { |
grt (UTC plus 2)
2017/02/14 21:20:13
auto -> bool
Roger Tawa OOO till Jul 10th
2017/02/15 19:11:27
Done.
|
+ using IsDeviceRegisteredWithManagementFunction = |
+ decltype(&::IsDeviceRegisteredWithManagement); |
+ |
+ IsDeviceRegisteredWithManagementFunction |
+ is_device_registered_with_management_function = nullptr; |
+ if (!is_device_registered_with_management_function) { |
grt (UTC plus 2)
2017/02/14 21:20:13
remove this check and move the definition of is_de
Roger Tawa OOO till Jul 10th
2017/02/15 19:11:27
Doh! Good catch, not sure how that line got there
|
+ HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); |
grt (UTC plus 2)
2017/02/14 21:20:13
?
if (!mdm_dll)
return false;
Roger Tawa OOO till Jul 10th
2017/02/15 19:11:27
Done.
|
+ is_device_registered_with_management_function = |
+ reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( |
+ ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); |
+ if (!is_device_registered_with_management_function) |
+ return false; |
+ } |
+ |
+ BOOL is_managed = false; |
+ HRESULT hr = |
+ is_device_registered_with_management_function(&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; |
} |