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

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

Issue 13486004: Audio extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update chrome/test/DEPS. Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/audio/audio_api.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/values.h"
9 #include "chrome/browser/extensions/event_names.h"
10 #include "chrome/browser/extensions/event_router.h"
11 #include "chrome/browser/extensions/extension_system.h"
12
13 namespace extensions {
14
15 static base::LazyInstance<ProfileKeyedAPIFactory<AudioAPI> >
16 g_factory = LAZY_INSTANCE_INITIALIZER;
17
18 // static
19 ProfileKeyedAPIFactory<AudioAPI>* AudioAPI::GetFactoryInstance() {
20 return &g_factory.Get();
21 }
22
23 AudioAPI::AudioAPI(Profile* profile)
24 : profile_(profile),
25 service_(AudioService::CreateInstance()) {
26 service_->AddObserver(this);
27 }
28
29 AudioAPI::~AudioAPI() {
30 service_->RemoveObserver(this);
31 delete service_;
32 service_ = NULL;
33 }
34
35 AudioService* AudioAPI::GetService() const {
36 return service_;
37 }
38
39 void AudioAPI::OnDeviceChanged() {
40 if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) {
41 scoped_ptr<extensions::Event> event(new extensions::Event(
42 event_names::kOnAudioDeviceChanged,
43 scoped_ptr<ListValue>(new ListValue())));
44 extensions::ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
45 event.Pass());
46 }
47 }
48
49 bool AudioGetInfoFunction::RunImpl() {
50 AudioService* service =
51 AudioAPI::GetFactoryInstance()->GetForProfile(profile())->GetService();
52 DCHECK(service);
53 service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted,
54 this));
55 return true;
56 }
57
58 void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info,
59 const InputInfo& input_info,
60 bool success) {
61 if (success)
62 results_ = api::audio::GetInfo::Results::Create(output_info, input_info);
63 else
64 SetError("Error occured when querying audio device information.");
65 SendResponse(success);
66 }
67
68 bool AudioSetActiveDevicesFunction::RunImpl() {
69 return false;
rkc 2013/04/22 22:54:19 Add TODO here and below.
hshi1 2013/04/22 23:02:16 Done.
70 }
71
72 bool AudioSetPropertiesFunction::RunImpl() {
73 return false;
74 }
75
76 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698