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