blob: cd09bb6fc98743b4e9886ea0086fb63084443d4b [file] [log] [blame]
Igor900cbc12021-10-12 17:58:231// Copyright 2021 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
5#ifndef CHROME_BROWSER_LACROS_DEVICE_SETTINGS_LACROS_H_
6#define CHROME_BROWSER_LACROS_DEVICE_SETTINGS_LACROS_H_
7
8#include "base/memory/weak_ptr.h"
9#include "chromeos/crosapi/mojom/device_settings_service.mojom.h"
10#include "mojo/public/cpp/bindings/receiver.h"
11
12// The keeper of device settings needed for Lacros. Initializes with current
13// value at startup and receives the updates from ash when the settings are
14// changed. Lacros should use the device settings provided by this class when
15// needs to use any device settings.
16class DeviceSettingsLacros : public crosapi::mojom::DeviceSettingsObserver {
17 public:
18 DeviceSettingsLacros();
19 DeviceSettingsLacros(const DeviceSettingsLacros&) = delete;
20 DeviceSettingsLacros& operator=(const DeviceSettingsLacros&) = delete;
21 ~DeviceSettingsLacros() override;
22
23 crosapi::mojom::DeviceSettings* GetDeviceSettings();
24
25 // crosapi::mojom::DeviceSettingsObserver:
26 void UpdateDeviceSettings(
27 crosapi::mojom::DeviceSettingsPtr device_settings) override;
28
29 private:
30 void Init();
31
32 crosapi::mojom::DeviceSettingsPtr device_settings_;
33 mojo::Receiver<crosapi::mojom::DeviceSettingsObserver> receiver_{this};
34 base::WeakPtrFactory<DeviceSettingsLacros> weak_ptr_factory_{this};
35};
36
37#endif // CHROME_BROWSER_LACROS_DEVICE_SETTINGS_LACROS_H_