| 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 #include "ash/system/chromeos/audio/audio_detailed_view.h" | 5 #include "ash/system/chromeos/audio/audio_detailed_view.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 7 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 8 #include "ash/common/system/tray/hover_highlight_view.h" | 8 #include "ash/common/system/tray/hover_highlight_view.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chromeos/audio/cras_audio_handler.h" | 11 #include "chromeos/audio/cras_audio_handler.h" |
| 12 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 base::string16 GetAudioDeviceName(const chromeos::AudioDevice& device) { | 20 base::string16 GetAudioDeviceName(const chromeos::AudioDevice& device) { |
| 21 switch (device.type) { | 21 switch (device.type) { |
| 22 case chromeos::AUDIO_TYPE_HEADPHONE: | 22 case chromeos::AUDIO_TYPE_HEADPHONE: |
| 23 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO_HEADPHONE); | 23 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO_HEADPHONE); |
| 24 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: | 24 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: |
| 25 return l10n_util::GetStringUTF16( | 25 return l10n_util::GetStringUTF16( |
| 26 IDS_ASH_STATUS_TRAY_AUDIO_INTERNAL_SPEAKER); | 26 IDS_ASH_STATUS_TRAY_AUDIO_INTERNAL_SPEAKER); |
| 27 case chromeos::AUDIO_TYPE_INTERNAL_MIC: | 27 case chromeos::AUDIO_TYPE_INTERNAL_MIC: |
| 28 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO_INTERNAL_MIC); | 28 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO_INTERNAL_MIC); |
| 29 case chromeos::AUDIO_TYPE_USB: | 29 case chromeos::AUDIO_TYPE_USB: |
| 30 return l10n_util::GetStringFUTF16( | 30 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_AUDIO_USB_DEVICE, |
| 31 IDS_ASH_STATUS_TRAY_AUDIO_USB_DEVICE, | 31 base::UTF8ToUTF16(device.display_name)); |
| 32 base::UTF8ToUTF16(device.display_name)); | |
| 33 case chromeos::AUDIO_TYPE_BLUETOOTH: | 32 case chromeos::AUDIO_TYPE_BLUETOOTH: |
| 34 return l10n_util::GetStringFUTF16( | 33 return l10n_util::GetStringFUTF16( |
| 35 IDS_ASH_STATUS_TRAY_AUDIO_BLUETOOTH_DEVICE, | 34 IDS_ASH_STATUS_TRAY_AUDIO_BLUETOOTH_DEVICE, |
| 36 base::UTF8ToUTF16(device.display_name)); | 35 base::UTF8ToUTF16(device.display_name)); |
| 37 case chromeos::AUDIO_TYPE_HDMI: | 36 case chromeos::AUDIO_TYPE_HDMI: |
| 38 return l10n_util::GetStringFUTF16( | 37 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_AUDIO_HDMI_DEVICE, |
| 39 IDS_ASH_STATUS_TRAY_AUDIO_HDMI_DEVICE, | 38 base::UTF8ToUTF16(device.display_name)); |
| 40 base::UTF8ToUTF16(device.display_name)); | |
| 41 case chromeos::AUDIO_TYPE_MIC: | 39 case chromeos::AUDIO_TYPE_MIC: |
| 42 return l10n_util::GetStringUTF16( | 40 return l10n_util::GetStringUTF16( |
| 43 IDS_ASH_STATUS_TRAY_AUDIO_MIC_JACK_DEVICE); | 41 IDS_ASH_STATUS_TRAY_AUDIO_MIC_JACK_DEVICE); |
| 44 default: | 42 default: |
| 45 return base::UTF8ToUTF16(device.display_name); | 43 return base::UTF8ToUTF16(device.display_name); |
| 46 } | 44 } |
| 47 } | 45 } |
| 48 | 46 |
| 49 } // namespace | 47 } // namespace |
| 50 | 48 |
| 51 using chromeos::CrasAudioHandler; | 49 using chromeos::CrasAudioHandler; |
| 52 | 50 |
| 53 namespace ash { | 51 namespace ash { |
| 54 namespace tray { | 52 namespace tray { |
| 55 | 53 |
| 56 AudioDetailedView::AudioDetailedView(SystemTrayItem* owner) | 54 AudioDetailedView::AudioDetailedView(SystemTrayItem* owner) |
| 57 : TrayDetailsView(owner) { | 55 : TrayDetailsView(owner) { |
| 58 CreateItems(); | 56 CreateItems(); |
| 59 Update(); | 57 Update(); |
| 60 } | 58 } |
| 61 | 59 |
| 62 AudioDetailedView::~AudioDetailedView() { | 60 AudioDetailedView::~AudioDetailedView() {} |
| 63 } | |
| 64 | 61 |
| 65 void AudioDetailedView::Update() { | 62 void AudioDetailedView::Update() { |
| 66 UpdateAudioDevices(); | 63 UpdateAudioDevices(); |
| 67 Layout(); | 64 Layout(); |
| 68 } | 65 } |
| 69 | 66 |
| 70 void AudioDetailedView::AddScrollListInfoItem(const base::string16& text) { | 67 void AudioDetailedView::AddScrollListInfoItem(const base::string16& text) { |
| 71 views::Label* label = new views::Label( | 68 views::Label* label = new views::Label( |
| 72 text, | 69 text, ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 73 ui::ResourceBundle::GetSharedInstance().GetFontList( | 70 ui::ResourceBundle::BoldFont)); |
| 74 ui::ResourceBundle::BoldFont)); | |
| 75 | 71 |
| 76 // Align info item with checkbox items | 72 // Align info item with checkbox items |
| 77 int margin = kTrayPopupPaddingHorizontal + | 73 int margin = |
| 78 kTrayPopupDetailsLabelExtraLeftMargin; | 74 kTrayPopupPaddingHorizontal + kTrayPopupDetailsLabelExtraLeftMargin; |
| 79 int left_margin = 0; | 75 int left_margin = 0; |
| 80 int right_margin = 0; | 76 int right_margin = 0; |
| 81 if (base::i18n::IsRTL()) | 77 if (base::i18n::IsRTL()) |
| 82 right_margin = margin; | 78 right_margin = margin; |
| 83 else | 79 else |
| 84 left_margin = margin; | 80 left_margin = margin; |
| 85 | 81 |
| 86 label->SetBorder(views::Border::CreateEmptyBorder( | 82 label->SetBorder(views::Border::CreateEmptyBorder( |
| 87 ash::kTrayPopupPaddingBetweenItems, | 83 ash::kTrayPopupPaddingBetweenItems, left_margin, |
| 88 left_margin, | 84 ash::kTrayPopupPaddingBetweenItems, right_margin)); |
| 89 ash::kTrayPopupPaddingBetweenItems, | |
| 90 right_margin)); | |
| 91 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 85 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 92 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0)); | 86 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0)); |
| 93 | 87 |
| 94 scroll_content()->AddChildView(label); | 88 scroll_content()->AddChildView(label); |
| 95 } | 89 } |
| 96 | 90 |
| 97 HoverHighlightView* AudioDetailedView::AddScrollListItem( | 91 HoverHighlightView* AudioDetailedView::AddScrollListItem( |
| 98 const base::string16& text, | 92 const base::string16& text, |
| 99 bool highlight, | 93 bool highlight, |
| 100 bool checked) { | 94 bool checked) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (iter == device_map_.end()) | 162 if (iter == device_map_.end()) |
| 169 return; | 163 return; |
| 170 chromeos::AudioDevice device = iter->second; | 164 chromeos::AudioDevice device = iter->second; |
| 171 CrasAudioHandler::Get()->SwitchToDevice(device, true, | 165 CrasAudioHandler::Get()->SwitchToDevice(device, true, |
| 172 CrasAudioHandler::ACTIVATE_BY_USER); | 166 CrasAudioHandler::ACTIVATE_BY_USER); |
| 173 } | 167 } |
| 174 } | 168 } |
| 175 | 169 |
| 176 } // namespace tray | 170 } // namespace tray |
| 177 } // namespace ash | 171 } // namespace ash |
| OLD | NEW |