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

Side by Side Diff: extensions/browser/api/audio/audio_api.cc

Issue 2605983002: Simplify logic behind chrome.audio.setActiveDevices (Closed)
Patch Set: . Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 ExtensionFunction::ResponseAction AudioSetActiveDevicesFunction::Run() { 102 ExtensionFunction::ResponseAction AudioSetActiveDevicesFunction::Run() {
103 std::unique_ptr<audio::SetActiveDevices::Params> params( 103 std::unique_ptr<audio::SetActiveDevices::Params> params(
104 audio::SetActiveDevices::Params::Create(*args_)); 104 audio::SetActiveDevices::Params::Create(*args_));
105 EXTENSION_FUNCTION_VALIDATE(params.get()); 105 EXTENSION_FUNCTION_VALIDATE(params.get());
106 106
107 AudioService* service = 107 AudioService* service =
108 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); 108 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService();
109 DCHECK(service); 109 DCHECK(service);
110 110
111 service->SetActiveDevices(params->ids); 111 if (params->ids.as_device_id_lists) {
112 if (!service->SetActiveDeviceLists(
113 params->ids.as_device_id_lists->input,
114 params->ids.as_device_id_lists->output)) {
115 return RespondNow(Error("Failed to set active devices."));
116 }
117 } else if (params->ids.as_strings) {
118 // TODO(tbarzic): This way of setting active devices is deprecated - have
119 // this return error for apps that were not whitelisted for deprecated
120 // version of audio API.
121 service->SetActiveDevices(*params->ids.as_strings);
122 }
112 return RespondNow(NoArguments()); 123 return RespondNow(NoArguments());
113 } 124 }
114 125
115 /////////////////////////////////////////////////////////////////////////////// 126 ///////////////////////////////////////////////////////////////////////////////
116 127
117 ExtensionFunction::ResponseAction AudioSetPropertiesFunction::Run() { 128 ExtensionFunction::ResponseAction AudioSetPropertiesFunction::Run() {
118 std::unique_ptr<audio::SetProperties::Params> params( 129 std::unique_ptr<audio::SetProperties::Params> params(
119 audio::SetProperties::Params::Create(*args_)); 130 audio::SetProperties::Params::Create(*args_));
120 EXTENSION_FUNCTION_VALIDATE(params.get()); 131 EXTENSION_FUNCTION_VALIDATE(params.get());
121 132
(...skipping 10 matching lines...) Expand all
132 if (!service->SetDeviceProperties(params->id, params->properties.is_muted, 143 if (!service->SetDeviceProperties(params->id, params->properties.is_muted,
133 volume_value, gain_value)) { 144 volume_value, gain_value)) {
134 return RespondNow(Error("Could not set properties")); 145 return RespondNow(Error("Could not set properties"));
135 } 146 }
136 return RespondNow(NoArguments()); 147 return RespondNow(NoArguments());
137 } 148 }
138 149
139 /////////////////////////////////////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////////////////
140 151
141 } // namespace extensions 152 } // namespace extensions
OLDNEW
« no previous file with comments | « chromeos/audio/cras_audio_handler_unittest.cc ('k') | extensions/browser/api/audio/audio_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698