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

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

Issue 2300353002: Revert of Make TrayDetailsView a ViewClickListener and ButtonListener (Closed)
Patch Set: 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
101 void AudioDetailedView::CreateItems() { 105 void AudioDetailedView::CreateItems() {
102 CreateScrollableList(); 106 CreateScrollableList();
103 CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO); 107 CreateHeaderEntry();
104 } 108 }
105 109
106 void AudioDetailedView::UpdateAudioDevices() { 110 void AudioDetailedView::UpdateAudioDevices() {
107 output_devices_.clear(); 111 output_devices_.clear();
108 input_devices_.clear(); 112 input_devices_.clear();
109 chromeos::AudioDeviceList devices; 113 chromeos::AudioDeviceList devices;
110 CrasAudioHandler::Get()->GetAudioDevices(&devices); 114 CrasAudioHandler::Get()->GetAudioDevices(&devices);
111 for (size_t i = 0; i < devices.size(); ++i) { 115 for (size_t i = 0; i < devices.size(); ++i) {
112 // Don't display keyboard mic or aokr type. 116 // Don't display keyboard mic or aokr type.
113 if (!devices[i].is_for_simple_usage()) 117 if (!devices[i].is_for_simple_usage())
(...skipping 29 matching lines...) Expand all
143 HoverHighlightView* container = AddScrollListItem( 147 HoverHighlightView* container = AddScrollListItem(
144 GetAudioDeviceName(input_devices_[i]), false /* highlight */, 148 GetAudioDeviceName(input_devices_[i]), false /* highlight */,
145 input_devices_[i].active); /* checkmark if active */ 149 input_devices_[i].active); /* checkmark if active */
146 device_map_[container] = input_devices_[i]; 150 device_map_[container] = input_devices_[i];
147 } 151 }
148 152
149 scroll_content()->SizeToPreferredSize(); 153 scroll_content()->SizeToPreferredSize();
150 scroller()->Layout(); 154 scroller()->Layout();
151 } 155 }
152 156
153 void AudioDetailedView::HandleViewClicked(views::View* view) { 157 void AudioDetailedView::OnViewClicked(views::View* sender) {
154 AudioDeviceMap::iterator iter = device_map_.find(view); 158 if (sender == footer()->content()) {
155 if (iter == device_map_.end()) 159 TransitionToDefaultView();
156 return; 160 } else {
157 chromeos::AudioDevice device = iter->second; 161 AudioDeviceMap::iterator iter = device_map_.find(sender);
158 CrasAudioHandler::Get()->SwitchToDevice(device, true, 162 if (iter == device_map_.end())
159 CrasAudioHandler::ACTIVATE_BY_USER); 163 return;
164 chromeos::AudioDevice device = iter->second;
165 CrasAudioHandler::Get()->SwitchToDevice(device, true,
166 CrasAudioHandler::ACTIVATE_BY_USER);
167 }
160 } 168 }
161 169
162 } // namespace tray 170 } // namespace tray
163 } // namespace ash 171 } // 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