| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 scoped_ptr<base::ListValue> args = audio::OnDevicesChanged::Create(devices); | 73 scoped_ptr<base::ListValue> args = audio::OnDevicesChanged::Create(devices); |
| 74 scoped_ptr<Event> event(new Event(events::AUDIO_ON_DEVICES_CHANGED, | 74 scoped_ptr<Event> event(new Event(events::AUDIO_ON_DEVICES_CHANGED, |
| 75 audio::OnDevicesChanged::kEventName, | 75 audio::OnDevicesChanged::kEventName, |
| 76 std::move(args))); | 76 std::move(args))); |
| 77 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 77 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
| 82 | 82 |
| 83 bool AudioGetInfoFunction::RunAsync() { | 83 bool AudioGetInfoFunction::RunSync() { |
| 84 AudioService* service = | 84 AudioService* service = |
| 85 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); | 85 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); |
| 86 DCHECK(service); | 86 DCHECK(service); |
| 87 service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted, | 87 OutputInfo output_info; |
| 88 this)); | 88 InputInfo input_info; |
| 89 if (!service->GetInfo(&output_info, &input_info)) { |
| 90 SetError("Error occurred when querying audio device information."); |
| 91 return false; |
| 92 } |
| 93 |
| 94 results_ = audio::GetInfo::Results::Create(output_info, input_info); |
| 89 return true; | 95 return true; |
| 90 } | 96 } |
| 91 | 97 |
| 92 void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info, | |
| 93 const InputInfo& input_info, | |
| 94 bool success) { | |
| 95 if (success) | |
| 96 results_ = audio::GetInfo::Results::Create(output_info, input_info); | |
| 97 else | |
| 98 SetError("Error occurred when querying audio device information."); | |
| 99 SendResponse(success); | |
| 100 } | |
| 101 | |
| 102 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
| 103 | 99 |
| 104 bool AudioSetActiveDevicesFunction::RunSync() { | 100 bool AudioSetActiveDevicesFunction::RunSync() { |
| 105 scoped_ptr<audio::SetActiveDevices::Params> params( | 101 scoped_ptr<audio::SetActiveDevices::Params> params( |
| 106 audio::SetActiveDevices::Params::Create(*args_)); | 102 audio::SetActiveDevices::Params::Create(*args_)); |
| 107 EXTENSION_FUNCTION_VALIDATE(params.get()); | 103 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 108 | 104 |
| 109 AudioService* service = | 105 AudioService* service = |
| 110 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); | 106 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); |
| 111 DCHECK(service); | 107 DCHECK(service); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 136 volume_value, | 132 volume_value, |
| 137 gain_value)) | 133 gain_value)) |
| 138 return false; | 134 return false; |
| 139 else | 135 else |
| 140 return true; | 136 return true; |
| 141 } | 137 } |
| 142 | 138 |
| 143 /////////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////////// |
| 144 | 140 |
| 145 } // namespace extensions | 141 } // namespace extensions |
| OLD | NEW |