Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: ash/common/system/chromeos/audio/audio_detailed_view.cc

Issue 2289223002: Make TrayDetailsView a ViewClickListener and ButtonListener (Closed)
Patch Set: fix test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 HoverHighlightView* AudioDetailedView::AddScrollListItem( 91 HoverHighlightView* AudioDetailedView::AddScrollListItem(
92 const base::string16& text, 92 const base::string16& text,
93 bool highlight, 93 bool highlight,
94 bool checked) { 94 bool checked) {
95 HoverHighlightView* container = new HoverHighlightView(this); 95 HoverHighlightView* container = new HoverHighlightView(this);
96 container->AddCheckableLabel(text, highlight, checked); 96 container->AddCheckableLabel(text, highlight, checked);
97 scroll_content()->AddChildView(container); 97 scroll_content()->AddChildView(container);
98 return container; 98 return container;
99 } 99 }
100 100
101 void AudioDetailedView::CreateHeaderEntry() {
102 CreateSpecialRow(IDS_ASH_STATUS_TRAY_AUDIO, this);
103 }
104
105 void AudioDetailedView::CreateItems() { 101 void AudioDetailedView::CreateItems() {
106 CreateScrollableList(); 102 CreateScrollableList();
107 CreateHeaderEntry(); 103 CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO);
108 } 104 }
109 105
110 void AudioDetailedView::UpdateAudioDevices() { 106 void AudioDetailedView::UpdateAudioDevices() {
111 output_devices_.clear(); 107 output_devices_.clear();
112 input_devices_.clear(); 108 input_devices_.clear();
113 chromeos::AudioDeviceList devices; 109 chromeos::AudioDeviceList devices;
114 CrasAudioHandler::Get()->GetAudioDevices(&devices); 110 CrasAudioHandler::Get()->GetAudioDevices(&devices);
115 for (size_t i = 0; i < devices.size(); ++i) { 111 for (size_t i = 0; i < devices.size(); ++i) {
116 // Don't display keyboard mic or aokr type. 112 // Don't display keyboard mic or aokr type.
117 if (!devices[i].is_for_simple_usage()) 113 if (!devices[i].is_for_simple_usage())
(...skipping 29 matching lines...) Expand all
147 HoverHighlightView* container = AddScrollListItem( 143 HoverHighlightView* container = AddScrollListItem(
148 GetAudioDeviceName(input_devices_[i]), false /* highlight */, 144 GetAudioDeviceName(input_devices_[i]), false /* highlight */,
149 input_devices_[i].active); /* checkmark if active */ 145 input_devices_[i].active); /* checkmark if active */
150 device_map_[container] = input_devices_[i]; 146 device_map_[container] = input_devices_[i];
151 } 147 }
152 148
153 scroll_content()->SizeToPreferredSize(); 149 scroll_content()->SizeToPreferredSize();
154 scroller()->Layout(); 150 scroller()->Layout();
155 } 151 }
156 152
157 void AudioDetailedView::OnViewClicked(views::View* sender) { 153 void AudioDetailedView::HandleViewClicked(views::View* view) {
158 if (sender == footer()->content()) { 154 AudioDeviceMap::iterator iter = device_map_.find(view);
159 TransitionToDefaultView(); 155 if (iter == device_map_.end())
160 } else { 156 return;
161 AudioDeviceMap::iterator iter = device_map_.find(sender); 157 chromeos::AudioDevice device = iter->second;
162 if (iter == device_map_.end()) 158 CrasAudioHandler::Get()->SwitchToDevice(device, true,
163 return; 159 CrasAudioHandler::ACTIVATE_BY_USER);
164 chromeos::AudioDevice device = iter->second;
165 CrasAudioHandler::Get()->SwitchToDevice(device, true,
166 CrasAudioHandler::ACTIVATE_BY_USER);
167 }
168 } 160 }
169 161
170 } // namespace tray 162 } // namespace tray
171 } // namespace ash 163 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/audio/audio_detailed_view.h ('k') | ash/common/system/chromeos/bluetooth/tray_bluetooth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698