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

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: Rebased to trunk@195702 and fix conflicts. 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_ && ExtensionSystem::Get(profile_)->event_router()) {
41 scoped_ptr<Event> event(new Event(event_names::kOnAudioDeviceChanged,
42 scoped_ptr<ListValue>(new ListValue())));
43 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
44 event.Pass());
45 }
46 }
47
48 bool AudioGetInfoFunction::RunImpl() {
49 AudioService* service =
50 AudioAPI::GetFactoryInstance()->GetForProfile(profile())->GetService();
51 DCHECK(service);
52 service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted,
53 this));
54 return true;
55 }
56
57 void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info,
58 const InputInfo& input_info,
59 bool success) {
60 if (success)
61 results_ = api::audio::GetInfo::Results::Create(output_info, input_info);
62 else
63 SetError("Error occured when querying audio device information.");
64 SendResponse(success);
65 }
66
67 bool AudioSetActiveDevicesFunction::RunImpl() {
68 // TODO: implement this.
69 return false;
70 }
71
72 bool AudioSetPropertiesFunction::RunImpl() {
73 // TODO: implement this.
74 return false;
75 }
76
77 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/audio/audio_api.h ('k') | chrome/browser/extensions/api/audio/audio_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698