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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 if (g_domain_state == UNKNOWN) { | 529 if (g_domain_state == UNKNOWN) { |
529 ::InterlockedCompareExchange(&g_domain_state, | 530 ::InterlockedCompareExchange(&g_domain_state, |
530 IsOS(OS_DOMAINMEMBER) ? | 531 IsOS(OS_DOMAINMEMBER) ? |
531 ENROLLED : NOT_ENROLLED, | 532 ENROLLED : NOT_ENROLLED, |
532 UNKNOWN); | 533 UNKNOWN); |
533 } | 534 } |
534 | 535 |
535 return g_domain_state == ENROLLED; | 536 return g_domain_state == ENROLLED; |
536 } | 537 } |
537 | 538 |
| 539 bool IsDeviceRegisteredWithMdm() { |
| 540 using IsDeviceRegisteredWithManagementFunction = |
| 541 decltype(&IsDeviceRegisteredWithManagement); |
| 542 |
| 543 static IsDeviceRegisteredWithManagementFunction fn = nullptr; |
| 544 if (!fn) { |
| 545 HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); |
| 546 fn = reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( |
| 547 ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); |
| 548 if (!fn) { |
| 549 return false; |
| 550 } |
| 551 } |
| 552 |
| 553 BOOL is_managed = false; |
| 554 HRESULT hr = fn(&is_managed, 0, nullptr); |
| 555 LOG(ERROR) << "*** rogerta: IsDeviceRegisteredWithMdm: " |
| 556 << (bool)((hr) && is_managed); |
| 557 return SUCCEEDED(hr) && is_managed; |
| 558 } |
| 559 |
| 560 bool IsEnterpriseUser() { |
| 561 return IsEnrolledToDomain() || IsDeviceRegisteredWithMdm(); |
| 562 } |
| 563 |
538 void SetDomainStateForTesting(bool state) { | 564 void SetDomainStateForTesting(bool state) { |
539 g_domain_state = state ? ENROLLED : NOT_ENROLLED; | 565 g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
540 } | 566 } |
541 | 567 |
542 bool IsUser32AndGdi32Available() { | 568 bool IsUser32AndGdi32Available() { |
543 static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available = | 569 static base::LazyInstance<LazyIsUser32AndGdi32Available>::Leaky available = |
544 LAZY_INSTANCE_INITIALIZER; | 570 LAZY_INSTANCE_INITIALIZER; |
545 return available.Get().value(); | 571 return available.Get().value(); |
546 } | 572 } |
547 | 573 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 awareness == PROCESS_PER_MONITOR_DPI_AWARE) | 644 awareness == PROCESS_PER_MONITOR_DPI_AWARE) |
619 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 645 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
620 } | 646 } |
621 } | 647 } |
622 } | 648 } |
623 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 649 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
624 } | 650 } |
625 | 651 |
626 } // namespace win | 652 } // namespace win |
627 } // namespace base | 653 } // namespace base |
OLD | NEW |