• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_API_H_
7 
8 #include "chrome/browser/extensions/api/audio/audio_service.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11 
12 namespace extensions {
13 
14 class AudioService;
15 
16 class AudioAPI : public BrowserContextKeyedAPI, public AudioService::Observer {
17  public:
18   explicit AudioAPI(content::BrowserContext* context);
19   virtual ~AudioAPI();
20 
21   AudioService* GetService() const;
22 
23   // BrowserContextKeyedAPI implementation.
24   static BrowserContextKeyedAPIFactory<AudioAPI>* GetFactoryInstance();
25 
26   // AudioService::Observer implementation.
27   virtual void OnDeviceChanged() OVERRIDE;
28 
29  private:
30   friend class BrowserContextKeyedAPIFactory<AudioAPI>;
31 
32   // BrowserContextKeyedAPI implementation.
service_name()33   static const char* service_name() {
34     return "AudioAPI";
35   }
36 
37   content::BrowserContext* const browser_context_;
38   AudioService* service_;
39 };
40 
41 class AudioGetInfoFunction : public ChromeAsyncExtensionFunction {
42  public:
43   DECLARE_EXTENSION_FUNCTION("audio.getInfo",
44                              AUDIO_GETINFO);
45 
46  protected:
~AudioGetInfoFunction()47   virtual ~AudioGetInfoFunction() {}
48   virtual bool RunAsync() OVERRIDE;
49 
50  private:
51   void OnGetInfoCompleted(const OutputInfo& output_info,
52                           const InputInfo& input_info,
53                           bool success);
54 };
55 
56 class AudioSetActiveDevicesFunction : public ChromeSyncExtensionFunction {
57  public:
58   DECLARE_EXTENSION_FUNCTION("audio.setActiveDevices",
59                              AUDIO_SETACTIVEDEVICES);
60 
61  protected:
~AudioSetActiveDevicesFunction()62   virtual ~AudioSetActiveDevicesFunction() {}
63   virtual bool RunSync() OVERRIDE;
64 };
65 
66 class AudioSetPropertiesFunction : public ChromeSyncExtensionFunction {
67  public:
68   DECLARE_EXTENSION_FUNCTION("audio.setProperties",
69                              AUDIO_SETPROPERTIES);
70 
71  protected:
~AudioSetPropertiesFunction()72   virtual ~AudioSetPropertiesFunction() {}
73   virtual bool RunSync() OVERRIDE;
74 };
75 
76 
77 }  // namespace extensions
78 
79 #endif  // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_API_H_
80