| 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 "chrome/browser/extensions/api/audio/audio_api.h" | 5 #include "chrome/browser/extensions/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 "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/extensions/api/audio.h" | 10 #include "chrome/common/extensions/api/audio.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info, | 58 void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info, |
| 59 const InputInfo& input_info, | 59 const InputInfo& input_info, |
| 60 bool success) { | 60 bool success) { |
| 61 if (success) | 61 if (success) |
| 62 results_ = api::audio::GetInfo::Results::Create(output_info, input_info); | 62 results_ = api::audio::GetInfo::Results::Create(output_info, input_info); |
| 63 else | 63 else |
| 64 SetError("Error occurred when querying audio device information."); | 64 SetError("Error occurred when querying audio device information."); |
| 65 SendResponse(success); | 65 SendResponse(success); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool AudioSetActiveDevicesFunction::RunImpl() { | 68 bool AudioSetActiveDevicesFunction::RunSync() { |
| 69 scoped_ptr<api::audio::SetActiveDevices::Params> params( | 69 scoped_ptr<api::audio::SetActiveDevices::Params> params( |
| 70 api::audio::SetActiveDevices::Params::Create(*args_)); | 70 api::audio::SetActiveDevices::Params::Create(*args_)); |
| 71 EXTENSION_FUNCTION_VALIDATE(params.get()); | 71 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 72 | 72 |
| 73 AudioService* service = | 73 AudioService* service = |
| 74 AudioAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 74 AudioAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
| 75 DCHECK(service); | 75 DCHECK(service); |
| 76 | 76 |
| 77 service->SetActiveDevices(params->ids); | 77 service->SetActiveDevices(params->ids); |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool AudioSetPropertiesFunction::RunImpl() { | 81 bool AudioSetPropertiesFunction::RunSync() { |
| 82 scoped_ptr<api::audio::SetProperties::Params> params( | 82 scoped_ptr<api::audio::SetProperties::Params> params( |
| 83 api::audio::SetProperties::Params::Create(*args_)); | 83 api::audio::SetProperties::Params::Create(*args_)); |
| 84 EXTENSION_FUNCTION_VALIDATE(params.get()); | 84 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 85 | 85 |
| 86 AudioService* service = | 86 AudioService* service = |
| 87 AudioAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 87 AudioAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
| 88 DCHECK(service); | 88 DCHECK(service); |
| 89 | 89 |
| 90 int volume_value = params->properties.volume.get() ? | 90 int volume_value = params->properties.volume.get() ? |
| 91 *params->properties.volume : -1; | 91 *params->properties.volume : -1; |
| 92 | 92 |
| 93 int gain_value = params->properties.gain.get() ? | 93 int gain_value = params->properties.gain.get() ? |
| 94 *params->properties.gain : -1; | 94 *params->properties.gain : -1; |
| 95 | 95 |
| 96 if (!service->SetDeviceProperties(params->id, | 96 if (!service->SetDeviceProperties(params->id, |
| 97 params->properties.is_muted, | 97 params->properties.is_muted, |
| 98 volume_value, | 98 volume_value, |
| 99 gain_value)) | 99 gain_value)) |
| 100 return false; | 100 return false; |
| 101 else | 101 else |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace extensions | 105 } // namespace extensions |
| OLD | NEW |