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 IsDeviceRegisteredWithManagement() { |
| 501 static bool is_device_registered_with_management = []() { |
| 502 HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); |
| 503 if (!mdm_dll) |
| 504 return false; |
| 505 |
| 506 using IsDeviceRegisteredWithManagementFunction = |
| 507 decltype(&::IsDeviceRegisteredWithManagement); |
| 508 IsDeviceRegisteredWithManagementFunction |
| 509 is_device_registered_with_management_function = |
| 510 reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( |
| 511 ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); |
| 512 if (!is_device_registered_with_management_function) |
| 513 return false; |
| 514 |
| 515 BOOL is_managed = false; |
| 516 HRESULT hr = |
| 517 is_device_registered_with_management_function(&is_managed, 0, nullptr); |
| 518 return SUCCEEDED(hr) && is_managed; |
| 519 }(); |
| 520 return is_device_registered_with_management; |
| 521 } |
| 522 |
| 523 bool IsEnterpriseManaged() { |
| 524 // TODO(rogerta): this function should really be: |
| 525 // |
| 526 // return IsEnrolledToDomain() || IsDeviceRegisteredWithManagement(); |
| 527 // |
| 528 // However, for now it is decided to collect some UMA metrics about |
| 529 // IsDeviceRegisteredWithMdm() before changing chrome's behavior. |
| 530 return IsEnrolledToDomain(); |
| 531 } |
| 532 |
499 void SetDomainStateForTesting(bool state) { | 533 void SetDomainStateForTesting(bool state) { |
500 g_domain_state = state ? ENROLLED : NOT_ENROLLED; | 534 g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
501 } | 535 } |
502 | 536 |
503 bool IsUser32AndGdi32Available() { | 537 bool IsUser32AndGdi32Available() { |
504 static auto is_user32_and_gdi32_available = []() { | 538 static auto is_user32_and_gdi32_available = []() { |
505 // If win32k syscalls aren't disabled, then user32 and gdi32 are available. | 539 // If win32k syscalls aren't disabled, then user32 and gdi32 are available. |
506 | 540 |
507 // Can't disable win32k prior to windows 8. | 541 // Can't disable win32k prior to windows 8. |
508 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 542 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) | 636 awareness == PROCESS_PER_MONITOR_DPI_AWARE) |
603 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 637 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
604 } | 638 } |
605 } | 639 } |
606 } | 640 } |
607 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; | 641 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
608 } | 642 } |
609 | 643 |
610 } // namespace win | 644 } // namespace win |
611 } // namespace base | 645 } // namespace base |
OLD | NEW |