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

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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return RespondNow( 92 return RespondNow(
93 Error("Error occurred when querying audio device information.")); 93 Error("Error occurred when querying audio device information."));
94 } 94 }
95 95
96 return RespondNow( 96 return RespondNow(
97 ArgumentList(audio::GetInfo::Results::Create(output_info, input_info))); 97 ArgumentList(audio::GetInfo::Results::Create(output_info, input_info)));
98 } 98 }
99 99
100 /////////////////////////////////////////////////////////////////////////////// 100 ///////////////////////////////////////////////////////////////////////////////
101 101
102 ExtensionFunction::ResponseAction AudioSetActiveDeviceListsFunction::Run() {
103 std::unique_ptr<audio::SetActiveDeviceLists::Params> params(
104 audio::SetActiveDeviceLists::Params::Create(*args_));
105 EXTENSION_FUNCTION_VALIDATE(params.get());
106
107 AudioService* service =
108 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService();
109 DCHECK(service);
110
111 if (!service->SetActiveDeviceLists(params->ids.input, params->ids.output)) {
112 return RespondNow(Error("Failed to set active devices."));
113 }
114 return RespondNow(NoArguments());
115 }
116
117 ///////////////////////////////////////////////////////////////////////////////
118
102 ExtensionFunction::ResponseAction AudioSetActiveDevicesFunction::Run() { 119 ExtensionFunction::ResponseAction AudioSetActiveDevicesFunction::Run() {
103 std::unique_ptr<audio::SetActiveDevices::Params> params( 120 std::unique_ptr<audio::SetActiveDevices::Params> params(
104 audio::SetActiveDevices::Params::Create(*args_)); 121 audio::SetActiveDevices::Params::Create(*args_));
105 EXTENSION_FUNCTION_VALIDATE(params.get()); 122 EXTENSION_FUNCTION_VALIDATE(params.get());
106 123
107 AudioService* service = 124 AudioService* service =
108 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService(); 125 AudioAPI::GetFactoryInstance()->Get(browser_context())->GetService();
109 DCHECK(service); 126 DCHECK(service);
110 127
111 service->SetActiveDevices(params->ids); 128 service->SetActiveDevices(params->ids);
(...skipping 20 matching lines...) Expand all
132 if (!service->SetDeviceProperties(params->id, params->properties.is_muted, 149 if (!service->SetDeviceProperties(params->id, params->properties.is_muted,
133 volume_value, gain_value)) { 150 volume_value, gain_value)) {
134 return RespondNow(Error("Could not set properties")); 151 return RespondNow(Error("Could not set properties"));
135 } 152 }
136 return RespondNow(NoArguments()); 153 return RespondNow(NoArguments());
137 } 154 }
138 155
139 /////////////////////////////////////////////////////////////////////////////// 156 ///////////////////////////////////////////////////////////////////////////////
140 157
141 } // namespace extensions 158 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698