| 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 20 matching lines...) Expand all Loading... |
| 31 delete service_; | 31 delete service_; |
| 32 service_ = NULL; | 32 service_ = NULL; |
| 33 } | 33 } |
| 34 | 34 |
| 35 AudioService* AudioAPI::GetService() const { | 35 AudioService* AudioAPI::GetService() const { |
| 36 return service_; | 36 return service_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void AudioAPI::OnDeviceChanged() { | 39 void AudioAPI::OnDeviceChanged() { |
| 40 if (EventRouter::Get(browser_context_)) { | 40 if (EventRouter::Get(browser_context_)) { |
| 41 scoped_ptr<Event> event(new Event( | 41 scoped_ptr<Event> event( |
| 42 audio::OnDeviceChanged::kEventName, | 42 new Event(events::UNKNOWN, 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::OnLevelChanged(const std::string& id, int level) { | 48 void AudioAPI::OnLevelChanged(const std::string& id, int level) { |
| 49 if (EventRouter::Get(browser_context_)) { | 49 if (EventRouter::Get(browser_context_)) { |
| 50 scoped_ptr<base::ListValue> args = audio::OnLevelChanged::Create(id, level); | 50 scoped_ptr<base::ListValue> args = audio::OnLevelChanged::Create(id, level); |
| 51 scoped_ptr<Event> event( | 51 scoped_ptr<Event> event(new Event( |
| 52 new Event(audio::OnLevelChanged::kEventName, args.Pass())); | 52 events::UNKNOWN, audio::OnLevelChanged::kEventName, args.Pass())); |
| 53 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 53 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 void AudioAPI::OnMuteChanged(bool is_input, bool is_muted) { | 57 void AudioAPI::OnMuteChanged(bool is_input, bool is_muted) { |
| 58 if (EventRouter::Get(browser_context_)) { | 58 if (EventRouter::Get(browser_context_)) { |
| 59 scoped_ptr<base::ListValue> args = | 59 scoped_ptr<base::ListValue> args = |
| 60 audio::OnMuteChanged::Create(is_input, is_muted); | 60 audio::OnMuteChanged::Create(is_input, is_muted); |
| 61 scoped_ptr<Event> event( | 61 scoped_ptr<Event> event(new Event( |
| 62 new Event(audio::OnMuteChanged::kEventName, args.Pass())); | 62 events::UNKNOWN, audio::OnMuteChanged::kEventName, args.Pass())); |
| 63 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 63 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void AudioAPI::OnDevicesChanged(const DeviceInfoList& devices) { | 67 void AudioAPI::OnDevicesChanged(const DeviceInfoList& devices) { |
| 68 if (EventRouter::Get(browser_context_)) { | 68 if (EventRouter::Get(browser_context_)) { |
| 69 scoped_ptr<base::ListValue> args = audio::OnDevicesChanged::Create(devices); | 69 scoped_ptr<base::ListValue> args = audio::OnDevicesChanged::Create(devices); |
| 70 scoped_ptr<Event> event( | 70 scoped_ptr<Event> event(new Event( |
| 71 new Event(audio::OnDevicesChanged::kEventName, args.Pass())); | 71 events::UNKNOWN, audio::OnDevicesChanged::kEventName, args.Pass())); |
| 72 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 72 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 /////////////////////////////////////////////////////////////////////////////// | 76 /////////////////////////////////////////////////////////////////////////////// |
| 77 | 77 |
| 78 bool AudioGetInfoFunction::RunAsync() { | 78 bool AudioGetInfoFunction::RunAsync() { |
| 79 AudioService* service = | 79 AudioService* service = |
| 80 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); | 80 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); |
| 81 DCHECK(service); | 81 DCHECK(service); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 volume_value, | 131 volume_value, |
| 132 gain_value)) | 132 gain_value)) |
| 133 return false; | 133 return false; |
| 134 else | 134 else |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
| 139 | 139 |
| 140 } // namespace extensions | 140 } // namespace extensions |
| OLD | NEW |