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

Side by Side Diff: ash/system/audio/tray_audio.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « ash/system/audio/tray_audio.h ('k') | ash/system/chromeos/audio/tray_audio_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/audio/tray_audio.h" 5 #include "ash/system/audio/tray_audio.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
11 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
12 #include "ash/metrics/user_metrics_recorder.h" 12 #include "ash/metrics/user_metrics_recorder.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/system/audio/tray_audio_delegate.h" 14 #include "ash/system/audio/tray_audio_delegate.h"
15 #include "ash/system/audio/volume_view.h" 15 #include "ash/system/audio/volume_view.h"
16 #include "ash/system/tray/actionable_view.h" 16 #include "ash/system/tray/actionable_view.h"
17 #include "ash/system/tray/fixed_sized_scroll_view.h" 17 #include "ash/system/tray/fixed_sized_scroll_view.h"
18 #include "ash/system/tray/hover_highlight_view.h" 18 #include "ash/system/tray/hover_highlight_view.h"
19 #include "ash/system/tray/system_tray.h" 19 #include "ash/system/tray/system_tray.h"
20 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
21 #include "ash/system/tray/system_tray_notifier.h" 21 #include "ash/system/tray/system_tray_notifier.h"
22 #include "ash/system/tray/tray_constants.h" 22 #include "ash/system/tray/tray_constants.h"
23 #include "ash/volume_control_delegate.h" 23 #include "ash/volume_control_delegate.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "grit/ash_resources.h" 25 #include "grit/ash_resources.h"
26 #include "third_party/skia/include/core/SkCanvas.h" 26 #include "third_party/skia/include/core/SkCanvas.h"
27 #include "third_party/skia/include/core/SkPaint.h" 27 #include "third_party/skia/include/core/SkPaint.h"
28 #include "third_party/skia/include/core/SkRect.h" 28 #include "third_party/skia/include/core/SkRect.h"
29 #include "third_party/skia/include/effects/SkGradientShader.h" 29 #include "third_party/skia/include/effects/SkGradientShader.h"
30 #include "ui/display/display.h"
30 #include "ui/gfx/canvas.h" 31 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/display.h"
32 #include "ui/gfx/font_list.h" 32 #include "ui/gfx/font_list.h"
33 #include "ui/gfx/image/image.h" 33 #include "ui/gfx/image/image.h"
34 #include "ui/gfx/image/image_skia_operations.h" 34 #include "ui/gfx/image/image_skia_operations.h"
35 #include "ui/views/controls/button/image_button.h" 35 #include "ui/views/controls/button/image_button.h"
36 #include "ui/views/controls/image_view.h" 36 #include "ui/views/controls/image_view.h"
37 #include "ui/views/controls/label.h" 37 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/slider.h" 38 #include "ui/views/controls/slider.h"
39 #include "ui/views/layout/box_layout.h" 39 #include "ui/views/layout/box_layout.h"
40 #include "ui/views/view.h" 40 #include "ui/views/view.h"
41 41
42 namespace ash { 42 namespace ash {
43 43
44 TrayAudio::TrayAudio(SystemTray* system_tray, 44 TrayAudio::TrayAudio(SystemTray* system_tray,
45 std::unique_ptr<system::TrayAudioDelegate> audio_delegate) 45 std::unique_ptr<system::TrayAudioDelegate> audio_delegate)
46 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE), 46 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_VOLUME_MUTE),
47 audio_delegate_(std::move(audio_delegate)), 47 audio_delegate_(std::move(audio_delegate)),
48 volume_view_(NULL), 48 volume_view_(NULL),
49 pop_up_volume_view_(false) { 49 pop_up_volume_view_(false) {
50 Shell::GetInstance()->system_tray_notifier()->AddAudioObserver(this); 50 Shell::GetInstance()->system_tray_notifier()->AddAudioObserver(this);
51 gfx::Screen::GetScreen()->AddObserver(this); 51 display::Screen::GetScreen()->AddObserver(this);
52 } 52 }
53 53
54 TrayAudio::~TrayAudio() { 54 TrayAudio::~TrayAudio() {
55 gfx::Screen::GetScreen()->RemoveObserver(this); 55 display::Screen::GetScreen()->RemoveObserver(this);
56 Shell::GetInstance()->system_tray_notifier()->RemoveAudioObserver(this); 56 Shell::GetInstance()->system_tray_notifier()->RemoveAudioObserver(this);
57 } 57 }
58 58
59 // static 59 // static
60 bool TrayAudio::ShowAudioDeviceMenu() { 60 bool TrayAudio::ShowAudioDeviceMenu() {
61 #if defined(OS_CHROMEOS) 61 #if defined(OS_CHROMEOS)
62 return true; 62 return true;
63 #else 63 #else
64 return false; 64 return false;
65 #endif 65 #endif
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 void TrayAudio::OnActiveInputNodeChanged() { 138 void TrayAudio::OnActiveInputNodeChanged() {
139 Update(); 139 Update();
140 } 140 }
141 141
142 void TrayAudio::ChangeInternalSpeakerChannelMode() { 142 void TrayAudio::ChangeInternalSpeakerChannelMode() {
143 // Swap left/right channel only if it is in Yoga mode. 143 // Swap left/right channel only if it is in Yoga mode.
144 system::TrayAudioDelegate::AudioChannelMode channel_mode = 144 system::TrayAudioDelegate::AudioChannelMode channel_mode =
145 system::TrayAudioDelegate::NORMAL; 145 system::TrayAudioDelegate::NORMAL;
146 if (gfx::Display::HasInternalDisplay()) { 146 if (display::Display::HasInternalDisplay()) {
147 const DisplayInfo& display_info = 147 const DisplayInfo& display_info =
148 Shell::GetInstance()->display_manager()->GetDisplayInfo( 148 Shell::GetInstance()->display_manager()->GetDisplayInfo(
149 gfx::Display::InternalDisplayId()); 149 display::Display::InternalDisplayId());
150 if (display_info.GetActiveRotation() == gfx::Display::ROTATE_180) 150 if (display_info.GetActiveRotation() == display::Display::ROTATE_180)
151 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED; 151 channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED;
152 } 152 }
153 153
154 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode); 154 audio_delegate_->SetInternalSpeakerChannelMode(channel_mode);
155 } 155 }
156 156
157 void TrayAudio::OnDisplayAdded(const gfx::Display& new_display) { 157 void TrayAudio::OnDisplayAdded(const display::Display& new_display) {
158 if (!new_display.IsInternal()) 158 if (!new_display.IsInternal())
159 return; 159 return;
160 ChangeInternalSpeakerChannelMode(); 160 ChangeInternalSpeakerChannelMode();
161 } 161 }
162 162
163 void TrayAudio::OnDisplayRemoved(const gfx::Display& old_display) { 163 void TrayAudio::OnDisplayRemoved(const display::Display& old_display) {
164 if (!old_display.IsInternal()) 164 if (!old_display.IsInternal())
165 return; 165 return;
166 ChangeInternalSpeakerChannelMode(); 166 ChangeInternalSpeakerChannelMode();
167 } 167 }
168 168
169 void TrayAudio::OnDisplayMetricsChanged(const gfx::Display& display, 169 void TrayAudio::OnDisplayMetricsChanged(const display::Display& display,
170 uint32_t changed_metrics) { 170 uint32_t changed_metrics) {
171 if (!display.IsInternal()) 171 if (!display.IsInternal())
172 return; 172 return;
173 173
174 if (changed_metrics & gfx::DisplayObserver::DISPLAY_METRIC_ROTATION) 174 if (changed_metrics & display::DisplayObserver::DISPLAY_METRIC_ROTATION)
175 ChangeInternalSpeakerChannelMode(); 175 ChangeInternalSpeakerChannelMode();
176 } 176 }
177 177
178 void TrayAudio::Update() { 178 void TrayAudio::Update() {
179 if (tray_view()) 179 if (tray_view())
180 tray_view()->SetVisible(GetInitialVisibility()); 180 tray_view()->SetVisible(GetInitialVisibility());
181 if (volume_view_) { 181 if (volume_view_) {
182 volume_view_->SetVolumeLevel( 182 volume_view_->SetVolumeLevel(
183 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); 183 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f);
184 volume_view_->Update(); 184 volume_view_->Update();
185 } 185 }
186 } 186 }
187 187
188 } // namespace ash 188 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/audio/tray_audio.h ('k') | ash/system/chromeos/audio/tray_audio_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698