OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/system/chromeos/audio/tray_audio_chromeos.h" | |
6 | |
7 #include "ash/common/system/audio/volume_view.h" | |
8 #include "ash/common/wm_shell.h" | |
9 #include "ash/system/chromeos/audio/audio_detailed_view.h" | |
10 #include "ash/system/chromeos/audio/tray_audio_delegate_chromeos.h" | |
11 #include "chromeos/dbus/dbus_thread_manager.h" | |
12 #include "ui/views/view.h" | |
13 | |
14 namespace ash { | |
15 | |
16 using system::TrayAudioDelegate; | |
17 using system::TrayAudioDelegateChromeOs; | |
18 | |
19 TrayAudioChromeOs::TrayAudioChromeOs(SystemTray* system_tray) | |
20 : TrayAudio( | |
21 system_tray, | |
22 std::unique_ptr<TrayAudioDelegate>(new TrayAudioDelegateChromeOs())), | |
23 audio_detail_view_(NULL) { | |
24 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( | |
25 this); | |
26 } | |
27 | |
28 TrayAudioChromeOs::~TrayAudioChromeOs() { | |
29 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( | |
30 this); | |
31 } | |
32 | |
33 void TrayAudioChromeOs::Update() { | |
34 TrayAudio::Update(); | |
35 | |
36 if (audio_detail_view_) | |
37 audio_detail_view_->Update(); | |
38 } | |
39 | |
40 views::View* TrayAudioChromeOs::CreateDetailedView(LoginStatus status) { | |
41 if (pop_up_volume_view_) { | |
42 volume_view_ = new tray::VolumeView(this, audio_delegate_.get(), false); | |
43 return volume_view_; | |
44 } else { | |
45 WmShell::Get()->RecordUserMetricsAction( | |
46 UMA_STATUS_AREA_DETAILED_AUDIO_VIEW); | |
47 audio_detail_view_ = new tray::AudioDetailedView(this); | |
48 return audio_detail_view_; | |
49 } | |
50 } | |
51 | |
52 void TrayAudioChromeOs::DestroyDetailedView() { | |
53 if (audio_detail_view_) { | |
54 audio_detail_view_ = NULL; | |
55 } else if (volume_view_) { | |
56 volume_view_ = NULL; | |
57 pop_up_volume_view_ = false; | |
58 } | |
59 } | |
60 | |
61 void TrayAudioChromeOs::OnDisplayAdded(const display::Display& new_display) { | |
62 TrayAudio::OnDisplayAdded(new_display); | |
63 | |
64 // This event will be triggered when the lid of the device is opened to exit | |
65 // the docked mode, we should always start or re-start HDMI re-discovering | |
66 // grace period right after this event. | |
67 audio_delegate_->SetActiveHDMIOutoutRediscoveringIfNecessary(true); | |
68 } | |
69 | |
70 void TrayAudioChromeOs::OnDisplayRemoved(const display::Display& old_display) { | |
71 TrayAudio::OnDisplayRemoved(old_display); | |
72 | |
73 // This event will be triggered when the lid of the device is closed to enter | |
74 // the docked mode, we should always start or re-start HDMI re-discovering | |
75 // grace period right after this event. | |
76 audio_delegate_->SetActiveHDMIOutoutRediscoveringIfNecessary(true); | |
77 } | |
78 | |
79 void TrayAudioChromeOs::OnDisplayMetricsChanged(const display::Display& display, | |
80 uint32_t changed_metrics) { | |
81 // The event could be triggered multiple times during the HDMI display | |
82 // transition, we don't need to restart HDMI re-discovering grace period | |
83 // it is already started earlier. | |
84 audio_delegate_->SetActiveHDMIOutoutRediscoveringIfNecessary(false); | |
85 } | |
86 | |
87 void TrayAudioChromeOs::SuspendDone(const base::TimeDelta& sleep_duration) { | |
88 // This event is triggered when the device resumes after earlier suspension, | |
89 // we should always start or re-start HDMI re-discovering | |
90 // grace period right after this event. | |
91 audio_delegate_->SetActiveHDMIOutoutRediscoveringIfNecessary(true); | |
92 } | |
93 | |
94 } // namespace ash | |
OLD | NEW |