Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/chromeos/extensions/extension_system_event_observer.h" | 5 #include "chrome/browser/chromeos/extensions/extension_system_event_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/system_private/system_private_api.h" | 7 #include "chrome/browser/extensions/api/system_private/system_private_api.h" |
| 8 #include "chromeos/audio/cras_audio_handler.h" | |
| 8 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 | 10 |
| 10 namespace chromeos { | 11 namespace chromeos { |
| 11 | 12 |
| 12 ExtensionSystemEventObserver::ExtensionSystemEventObserver() { | 13 ExtensionSystemEventObserver::ExtensionSystemEventObserver() { |
| 13 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 14 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 14 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 15 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 16 CrasAudioHandler::Get()->AddAudioObserver(this); | |
| 15 } | 17 } |
| 16 | 18 |
| 17 ExtensionSystemEventObserver::~ExtensionSystemEventObserver() { | 19 ExtensionSystemEventObserver::~ExtensionSystemEventObserver() { |
| 18 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 20 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 19 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 21 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 22 if (CrasAudioHandler::IsInitialized()) | |
| 23 CrasAudioHandler::Get()->RemoveAudioObserver(this); | |
| 20 } | 24 } |
| 21 | 25 |
| 22 void ExtensionSystemEventObserver::BrightnessChanged(int level, | 26 void ExtensionSystemEventObserver::BrightnessChanged(int level, |
| 23 bool user_initiated) { | 27 bool user_initiated) { |
| 24 extensions::DispatchBrightnessChangedEvent(level, user_initiated); | 28 extensions::DispatchBrightnessChangedEvent(level, user_initiated); |
| 25 } | 29 } |
| 26 | 30 |
| 27 void ExtensionSystemEventObserver::SuspendDone( | 31 void ExtensionSystemEventObserver::SuspendDone( |
| 28 const base::TimeDelta& sleep_duration) { | 32 const base::TimeDelta& sleep_duration) { |
| 29 extensions::DispatchWokeUpEvent(); | 33 extensions::DispatchWokeUpEvent(); |
| 30 } | 34 } |
| 31 | 35 |
| 32 void ExtensionSystemEventObserver::ScreenIsUnlocked() { | 36 void ExtensionSystemEventObserver::ScreenIsUnlocked() { |
| 33 extensions::DispatchScreenUnlockedEvent(); | 37 extensions::DispatchScreenUnlockedEvent(); |
| 34 } | 38 } |
| 35 | 39 |
| 40 void ExtensionSystemEventObserver::OnOutputNodeVolumeChanged(uint64_t node_id, | |
| 41 int volume) { | |
| 42 CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); | |
| 43 extensions::DispatchVolumeChangedEvent( | |
| 44 audio_handler->GetOutputVolumePercent(), audio_handler->IsOutputMuted()); | |
| 45 } | |
| 46 | |
| 47 void ExtensionSystemEventObserver::OnOutputMuteChanged( | |
| 48 bool /* mute_on */, | |
| 49 bool /* system_adjust */) { | |
| 50 CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); | |
|
sky
2016/10/20 15:41:07
This is the same as OnOutputMuteChanged. Move to c
msw
2016/10/20 16:15:32
Done.
| |
| 51 extensions::DispatchVolumeChangedEvent( | |
| 52 audio_handler->GetOutputVolumePercent(), audio_handler->IsOutputMuted()); | |
| 53 } | |
| 54 | |
| 36 } // namespace chromeos | 55 } // namespace chromeos |
| OLD | NEW |