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
ash / system / privacy_hub / speak_on_mute_detection_privacy_switch_controller.h [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_PRIVACY_HUB_SPEAK_ON_MUTE_DETECTION_PRIVACY_SWITCH_CONTROLLER_H_
#define ASH_SYSTEM_PRIVACY_HUB_SPEAK_ON_MUTE_DETECTION_PRIVACY_SWITCH_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_controller.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/scoped_observation.h"
class PrefChangeRegistrar;
class PrefService;
namespace ash {
// This controller keeps the `kUserSpeakOnMuteDetectionEnabled` preference and
// the state of the speak-on-mute detection in sync.
class ASH_EXPORT SpeakOnMuteDetectionPrivacySwitchController
: public SessionObserver {
public:
SpeakOnMuteDetectionPrivacySwitchController();
SpeakOnMuteDetectionPrivacySwitchController(
const SpeakOnMuteDetectionPrivacySwitchController&) = delete;
SpeakOnMuteDetectionPrivacySwitchController& operator=(
const SpeakOnMuteDetectionPrivacySwitchController&) = delete;
~SpeakOnMuteDetectionPrivacySwitchController() override;
// SessionObserver:
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
private:
// Enables/disables the speak-on-mute detection according to the user
// preference.
void SetSpeakOnMuteDetectionFromPref();
// The profile pref state of the speak-on-mute detection.
bool speak_on_mute_detection_pref_on_ = false;
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
base::ScopedObservation<SessionController, SessionObserver>
session_observation_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_PRIVACY_HUB_SPEAK_ON_MUTE_DETECTION_PRIVACY_SWITCH_CONTROLLER_H_