OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/system_monitor/system_monitor.h" | 12 #include "base/system_monitor/system_monitor.h" |
13 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
14 #include "chrome/common/extensions/api/webrtc_audio_private.h" | 14 #include "chrome/common/extensions/api/webrtc_audio_private.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/resource_context.h" |
16 #include "extensions/browser/browser_context_keyed_api_factory.h" | 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
17 #include "media/audio/audio_device_name.h" | 18 #include "media/audio/audio_device_name.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace content { | |
21 class ResourceContext; | |
22 } | |
23 | |
24 namespace extensions { | 21 namespace extensions { |
25 | 22 |
26 // Listens for device changes and forwards as an extension event. | 23 // Listens for device changes and forwards as an extension event. |
27 class WebrtcAudioPrivateEventService | 24 class WebrtcAudioPrivateEventService |
28 : public BrowserContextKeyedAPI, | 25 : public BrowserContextKeyedAPI, |
29 public base::SystemMonitor::DevicesChangedObserver { | 26 public base::SystemMonitor::DevicesChangedObserver { |
30 public: | 27 public: |
31 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context); | 28 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context); |
32 ~WebrtcAudioPrivateEventService() override; | 29 ~WebrtcAudioPrivateEventService() override; |
33 | 30 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void CalculateHMAC(const std::string& raw_id); | 84 void CalculateHMAC(const std::string& raw_id); |
88 | 85 |
89 // Must override this if you call CalculateHMAC. | 86 // Must override this if you call CalculateHMAC. |
90 virtual void OnHMACCalculated(const std::string& hmac); | 87 virtual void OnHMACCalculated(const std::string& hmac); |
91 | 88 |
92 // Calculates a single HMAC, using the extension ID as the security origin. | 89 // Calculates a single HMAC, using the extension ID as the security origin. |
93 // | 90 // |
94 // Call only on IO thread. | 91 // Call only on IO thread. |
95 std::string CalculateHMACImpl(const std::string& raw_id); | 92 std::string CalculateHMACImpl(const std::string& raw_id); |
96 | 93 |
97 // Initializes |resource_context_|. Must be called on the UI thread, | 94 // Initializes |device_id_salt_|. Must be called on the UI thread, |
98 // before any calls to |resource_context()|. | 95 // before any calls to |device_id_salt()|. |
99 void InitResourceContext(); | 96 void InitDeviceIDSalt(); |
100 | 97 |
101 // Callable from any thread. Must previously have called | 98 // Callable from any thread. Must previously have called |
102 // |InitResourceContext()|. | 99 // |InitDeviceIDSalt()|. |
103 content::ResourceContext* resource_context() const; | 100 const content::ResourceContext::SaltCallback& device_id_salt() const; |
104 | 101 |
105 private: | 102 private: |
106 content::ResourceContext* resource_context_; | 103 content::ResourceContext::SaltCallback device_id_salt_; |
107 | 104 |
108 DISALLOW_COPY_AND_ASSIGN(WebrtcAudioPrivateFunction); | 105 DISALLOW_COPY_AND_ASSIGN(WebrtcAudioPrivateFunction); |
109 }; | 106 }; |
110 | 107 |
111 class WebrtcAudioPrivateGetSinksFunction : public WebrtcAudioPrivateFunction { | 108 class WebrtcAudioPrivateGetSinksFunction : public WebrtcAudioPrivateFunction { |
112 protected: | 109 protected: |
113 ~WebrtcAudioPrivateGetSinksFunction() override {} | 110 ~WebrtcAudioPrivateGetSinksFunction() override {} |
114 | 111 |
115 private: | 112 private: |
116 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks", | 113 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks", |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // time, no locking needed. | 220 // time, no locking needed. |
224 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; | 221 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; |
225 | 222 |
226 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. | 223 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. |
227 media::AudioDeviceNames source_devices_; | 224 media::AudioDeviceNames source_devices_; |
228 }; | 225 }; |
229 | 226 |
230 } // namespace extensions | 227 } // namespace extensions |
231 | 228 |
232 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ | 229 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ |
OLD | NEW |