1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file contains some utilities that are used by both CRD related
// remote commands (`FETCH_CRD_AVAILABILITY_INFO` and
// `DEVICE_START_CRD_SESSION`).
#ifndef CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_CRD_CRD_REMOTE_COMMAND_UTILS_H_
#define CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_CRD_CRD_REMOTE_COMMAND_UTILS_H_
#include "base/functional/callback_forward.h"
#include "base/time/time.h"
#include "chrome/browser/ash/policy/remote_commands/crd/public/shared_crd_session.h"
#include "chrome/browser/ash/policy/remote_commands/crd/start_crd_session_job_delegate.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/prefs/pref_service.h"
#include "remoting/host/chromeos/chromeos_enterprise_params.h"
namespace policy {
// The current active session type on the device, or `NO_SESSION` if no user
// is currently logged in.
using ::enterprise_management::UserSessionType;
// The type of the CRD session.
using ::enterprise_management::CrdSessionType;
// Returns the time since the last user activity on this device.
// Returns `TimeDelta::Max()` if there was no user activity since the last
// reboot.
base::TimeDelta GetDeviceIdleTime();
// Returns the type of the currently active user session.
UserSessionType GetCurrentUserSessionType();
// Returns if a remote admin is allowed to start a 'CRD remote support' session
// when an user session of the given type is active.
bool UserSessionSupportsRemoteSupport(UserSessionType user_session);
// Returns if a remote admin is allowed to start a 'CRD remote access' session
// when an user session of the given type is active.
bool UserSessionSupportsRemoteAccess(UserSessionType user_session);
// Returns if a remote admin is allowed by policy to start a 'CRD remote access'
// session when no user is present at the device.
bool IsRemoteAccessAllowedByPolicy(const PrefService& policy_service);
// Returns if a remote admin is allowed by policy to start a 'CRD remote
// support' session when no user is present at the device.
bool IsRemoteSupportAllowedByPolicy(const PrefService& policy_service);
const char* UserSessionTypeToString(UserSessionType value);
const char* CrdSessionTypeToString(CrdSessionType value);
// Returns asynchronously if the ChromeOS device is in a managed environment.
// We consider the device's environment to be managed if there is a
// * active (connected) network
// * with a policy ONC source set (meaning the network is managed)
// * which is not cellular
//
// The reasoning is that these conditions will only be met if the device is in
// an office building or a store, and these conditions will not be met if the
// device is in a private setting like an user's home.
using ManagedEnvironmentResultCallback = base::OnceCallback<void(bool)>;
void CalculateIsInManagedEnvironmentAsync(
ManagedEnvironmentResultCallback result_callback);
// Convert from `StartCrdSessionJobDelegate::RequestOrigin` to
// `remoting::ChromeOsEnterpriseRequestOrigin`.
remoting::ChromeOsEnterpriseRequestOrigin
ConvertToChromeOsEnterpriseRequestOrigin(
StartCrdSessionJobDelegate::RequestOrigin request_origin);
// Convert from `SharedCrdSession::RequestOrigin` to
// `StartCrdSessionJobDelegate::RequestOrigin`.
StartCrdSessionJobDelegate::RequestOrigin
ConvertToStartCrdSessionJobDelegateRequestOrigin(
SharedCrdSession::RequestOrigin request_origin);
} // namespace policy
#endif // CHROME_BROWSER_ASH_POLICY_REMOTE_COMMANDS_CRD_CRD_REMOTE_COMMAND_UTILS_H_
|