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
;
30 friend class BrowserContextKeyedAPIFactory
<AudioAPI
>;
32 // BrowserContextKeyedAPI implementation.
33 static const char* service_name() {
37 content::BrowserContext
* const browser_context_
;
38 AudioService
* service_
;
41 class AudioGetInfoFunction
: public AsyncExtensionFunction
{
43 DECLARE_EXTENSION_FUNCTION("audio.getInfo", AUDIO_GETINFO
);
46 ~AudioGetInfoFunction() override
{}
47 bool RunAsync() override
;
50 void OnGetInfoCompleted(const OutputInfo
& output_info
,
51 const InputInfo
& input_info
,
55 class AudioSetActiveDevicesFunction
: public SyncExtensionFunction
{
57 DECLARE_EXTENSION_FUNCTION("audio.setActiveDevices", AUDIO_SETACTIVEDEVICES
);
60 ~AudioSetActiveDevicesFunction() override
{}
61 bool RunSync() override
;
64 class AudioSetPropertiesFunction
: public SyncExtensionFunction
{
66 DECLARE_EXTENSION_FUNCTION("audio.setProperties", AUDIO_SETPROPERTIES
);
69 ~AudioSetPropertiesFunction() override
{}
70 bool RunSync() override
;
74 } // namespace extensions
76 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_API_H_