1 // Copyright (c) 2013 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_BROWSER_API_AUDIO_AUDIO_API_H_
6 #define EXTENSIONS_BROWSER_API_AUDIO_AUDIO_API_H_
8 #include "extensions/browser/api/audio/audio_service.h"
9 #include "extensions/browser/browser_context_keyed_api_factory.h"
10 #include "extensions/browser/extension_function.h"
12 namespace extensions
{
16 class AudioAPI
: public BrowserContextKeyedAPI
, public AudioService::Observer
{
18 explicit AudioAPI(content::BrowserContext
* context
);
21 AudioService
* GetService() const;
23 // BrowserContextKeyedAPI implementation.
24 static BrowserContextKeyedAPIFactory
<AudioAPI
>* GetFactoryInstance();
26 // AudioService::Observer implementation.
27 void OnDeviceChanged() override
;
28 void OnLevelChanged(const std::string
& id
, int level
) override
;
29 void OnMuteChanged(bool is_input
, bool is_muted
) override
;
30 void OnDevicesChanged(const DeviceInfoList
& devices
) override
;
33 friend class BrowserContextKeyedAPIFactory
<AudioAPI
>;
35 // BrowserContextKeyedAPI implementation.
36 static const char* service_name() {
40 content::BrowserContext
* const browser_context_
;
41 AudioService
* service_
;
44 class AudioGetInfoFunction
: public AsyncExtensionFunction
{
46 DECLARE_EXTENSION_FUNCTION("audio.getInfo", AUDIO_GETINFO
);
49 ~AudioGetInfoFunction() override
{}
50 bool RunAsync() override
;
53 void OnGetInfoCompleted(const OutputInfo
& output_info
,
54 const InputInfo
& input_info
,
58 class AudioSetActiveDevicesFunction
: public SyncExtensionFunction
{
60 DECLARE_EXTENSION_FUNCTION("audio.setActiveDevices", AUDIO_SETACTIVEDEVICES
);
63 ~AudioSetActiveDevicesFunction() override
{}
64 bool RunSync() override
;
67 class AudioSetPropertiesFunction
: public SyncExtensionFunction
{
69 DECLARE_EXTENSION_FUNCTION("audio.setProperties", AUDIO_SETPROPERTIES
);
72 ~AudioSetPropertiesFunction() override
{}
73 bool RunSync() override
;
76 } // namespace extensions
78 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_API_H_