| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef ASH_COMMON_SYSTEM_AUDIO_TRAY_AUDIO_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_TRAY_AUDIO_H_ |
| 6 #define ASH_COMMON_SYSTEM_AUDIO_TRAY_AUDIO_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_TRAY_AUDIO_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "ash/common/system/audio/audio_observer.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/common/system/chromeos/audio/audio_observer.h" |
| 13 #include "ash/common/system/tray/tray_image_item.h" | 14 #include "ash/common/system/tray/tray_image_item.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "chromeos/dbus/power_manager_client.h" |
| 15 #include "ui/display/display_observer.h" | 17 #include "ui/display/display_observer.h" |
| 16 | 18 |
| 17 namespace ash { | 19 namespace ash { |
| 18 | 20 |
| 19 namespace system { | 21 namespace system { |
| 20 class TrayAudioDelegate; | 22 class TrayAudioDelegate; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace tray { | 25 namespace tray { |
| 26 class AudioDetailedView; |
| 24 class VolumeView; | 27 class VolumeView; |
| 25 } | 28 } |
| 26 | 29 |
| 27 class TrayAudio : public TrayImageItem, | 30 // The system tray item for audio input and output. |
| 28 public AudioObserver, | 31 class ASH_EXPORT TrayAudio : public TrayImageItem, |
| 29 public display::DisplayObserver { | 32 public AudioObserver, |
| 33 public display::DisplayObserver, |
| 34 public chromeos::PowerManagerClient::Observer { |
| 30 public: | 35 public: |
| 31 TrayAudio(SystemTray* system_tray, | 36 explicit TrayAudio(SystemTray* system_tray); |
| 32 std::unique_ptr<system::TrayAudioDelegate> audio_delegate); | |
| 33 ~TrayAudio() override; | 37 ~TrayAudio() override; |
| 34 | 38 |
| 35 static bool ShowAudioDeviceMenu(); | 39 private: |
| 36 | |
| 37 protected: | |
| 38 // Overridden from display::DisplayObserver. | 40 // Overridden from display::DisplayObserver. |
| 39 void OnDisplayAdded(const display::Display& new_display) override; | 41 void OnDisplayAdded(const display::Display& new_display) override; |
| 40 void OnDisplayRemoved(const display::Display& old_display) override; | 42 void OnDisplayRemoved(const display::Display& old_display) override; |
| 41 void OnDisplayMetricsChanged(const display::Display& display, | 43 void OnDisplayMetricsChanged(const display::Display& display, |
| 42 uint32_t changed_metrics) override; | 44 uint32_t changed_metrics) override; |
| 43 | 45 |
| 44 virtual void Update(); | |
| 45 | |
| 46 std::unique_ptr<system::TrayAudioDelegate> audio_delegate_; | |
| 47 tray::VolumeView* volume_view_; | |
| 48 | |
| 49 // True if VolumeView should be created for accelerator pop up; | |
| 50 // Otherwise, it should be created for detailed view in ash tray bubble. | |
| 51 bool pop_up_volume_view_; | |
| 52 | |
| 53 private: | |
| 54 // Overridden from TrayImageItem. | 46 // Overridden from TrayImageItem. |
| 55 bool GetInitialVisibility() override; | 47 bool GetInitialVisibility() override; |
| 56 | 48 |
| 57 // Overridden from SystemTrayItem. | 49 // Overridden from SystemTrayItem. |
| 58 views::View* CreateDefaultView(LoginStatus status) override; | 50 views::View* CreateDefaultView(LoginStatus status) override; |
| 59 views::View* CreateDetailedView(LoginStatus status) override; | 51 views::View* CreateDetailedView(LoginStatus status) override; |
| 60 void DestroyDefaultView() override; | 52 void DestroyDefaultView() override; |
| 61 void DestroyDetailedView() override; | 53 void DestroyDetailedView() override; |
| 62 bool ShouldHideArrow() const override; | 54 bool ShouldHideArrow() const override; |
| 63 bool ShouldShowShelf() const override; | 55 bool ShouldShowShelf() const override; |
| 64 | 56 |
| 65 // Overridden from AudioObserver. | 57 // Overridden from AudioObserver. |
| 66 void OnOutputNodeVolumeChanged(uint64_t node_id, double volume) override; | 58 void OnOutputNodeVolumeChanged(uint64_t node_id, double volume) override; |
| 67 void OnOutputMuteChanged(bool mute_on, bool system_adjust) override; | 59 void OnOutputMuteChanged(bool mute_on, bool system_adjust) override; |
| 68 void OnAudioNodesChanged() override; | 60 void OnAudioNodesChanged() override; |
| 69 void OnActiveOutputNodeChanged() override; | 61 void OnActiveOutputNodeChanged() override; |
| 70 void OnActiveInputNodeChanged() override; | 62 void OnActiveInputNodeChanged() override; |
| 71 | 63 |
| 64 // Overridden from chromeos::PowerManagerClient::Observer. |
| 65 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 66 |
| 67 // Swaps the left and right channels on yoga devices based on orientation. |
| 72 void ChangeInternalSpeakerChannelMode(); | 68 void ChangeInternalSpeakerChannelMode(); |
| 73 | 69 |
| 70 // Updates the UI views. |
| 71 void Update(); |
| 72 |
| 73 // TODO(jamescook): Remove this delegate and inline all the code. |
| 74 std::unique_ptr<system::TrayAudioDelegate> audio_delegate_; |
| 75 tray::VolumeView* volume_view_; |
| 76 |
| 77 // True if VolumeView should be created for accelerator pop up; |
| 78 // Otherwise, it should be created for detailed view in ash tray bubble. |
| 79 bool pop_up_volume_view_; |
| 80 |
| 81 tray::AudioDetailedView* audio_detail_view_; |
| 82 |
| 74 DISALLOW_COPY_AND_ASSIGN(TrayAudio); | 83 DISALLOW_COPY_AND_ASSIGN(TrayAudio); |
| 75 }; | 84 }; |
| 76 | 85 |
| 77 } // namespace ash | 86 } // namespace ash |
| 78 | 87 |
| 79 #endif // ASH_COMMON_SYSTEM_AUDIO_TRAY_AUDIO_H_ | 88 #endif // ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_TRAY_AUDIO_H_ |
| OLD | NEW |