#include "chrome/browser/device_api/device_service_impl.h"
#include "base/check_deref.h"
#include "base/check_is_test.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/device_api/device_attribute_api.h"
#include "chrome/browser/policy/policy_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/policy/web_app_policy_constants.h"
#include "chrome/browser/web_applications/proto/proto_helpers.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/proto/web_app_os_integration_state.pb.h"
#include "chrome/browser/web_applications/proto/web_app_proto_package.pb.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/pref_names.h"
#include "components/permissions/features.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "url/gurl.h"
#include "url/origin.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/web_applications/isolated_web_apps/policy/isolated_web_app_policy_constants.h"
#include "chrome/common/url_constants.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_data.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "components/user_manager/user_manager.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/app_mode/kiosk_session_service_lacros.h"
#include "components/policy/core/common/policy_loader_lacros.h"
#endif
namespace {
bool IsEqualToKioskOrigin(const url::Origin& origin) { … }
Profile* GetProfile(content::RenderFrameHost& host) { … }
bool IsForceInstalledOrigin(content::RenderFrameHost& host,
const url::Origin& origin) { … }
const PrefService* GetPrefs(content::RenderFrameHost& host) { … }
bool IsAffiliatedUser() { … }
bool IsTrustedContext(content::RenderFrameHost& host,
const url::Origin& origin) { … }
}
DeviceServiceImpl::DeviceServiceImpl(
content::RenderFrameHost& host,
mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver,
std::unique_ptr<DeviceAttributeApi> device_attribute_api)
: … { … }
DeviceServiceImpl::~DeviceServiceImpl() = default;
void DeviceServiceImpl::Create(
content::RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver,
std::unique_ptr<DeviceAttributeApi> device_attribute_api) { … }
void DeviceServiceImpl::Create(
content::RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver) { … }
void DeviceServiceImpl::CreateForTest(
content::RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver,
std::unique_ptr<DeviceAttributeApi> device_attribute_api) { … }
void DeviceServiceImpl::RegisterProfilePrefs(PrefRegistrySimple* registry) { … }
void DeviceServiceImpl::OnWebAppSourceRemoved(const webapps::AppId& app_id) { … }
void DeviceServiceImpl::OnWebAppUninstalled(
const webapps::AppId& app_id,
webapps::WebappUninstallSource uninstall_source) { … }
void DeviceServiceImpl::OnWebAppInstallManagerDestroyed() { … }
void DeviceServiceImpl::OnDisposingIfNeeded() { … }
void DeviceServiceImpl::GetDirectoryId(GetDirectoryIdCallback callback) { … }
void DeviceServiceImpl::GetHostname(GetHostnameCallback callback) { … }
void DeviceServiceImpl::GetSerialNumber(GetSerialNumberCallback callback) { … }
void DeviceServiceImpl::GetAnnotatedAssetId(
GetAnnotatedAssetIdCallback callback) { … }
void DeviceServiceImpl::GetAnnotatedLocation(
GetAnnotatedLocationCallback callback) { … }
void DeviceServiceImpl::GetDeviceAttribute(
void (DeviceAttributeApi::*method)(DeviceAttributeCallback callback),
DeviceAttributeCallback callback) { … }