Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ash / system / chromeos / audio / tray_audio_chromeos.cc
blob3d420ff6e655efc91d6ca93beb48897909439fb8
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.
5 #include "ash/system/chromeos/audio/tray_audio_chromeos.h"
7 #include "ash/metrics/user_metrics_recorder.h"
8 #include "ash/shell.h"
9 #include "ash/system/audio/volume_view.h"
10 #include "ash/system/chromeos/audio/audio_detailed_view.h"
11 #include "ash/system/chromeos/audio/tray_audio_delegate_chromeos.h"
12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "ui/views/view.h"
15 namespace ash {
17 using system::TrayAudioDelegate;
18 using system::TrayAudioDelegateChromeOs;
20 TrayAudioChromeOs::TrayAudioChromeOs(SystemTray* system_tray)
21 : TrayAudio(system_tray,
22 scoped_ptr<TrayAudioDelegate>(new TrayAudioDelegateChromeOs())),
23 audio_detail_view_(NULL) {
24 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
25 this);
28 TrayAudioChromeOs::~TrayAudioChromeOs() {
29 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
30 this);
33 void TrayAudioChromeOs::Update() {
34 TrayAudio::Update();
36 if (audio_detail_view_)
37 audio_detail_view_->Update();
40 views::View* TrayAudioChromeOs::CreateDetailedView(user::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 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
46 ash::UMA_STATUS_AREA_DETAILED_AUDIO_VIEW);
47 audio_detail_view_ = new tray::AudioDetailedView(this);
48 return audio_detail_view_;
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;
61 void TrayAudioChromeOs::OnDisplayAdded(const gfx::Display& new_display) {
62 TrayAudio::OnDisplayAdded(new_display);
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);
70 void TrayAudioChromeOs::OnDisplayRemoved(const gfx::Display& old_display) {
71 TrayAudio::OnDisplayRemoved(old_display);
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);
79 void TrayAudioChromeOs::OnDisplayMetricsChanged(const gfx::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);
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);
94 } // namespace ash