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