Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Unified Diff: base/win/win_util.cc

Issue 2581353002: Use the Windows MDM API to check if the machine is being managed. (Closed)
Patch Set: Address review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/win_util.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « base/win/win_util.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698