| 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/common/system/chromeos/audio/audio_detailed_view.h" | 5 #include "ash/common/system/chromeos/audio/audio_detailed_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 8 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 9 #include "ash/common/system/tray/hover_highlight_view.h" | 9 #include "ash/common/system/tray/hover_highlight_view.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/system/tray/tray_popup_utils.h" | 11 #include "ash/common/system/tray/tray_popup_utils.h" |
| 12 #include "ash/common/system/tray/tri_view.h" | 12 #include "ash/common/system/tray/tri_view.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chromeos/audio/cras_audio_handler.h" | 14 #include "chromeos/audio/cras_audio_handler.h" |
| 15 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/color_palette.h" | 18 #include "ui/gfx/color_palette.h" |
| 19 #include "ui/gfx/paint_vector_icon.h" | 19 #include "ui/gfx/paint_vector_icon.h" |
| 20 #include "ui/gfx/vector_icons_public.h" | 20 #include "ui/gfx/vector_icons_public.h" |
| 21 #include "ui/native_theme/native_theme.h" |
| 21 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| 22 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
| 23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 24 #include "ui/views/controls/separator.h" | 25 #include "ui/views/controls/separator.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 base::string16 GetAudioDeviceName(const chromeos::AudioDevice& device) { | 29 base::string16 GetAudioDeviceName(const chromeos::AudioDevice& device) { |
| 29 switch (device.type) { | 30 switch (device.type) { |
| 30 case chromeos::AUDIO_TYPE_FRONT_MIC: | 31 case chromeos::AUDIO_TYPE_FRONT_MIC: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 void AudioDetailedView::AddOutputHeader() { | 85 void AudioDetailedView::AddOutputHeader() { |
| 85 AddScrollListInfoItem(IDS_ASH_STATUS_TRAY_AUDIO_OUTPUT, | 86 AddScrollListInfoItem(IDS_ASH_STATUS_TRAY_AUDIO_OUTPUT, |
| 86 kSystemMenuAudioOutputIcon); | 87 kSystemMenuAudioOutputIcon); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void AudioDetailedView::AddScrollListInfoItem(int text_id, | 90 void AudioDetailedView::AddScrollListInfoItem(int text_id, |
| 90 const gfx::VectorIcon& icon) { | 91 const gfx::VectorIcon& icon) { |
| 91 const base::string16 text = l10n_util::GetStringUTF16(text_id); | 92 const base::string16 text = l10n_util::GetStringUTF16(text_id); |
| 92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 93 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 93 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); | |
| 94 TriView* header = TrayPopupUtils::CreateDefaultRowView(); | 94 TriView* header = TrayPopupUtils::CreateDefaultRowView(); |
| 95 TrayPopupUtils::ConfigureAsStickyHeader(header); | 95 TrayPopupUtils::ConfigureAsStickyHeader(header); |
| 96 views::ImageView* image_view = TrayPopupUtils::CreateMainImageView(); | 96 views::ImageView* image_view = TrayPopupUtils::CreateMainImageView(); |
| 97 image_view->SetImage(gfx::CreateVectorIcon(icon, style.GetIconColor())); | 97 image_view->SetImage(gfx::CreateVectorIcon( |
| 98 icon, GetNativeTheme()->GetSystemColor( |
| 99 ui::NativeTheme::kColorId_ProminentButtonColor))); |
| 98 header->AddView(TriView::Container::START, image_view); | 100 header->AddView(TriView::Container::START, image_view); |
| 99 | 101 |
| 100 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 102 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| 101 label->SetText(text); | 103 label->SetText(text); |
| 104 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); |
| 102 style.SetupLabel(label); | 105 style.SetupLabel(label); |
| 103 header->AddView(TriView::Container::CENTER, label); | 106 header->AddView(TriView::Container::CENTER, label); |
| 104 | 107 |
| 105 header->SetContainerVisible(TriView::Container::END, false); | 108 header->SetContainerVisible(TriView::Container::END, false); |
| 106 scroll_content()->AddChildView(header); | 109 scroll_content()->AddChildView(header); |
| 107 } else { | 110 } else { |
| 108 views::Label* label = new views::Label( | 111 views::Label* label = new views::Label( |
| 109 text, ui::ResourceBundle::GetSharedInstance().GetFontList( | 112 text, ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 110 ui::ResourceBundle::BoldFont)); | 113 ui::ResourceBundle::BoldFont)); |
| 111 | 114 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 AudioDeviceMap::iterator iter = device_map_.find(view); | 224 AudioDeviceMap::iterator iter = device_map_.find(view); |
| 222 if (iter == device_map_.end()) | 225 if (iter == device_map_.end()) |
| 223 return; | 226 return; |
| 224 chromeos::AudioDevice device = iter->second; | 227 chromeos::AudioDevice device = iter->second; |
| 225 CrasAudioHandler::Get()->SwitchToDevice(device, true, | 228 CrasAudioHandler::Get()->SwitchToDevice(device, true, |
| 226 CrasAudioHandler::ACTIVATE_BY_USER); | 229 CrasAudioHandler::ACTIVATE_BY_USER); |
| 227 } | 230 } |
| 228 | 231 |
| 229 } // namespace tray | 232 } // namespace tray |
| 230 } // namespace ash | 233 } // namespace ash |
| OLD | NEW |