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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/audio/audio_api.cc
diff --git a/chrome/browser/extensions/api/audio/audio_api.cc b/chrome/browser/extensions/api/audio/audio_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aacf14fffb749c83cca89b69641ae4282b855d52
--- /dev/null
+++ b/chrome/browser/extensions/api/audio/audio_api.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/audio/audio_api.h"
+
+#include "base/lazy_instance.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/event_names.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_system.h"
+
+namespace extensions {
+
+static base::LazyInstance<ProfileKeyedAPIFactory<AudioAPI> >
+g_factory = LAZY_INSTANCE_INITIALIZER;
+
+// static
+ProfileKeyedAPIFactory<AudioAPI>* AudioAPI::GetFactoryInstance() {
+ return &g_factory.Get();
+}
+
+AudioAPI::AudioAPI(Profile* profile)
+ : profile_(profile),
+ service_(AudioService::CreateInstance()) {
+ service_->AddObserver(this);
+}
+
+AudioAPI::~AudioAPI() {
+ service_->RemoveObserver(this);
+ delete service_;
+ service_ = NULL;
+}
+
+AudioService* AudioAPI::GetService() const {
+ return service_;
+}
+
+void AudioAPI::OnDeviceChanged() {
+ if (profile_ && ExtensionSystem::Get(profile_)->event_router()) {
+ scoped_ptr<Event> event(new Event(event_names::kOnAudioDeviceChanged,
+ scoped_ptr<ListValue>(new ListValue())));
+ ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(
+ event.Pass());
+ }
+}
+
+bool AudioGetInfoFunction::RunImpl() {
+ AudioService* service =
+ AudioAPI::GetFactoryInstance()->GetForProfile(profile())->GetService();
+ DCHECK(service);
+ service->StartGetInfo(base::Bind(&AudioGetInfoFunction::OnGetInfoCompleted,
+ this));
+ return true;
+}
+
+void AudioGetInfoFunction::OnGetInfoCompleted(const OutputInfo& output_info,
+ const InputInfo& input_info,
+ bool success) {
+ if (success)
+ results_ = api::audio::GetInfo::Results::Create(output_info, input_info);
+ else
+ SetError("Error occured when querying audio device information.");
+ SendResponse(success);
+}
+
+bool AudioSetActiveDevicesFunction::RunImpl() {
+ // TODO: implement this.
+ return false;
+}
+
+bool AudioSetPropertiesFunction::RunImpl() {
+ // TODO: implement this.
+ return false;
+}
+
+} // namespace extensions
« 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