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

Unified Diff: chrome/browser/chromeos/extensions/extension_volume_observer.cc

Issue 2427913003: Use mojo volume interfaces for mash and classic ash. (Closed)
Patch Set: Split volume and system events observers; only hook up volume. Created 4 years, 2 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/chromeos/extensions/extension_volume_observer.cc
diff --git a/chrome/browser/chromeos/extensions/extension_volume_observer.cc b/chrome/browser/chromeos/extensions/extension_volume_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..845e76acdca3a2da0ee2ddee730291360ec832f2
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/extension_volume_observer.cc
@@ -0,0 +1,42 @@
+// Copyright 2016 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/chromeos/extensions/extension_volume_observer.h"
+
+#include "chrome/browser/extensions/api/system_private/system_private_api.h"
+#include "chromeos/audio/cras_audio_handler.h"
+
+namespace chromeos {
+
+namespace {
+
+// A helper to call the corresponding extensions method.
+void DispatchVolumeChangedEvent() {
+ CrasAudioHandler* audio_handler = CrasAudioHandler::Get();
+ extensions::DispatchVolumeChangedEvent(
+ audio_handler->GetOutputVolumePercent(), audio_handler->IsOutputMuted());
+}
+
+} // namespace
+
+ExtensionVolumeObserver::ExtensionVolumeObserver() {
+ CrasAudioHandler::Get()->AddAudioObserver(this);
+}
+
+ExtensionVolumeObserver::~ExtensionVolumeObserver() {
+ if (CrasAudioHandler::IsInitialized())
+ CrasAudioHandler::Get()->RemoveAudioObserver(this);
+}
+
+void ExtensionVolumeObserver::OnOutputNodeVolumeChanged(uint64_t node_id,
+ int volume) {
+ DispatchVolumeChangedEvent();
+}
+
+void ExtensionVolumeObserver::OnOutputMuteChanged(bool /* mute_on */,
+ bool /* system_adjust */) {
+ DispatchVolumeChangedEvent();
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/extensions/extension_volume_observer.h ('k') | chrome/browser/ui/ash/system_tray_delegate_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698