Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / browser / api / audio / audio_api.h
blob29e526b194597d51f72bd03480a86a50c87135d9
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 {
14 class AudioService;
16 class AudioAPI : public BrowserContextKeyedAPI, public AudioService::Observer {
17 public:
18 explicit AudioAPI(content::BrowserContext* context);
19 ~AudioAPI() override;
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;
32 private:
33 friend class BrowserContextKeyedAPIFactory<AudioAPI>;
35 // BrowserContextKeyedAPI implementation.
36 static const char* service_name() {
37 return "AudioAPI";
40 content::BrowserContext* const browser_context_;
41 AudioService* service_;
44 class AudioGetInfoFunction : public AsyncExtensionFunction {
45 public:
46 DECLARE_EXTENSION_FUNCTION("audio.getInfo", AUDIO_GETINFO);
48 protected:
49 ~AudioGetInfoFunction() override {}
50 bool RunAsync() override;
52 private:
53 void OnGetInfoCompleted(const OutputInfo& output_info,
54 const InputInfo& input_info,
55 bool success);
58 class AudioSetActiveDevicesFunction : public SyncExtensionFunction {
59 public:
60 DECLARE_EXTENSION_FUNCTION("audio.setActiveDevices", AUDIO_SETACTIVEDEVICES);
62 protected:
63 ~AudioSetActiveDevicesFunction() override {}
64 bool RunSync() override;
67 class AudioSetPropertiesFunction : public SyncExtensionFunction {
68 public:
69 DECLARE_EXTENSION_FUNCTION("audio.setProperties", AUDIO_SETPROPERTIES);
71 protected:
72 ~AudioSetPropertiesFunction() override {}
73 bool RunSync() override;
76 } // namespace extensions
78 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_API_H_