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/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 "ui/views/view.h"
13
14namespace ash {
15
16using system::TrayAudioDelegate;
17using system::TrayAudioDelegateChromeOs;
18
19TrayAudioChromeOs::TrayAudioChromeOs(SystemTray* system_tray)
20    : TrayAudio(system_tray,
21                scoped_ptr<TrayAudioDelegate>(new TrayAudioDelegateChromeOs())),
22      audio_detail_view_(NULL) {
23}
24
25TrayAudioChromeOs::~TrayAudioChromeOs() {
26}
27
28void TrayAudioChromeOs::Update() {
29  TrayAudio::Update();
30
31  if (audio_detail_view_)
32    audio_detail_view_->Update();
33}
34
35views::View* TrayAudioChromeOs::CreateDetailedView(user::LoginStatus status) {
36  if (pop_up_volume_view_) {
37    volume_view_ = new tray::VolumeView(this, audio_delegate_.get(), false);
38    return volume_view_;
39  } else {
40    Shell::GetInstance()->metrics()->RecordUserMetricsAction(
41        ash::UMA_STATUS_AREA_DETAILED_AUDIO_VIEW);
42    audio_detail_view_ =
43        new tray::AudioDetailedView(this, status);
44    return audio_detail_view_;
45  }
46}
47
48void TrayAudioChromeOs::DestroyDetailedView() {
49  if (audio_detail_view_) {
50    audio_detail_view_ = NULL;
51  } else if (volume_view_) {
52    volume_view_ = NULL;
53    pop_up_volume_view_ = false;
54  }
55}
56
57}  // namespace ash
58