enterprise_util.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_ENTERPRISE_UTIL_H_
  5. #define BASE_ENTERPRISE_UTIL_H_
  6. #include "base/base_export.h"
  7. #include "build/build_config.h"
  8. namespace base {
  9. // Returns true if an outside entity manages the current machine. To be
  10. // "managed" means that an entity such as a company or school is applying
  11. // policies to this device. This is primarily checking the device for MDM
  12. // management.
  13. // Not all managed devices are enterprise devices, as BYOD (bring your own
  14. // device) is becoming more common in connection with workplace joining of
  15. // personal computers.
  16. BASE_EXPORT bool IsManagedDevice();
  17. // Returns true if the device should be considered an enterprise device. To be
  18. // an enterprise device means that the enterprise actually owns or has complete
  19. // control over a device. This is primarily checking if the device is joined to
  20. // a domain.
  21. // Not all enterprise devices are managed devices because not all enterprises
  22. // actually apply policies to all devices.
  23. BASE_EXPORT bool IsEnterpriseDevice();
  24. // Returns true if the device is either managed or enterprise. In general, it is
  25. // recommended to use the PlatformManagementService to obtain this information,
  26. // if possible.
  27. BASE_EXPORT bool IsManagedOrEnterpriseDevice();
  28. #if BUILDFLAG(IS_APPLE)
  29. // Returns true if the device is being managed by an MDM system. Uses an old API
  30. // not intended for the purpose.
  31. enum class MacDeviceManagementStateOld {
  32. kFailureAPIUnavailable = 0,
  33. kFailureUnableToParseResult = 1,
  34. kNoEnrollment = 2,
  35. kMDMEnrollment = 3,
  36. kMaxValue = kMDMEnrollment
  37. };
  38. BASE_EXPORT MacDeviceManagementStateOld IsDeviceRegisteredWithManagementOld();
  39. // Returns the state of the management of the device. Uses a new API so results
  40. // aren't always available. For more details, this is documented at
  41. // https://blog.fleetsmith.com/what-is-user-approved-mdm-uamdm/ .
  42. // These values are persisted to logs. Entries must not be renumbered and
  43. // numeric values must never be reused.
  44. enum class MacDeviceManagementStateNew {
  45. kFailureAPIUnavailable = 0,
  46. kFailureUnableToParseResult = 1,
  47. kNoEnrollment = 2,
  48. kLimitedMDMEnrollment = 3,
  49. kFullMDMEnrollment = 4,
  50. kDEPMDMEnrollment = 5,
  51. kMaxValue = kDEPMDMEnrollment
  52. };
  53. BASE_EXPORT MacDeviceManagementStateNew IsDeviceRegisteredWithManagementNew();
  54. // Returns whether the device and/or the current user is enrolled to a domain.
  55. struct DeviceUserDomainJoinState {
  56. bool device_joined;
  57. bool user_joined;
  58. };
  59. BASE_EXPORT DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain();
  60. #endif // BUILDFLAG(IS_APPLE)
  61. } // namespace base
  62. #endif // BASE_ENTERPRISE_UTIL_H_