4f39865c0dee9196534beee138834dd3877439cd
[platform/framework/web/crosswalk.git] / src / ash / system / chromeos / audio / tray_audio_delegate_chromeos.cc
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_delegate_chromeos.h"
6
7 #include "chromeos/audio/cras_audio_handler.h"
8 #include "grit/ash_resources.h"
9
10 using chromeos::CrasAudioHandler;
11
12 namespace ash  {
13 namespace system {
14
15 void TrayAudioDelegateChromeOs::AdjustOutputVolumeToAudibleLevel() {
16   CrasAudioHandler::Get()->AdjustOutputVolumeToAudibleLevel();
17 }
18
19 int TrayAudioDelegateChromeOs::GetOutputDefaultVolumeMuteLevel() {
20   return CrasAudioHandler::Get()->GetOutputDefaultVolumeMuteThreshold();
21 }
22
23 int TrayAudioDelegateChromeOs::GetOutputVolumeLevel() {
24   return CrasAudioHandler::Get()->GetOutputVolumePercent();
25 }
26
27 int TrayAudioDelegateChromeOs::GetActiveOutputDeviceIconId() {
28   chromeos::AudioDevice device;
29   if (!CrasAudioHandler::Get()->GetPrimaryActiveOutputDevice(&device))
30     return kNoAudioDeviceIcon;
31
32   if (device.type == chromeos::AUDIO_TYPE_HEADPHONE)
33     return IDR_AURA_UBER_TRAY_AUDIO_HEADPHONE;
34   else if (device.type == chromeos::AUDIO_TYPE_USB)
35     return IDR_AURA_UBER_TRAY_AUDIO_USB;
36   else if (device.type == chromeos::AUDIO_TYPE_BLUETOOTH)
37     return IDR_AURA_UBER_TRAY_AUDIO_BLUETOOTH;
38   else if (device.type == chromeos::AUDIO_TYPE_HDMI)
39     return IDR_AURA_UBER_TRAY_AUDIO_HDMI;
40   else
41     return kNoAudioDeviceIcon;
42 }
43
44
45 bool TrayAudioDelegateChromeOs::HasAlternativeSources() {
46   CrasAudioHandler* audio_handler = CrasAudioHandler::Get();
47   return (audio_handler->has_alternative_output() ||
48           audio_handler->has_alternative_input());
49 }
50
51 bool TrayAudioDelegateChromeOs::IsOutputAudioMuted() {
52   return CrasAudioHandler::Get()->IsOutputMuted();
53 }
54
55 void TrayAudioDelegateChromeOs::SetOutputAudioIsMuted(bool is_muted) {
56   CrasAudioHandler::Get()->SetOutputMute(is_muted);
57 }
58
59 void TrayAudioDelegateChromeOs::SetOutputVolumeLevel(int level) {
60   CrasAudioHandler::Get()->SetOutputVolumePercent(level);
61 }
62
63 }  // namespace system
64 }  // namespace ash