Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
| 6 | 6 |
| 7 #include <aclapi.h> | 7 #include <aclapi.h> |
| 8 #include <cfgmgr32.h> | 8 #include <cfgmgr32.h> |
| 9 #include <powrprof.h> | 9 #include <powrprof.h> |
| 10 #include <shobjidl.h> // Must be before propkey. | 10 #include <shobjidl.h> // Must be before propkey. |
| 11 #include <initguid.h> | 11 #include <initguid.h> |
| 12 #include <inspectable.h> | 12 #include <inspectable.h> |
| 13 #include <mdmregistration.h> | |
| 13 #include <propkey.h> | 14 #include <propkey.h> |
| 14 #include <propvarutil.h> | 15 #include <propvarutil.h> |
| 15 #include <psapi.h> | 16 #include <psapi.h> |
| 16 #include <roapi.h> | 17 #include <roapi.h> |
| 17 #include <sddl.h> | 18 #include <sddl.h> |
| 18 #include <setupapi.h> | 19 #include <setupapi.h> |
| 19 #include <shellscalingapi.h> | 20 #include <shellscalingapi.h> |
| 20 #include <shlwapi.h> | 21 #include <shlwapi.h> |
| 21 #include <signal.h> | 22 #include <signal.h> |
| 22 #include <stddef.h> | 23 #include <stddef.h> |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 if (g_domain_state == UNKNOWN) { | 490 if (g_domain_state == UNKNOWN) { |
| 490 ::InterlockedCompareExchange(&g_domain_state, | 491 ::InterlockedCompareExchange(&g_domain_state, |
| 491 IsOS(OS_DOMAINMEMBER) ? | 492 IsOS(OS_DOMAINMEMBER) ? |
| 492 ENROLLED : NOT_ENROLLED, | 493 ENROLLED : NOT_ENROLLED, |
| 493 UNKNOWN); | 494 UNKNOWN); |
| 494 } | 495 } |
| 495 | 496 |
| 496 return g_domain_state == ENROLLED; | 497 return g_domain_state == ENROLLED; |
| 497 } | 498 } |
| 498 | 499 |
| 500 bool IsDeviceRegisteredWithMdm() { | |
| 501 using IsDeviceRegisteredWithManagementFunction = | |
| 502 decltype(&IsDeviceRegisteredWithManagement); | |
| 503 | |
| 504 static IsDeviceRegisteredWithManagementFunction fn = nullptr; | |
|
grt (UTC plus 2)
2017/02/08 21:59:55
please initialize this in a lambda sorta like is_u
Roger Tawa OOO till Jul 10th
2017/02/09 14:55:59
Done. I was debating whether to do this or not, b
| |
| 505 if (!fn) { | |
| 506 HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); | |
|
Roger Tawa OOO till Jul 10th
2017/02/09 14:55:59
Should I call FreeLibrary() after calling through
| |
| 507 fn = reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( | |
| 508 ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); | |
| 509 if (!fn) { | |
|
grt (UTC plus 2)
2017/02/08 21:59:55
nit: omit braces for one-liners like this
Roger Tawa OOO till Jul 10th
2017/02/09 14:55:59
Done.
| |
| 510 return false; | |
| 511 } | |
| 512 } | |
| 513 | |
| 514 BOOL is_managed = false; | |
| 515 HRESULT hr = fn(&is_managed, 0, nullptr); | |
| 516 return SUCCEEDED(hr) && is_managed; | |
| 517 } | |
| 518 | |
| 519 bool IsEnterpriseUser() { | |
|
grt (UTC plus 2)
2017/02/08 21:59:55
this is checking machine-level rather than user ac
Roger Tawa OOO till Jul 10th
2017/02/09 14:55:59
I'll wait for Georges' suggestion on the name. Ho
Georges Khalil
2017/02/09 14:59:57
I will suggest IsEnterpriseManaged, which is what
Roger Tawa OOO till Jul 10th
2017/02/09 16:06:43
Done. Note that the UMA stat is called "IsEnterpr
| |
| 520 return IsEnrolledToDomain() || IsDeviceRegisteredWithMdm(); | |
| 521 } | |
| 522 | |
| 499 void SetDomainStateForTesting(bool state) { | 523 void SetDomainStateForTesting(bool state) { |
| 500 g_domain_state = state ? ENROLLED : NOT_ENROLLED; | 524 g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
| 501 } | 525 } |
| 502 | 526 |
| 503 bool IsUser32AndGdi32Available() { | 527 bool IsUser32AndGdi32Available() { |
| 504 static auto is_user32_and_gdi32_available = []() { | 528 static auto is_user32_and_gdi32_available = []() { |
| 505 // If win32k syscalls aren't disabled, then user32 and gdi32 are available. | 529 // If win32k syscalls aren't disabled, then user32 and gdi32 are available. |
| 506 | 530 |
| 507 // Can't disable win32k prior to windows 8. | 531 // Can't disable win32k prior to windows 8. |
| 508 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 532 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 awareness == PROCESS_PER_MONITOR_DPI_AWARE) | 626 awareness == PROCESS_PER_MONITOR_DPI_AWARE) |
| 603 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 627 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
| 604 } | 628 } |
| 605 } | 629 } |
| 606 } | 630 } |
| 607 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 631 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
| 608 } | 632 } |
| 609 | 633 |
| 610 } // namespace win | 634 } // namespace win |
| 611 } // namespace base | 635 } // namespace base |
| OLD | NEW |