OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "extensions/browser/api/audio/audio_api.h" | 5 #include "extensions/browser/api/audio/audio_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "extensions/browser/event_router.h" | 9 #include "extensions/browser/event_router.h" |
10 #include "extensions/common/api/audio.h" | 10 #include "extensions/common/api/audio.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 void AudioAPI::OnDeviceChanged() { | 39 void AudioAPI::OnDeviceChanged() { |
40 if (browser_context_ && EventRouter::Get(browser_context_)) { | 40 if (browser_context_ && EventRouter::Get(browser_context_)) { |
41 scoped_ptr<Event> event(new Event( | 41 scoped_ptr<Event> event(new Event( |
42 audio::OnDeviceChanged::kEventName, | 42 audio::OnDeviceChanged::kEventName, |
43 scoped_ptr<base::ListValue>(new base::ListValue()))); | 43 scoped_ptr<base::ListValue>(new base::ListValue()))); |
44 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 44 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
| 48 void AudioAPI::OnOutputNodeVolumeChanged(const std::string& id, double volume) { |
| 49 if (browser_context_ && EventRouter::Get(browser_context_)) { |
| 50 scoped_ptr<base::ListValue> args = |
| 51 audio::OnOutputNodeVolumeChanged::Create(id, volume); |
| 52 scoped_ptr<Event> event( |
| 53 new Event(audio::OnOutputNodeVolumeChanged::kEventName, args.Pass())); |
| 54 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 55 } |
| 56 } |
| 57 |
48 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
49 | 59 |
50 bool AudioGetInfoFunction::RunAsync() { | 60 bool AudioGetInfoFunction::RunAsync() { |
51 AudioService* service = | 61 AudioService* service = |
52 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); | 62 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); |
53 DCHECK(service); | 63 DCHECK(service); |
54 service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted, | 64 service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted, |
55 this)); | 65 this)); |
56 return true; | 66 return true; |
57 } | 67 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 110 |
101 if (!service->SetDeviceProperties(params->id, | 111 if (!service->SetDeviceProperties(params->id, |
102 params->properties.is_muted, | 112 params->properties.is_muted, |
103 volume_value, | 113 volume_value, |
104 gain_value)) | 114 gain_value)) |
105 return false; | 115 return false; |
106 else | 116 else |
107 return true; | 117 return true; |
108 } | 118 } |
109 | 119 |
| 120 /////////////////////////////////////////////////////////////////////////////// |
| 121 |
| 122 bool AudioGetDeviceInfoFunction::RunAsync() { |
| 123 AudioService* service = |
| 124 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); |
| 125 DCHECK(service); |
| 126 service->StartGetDeviceInfo( |
| 127 base::Bind(&AudioGetDeviceInfoFunction::OnGetDeviceInfoCompleted, this)); |
| 128 return true; |
| 129 } |
| 130 |
| 131 void AudioGetDeviceInfoFunction::OnGetDeviceInfoCompleted( |
| 132 const DevicesInfo& devices_info, |
| 133 bool success) { |
| 134 if (success) |
| 135 results_ = audio::GetDeviceInfo::Results::Create(devices_info); |
| 136 else |
| 137 SetError("Error occurred when querying audio device information."); |
| 138 SendResponse(success); |
| 139 } |
| 140 |
| 141 /////////////////////////////////////////////////////////////////////////////// |
| 142 |
110 } // namespace extensions | 143 } // namespace extensions |
OLD | NEW |