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

Side by Side Diff: ash/common/system/audio/volume_view.cc

Issue 2084533008: mash: Migrate tray audio and deps to common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 6 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/common/system/audio/volume_view.h ('k') | ash/common/system/tray/wm_system_tray_notifier.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/volume_view.h" 5 #include "ash/common/system/audio/volume_view.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/metrics/user_metrics_action.h"
9 #include "ash/common/system/audio/tray_audio.h"
10 #include "ash/common/system/audio/tray_audio_delegate.h"
8 #include "ash/common/system/tray/system_tray_item.h" 11 #include "ash/common/system/tray/system_tray_item.h"
9 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_popup_item_container.h" 13 #include "ash/common/system/tray/tray_popup_item_container.h"
11 #include "ash/shell.h" 14 #include "ash/common/wm_shell.h"
12 #include "ash/system/audio/tray_audio.h"
13 #include "ash/system/audio/tray_audio_delegate.h"
14 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
15 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/image/image_skia_operations.h" 19 #include "ui/gfx/image/image_skia_operations.h"
19 #include "ui/views/background.h" 20 #include "ui/views/background.h"
20 #include "ui/views/border.h" 21 #include "ui/views/border.h"
21 #include "ui/views/controls/button/image_button.h" 22 #include "ui/views/controls/button/image_button.h"
22 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
23 #include "ui/views/controls/separator.h" 24 #include "ui/views/controls/separator.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 float value, 246 float value,
246 float old_value, 247 float old_value,
247 views::SliderChangeReason reason) { 248 views::SliderChangeReason reason) {
248 if (reason == views::VALUE_CHANGED_BY_USER) { 249 if (reason == views::VALUE_CHANGED_BY_USER) {
249 float new_volume = value * 100.0f; 250 float new_volume = value * 100.0f;
250 float current_volume = audio_delegate_->GetOutputVolumeLevel(); 251 float current_volume = audio_delegate_->GetOutputVolumeLevel();
251 // Do not call change audio volume if the difference is less than 252 // Do not call change audio volume if the difference is less than
252 // 1%, which is beyond cras audio api's granularity for output volume. 253 // 1%, which is beyond cras audio api's granularity for output volume.
253 if (std::abs(new_volume - current_volume) < 1.0f) 254 if (std::abs(new_volume - current_volume) < 1.0f)
254 return; 255 return;
255 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 256 WmShell::Get()->RecordUserMetricsAction(
256 is_default_view_ ? 257 is_default_view_ ? UMA_STATUS_AREA_CHANGED_VOLUME_MENU
257 ash::UMA_STATUS_AREA_CHANGED_VOLUME_MENU : 258 : UMA_STATUS_AREA_CHANGED_VOLUME_POPUP);
258 ash::UMA_STATUS_AREA_CHANGED_VOLUME_POPUP);
259 if (new_volume > current_volume) 259 if (new_volume > current_volume)
260 HandleVolumeUp(new_volume); 260 HandleVolumeUp(new_volume);
261 else 261 else
262 HandleVolumeDown(new_volume); 262 HandleVolumeDown(new_volume);
263 } 263 }
264 icon_->Update(); 264 icon_->Update();
265 } 265 }
266 266
267 bool VolumeView::PerformAction(const ui::Event& event) { 267 bool VolumeView::PerformAction(const ui::Event& event) {
268 if (!more_region_->visible()) 268 if (!more_region_->visible())
269 return false; 269 return false;
270 owner_->TransitionDetailedView(); 270 owner_->TransitionDetailedView();
271 return true; 271 return true;
272 } 272 }
273 273
274 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 274 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
275 // Separator's prefered size is based on set bounds. When an empty bounds is 275 // Separator's prefered size is based on set bounds. When an empty bounds is
276 // set on first layout this causes BoxLayout to ignore the separator. Reset 276 // set on first layout this causes BoxLayout to ignore the separator. Reset
277 // its height on each bounds change so that it is laid out properly. 277 // its height on each bounds change so that it is laid out properly.
278 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); 278 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height()));
279 } 279 }
280 280
281 void VolumeView::GetAccessibleState(ui::AXViewState* state) { 281 void VolumeView::GetAccessibleState(ui::AXViewState* state) {
282 // Intentionally overrides ActionableView, leaving |state| unset. A slider 282 // Intentionally overrides ActionableView, leaving |state| unset. A slider
283 // childview exposes accessibility data. 283 // childview exposes accessibility data.
284 } 284 }
285 285
286 } // namespace tray 286 } // namespace tray
287 } // namespace ash 287 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/audio/volume_view.h ('k') | ash/common/system/tray/wm_system_tray_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698