Convert env to a defaultdict in run_executable() to fix other callers of that function.
[chromium-blink-merge.git] / extensions / shell / browser / shell_audio_controller_chromeos.h
blob7ab2e3386c7989b825dff00fd83e4f96e9426dae
1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_
8 #include "base/macros.h"
9 #include "chromeos/audio/audio_devices_pref_handler.h"
10 #include "chromeos/audio/cras_audio_handler.h"
12 namespace chromeos {
13 class AudioDevicesPrefHandler;
16 namespace extensions {
18 // Ensures that the "best" input and output audio devices are always active.
19 class ShellAudioController : public chromeos::CrasAudioHandler::AudioObserver {
20 public:
21 // Requests max volume for all devices and doesn't bother saving prefs.
22 class PrefHandler : public chromeos::AudioDevicesPrefHandler {
23 public:
24 PrefHandler();
26 // chromeos::AudioDevicesPrefHandler implementation:
27 virtual double GetOutputVolumeValue(
28 const chromeos::AudioDevice* device) override;
29 virtual double GetInputGainValue(
30 const chromeos::AudioDevice* device) override;
31 virtual void SetVolumeGainValue(const chromeos::AudioDevice& device,
32 double value) override;
33 virtual bool GetMuteValue(const chromeos::AudioDevice& device) override;
34 virtual void SetMuteValue(const chromeos::AudioDevice& device,
35 bool mute_on) override;
36 virtual bool GetAudioCaptureAllowedValue() override;
37 virtual bool GetAudioOutputAllowedValue() override;
38 virtual void AddAudioPrefObserver(
39 chromeos::AudioPrefObserver* observer) override;
40 virtual void RemoveAudioPrefObserver(
41 chromeos::AudioPrefObserver* observer) override;
43 protected:
44 virtual ~PrefHandler();
46 private:
47 DISALLOW_COPY_AND_ASSIGN(PrefHandler);
50 ShellAudioController();
51 virtual ~ShellAudioController();
53 // chromeos::CrasAudioHandler::Observer implementation:
54 virtual void OnOutputVolumeChanged() override;
55 virtual void OnOutputMuteChanged() override;
56 virtual void OnInputGainChanged() override;
57 virtual void OnInputMuteChanged() override;
58 virtual void OnAudioNodesChanged() override;
59 virtual void OnActiveOutputNodeChanged() override;
60 virtual void OnActiveInputNodeChanged() override;
62 private:
63 // Gets the current device list from CRAS, chooses the best input and output
64 // device, and activates them if they aren't already active.
65 void ActivateDevices();
67 DISALLOW_COPY_AND_ASSIGN(ShellAudioController);
70 } // namespace extensions
72 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_AUDIO_CONTROLLER_CHROMEOS_H_