Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: extensions/browser/api/audio/audio_api.cc

Issue 945103002: Add a new audio extension event OnLevelChanged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/audio/audio_api.cc
diff --git a/extensions/browser/api/audio/audio_api.cc b/extensions/browser/api/audio/audio_api.cc
index 659ae6ce67637ac20228a53e47681c1ab558b37a..3bd7219067503c3a6443614a10f6cca1549530f5 100644
--- a/extensions/browser/api/audio/audio_api.cc
+++ b/extensions/browser/api/audio/audio_api.cc
@@ -45,6 +45,16 @@ void AudioAPI::OnDeviceChanged() {
}
}
+void AudioAPI::OnOutputNodeVolumeChanged(const std::string& id, double volume) {
+ if (browser_context_ && EventRouter::Get(browser_context_)) {
+ scoped_ptr<base::ListValue> args =
+ audio::OnOutputNodeVolumeChanged::Create(id, volume);
+ scoped_ptr<Event> event(
+ new Event(audio::OnOutputNodeVolumeChanged::kEventName, args.Pass()));
+ EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
bool AudioGetInfoFunction::RunAsync() {
@@ -107,4 +117,27 @@ bool AudioSetPropertiesFunction::RunSync() {
return true;
}
+///////////////////////////////////////////////////////////////////////////////
+
+bool AudioGetDeviceInfoFunction::RunAsync() {
+ AudioService* service =
+ AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService();
+ DCHECK(service);
+ service->StartGetDeviceInfo(
+ base::Bind(&AudioGetDeviceInfoFunction::OnGetDeviceInfoCompleted, this));
+ return true;
+}
+
+void AudioGetDeviceInfoFunction::OnGetDeviceInfoCompleted(
+ const DevicesInfo& devices_info,
+ bool success) {
+ if (success)
+ results_ = audio::GetDeviceInfo::Results::Create(devices_info);
+ else
+ SetError("Error occurred when querying audio device information.");
+ SendResponse(success);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698