| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/audio/tray_audio.h" | 5 #include "ash/system/chromeos/audio/tray_audio.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const int kExtraPaddingBetweenBarAndMore = 10; | 50 const int kExtraPaddingBetweenBarAndMore = 10; |
| 51 | 51 |
| 52 const int kNoAudioDeviceIcon = -1; | 52 const int kNoAudioDeviceIcon = -1; |
| 53 | 53 |
| 54 // IDR_AURA_UBER_TRAY_VOLUME_LEVELS contains 5 images, | 54 // IDR_AURA_UBER_TRAY_VOLUME_LEVELS contains 5 images, |
| 55 // The one for mute is at the 0 index and the other | 55 // The one for mute is at the 0 index and the other |
| 56 // four are used for ascending volume levels. | 56 // four are used for ascending volume levels. |
| 57 const int kVolumeLevels = 4; | 57 const int kVolumeLevels = 4; |
| 58 | 58 |
| 59 bool UseNewAudioHandler() { | 59 bool UseNewAudioHandler() { |
| 60 return CommandLine::ForCurrentProcess()-> | 60 return !CommandLine::ForCurrentProcess()-> |
| 61 HasSwitch(ash::switches::kAshEnableNewAudioHandler); | 61 HasSwitch(ash::switches::kAshDisableNewAudioHandler); |
| 62 } |
| 63 |
| 64 // Returns true if we should show the audio device switching UI. |
| 65 bool ShowAudioDeviceMenu() { |
| 66 return UseNewAudioHandler() && |
| 67 CommandLine::ForCurrentProcess()-> |
| 68 HasSwitch(ash::switches::kAshEnableAudioDeviceMenu); |
| 62 } | 69 } |
| 63 | 70 |
| 64 bool IsAudioMuted() { | 71 bool IsAudioMuted() { |
| 65 if(UseNewAudioHandler()) { | 72 if(UseNewAudioHandler()) { |
| 66 return chromeos::CrasAudioHandler::Get()->IsOutputMuted(); | 73 return chromeos::CrasAudioHandler::Get()->IsOutputMuted(); |
| 67 } else { | 74 } else { |
| 68 return Shell::GetInstance()->system_tray_delegate()-> | 75 return Shell::GetInstance()->system_tray_delegate()-> |
| 69 GetVolumeControlDelegate()->IsAudioMuted(); | 76 GetVolumeControlDelegate()->IsAudioMuted(); |
| 70 } | 77 } |
| 71 } | 78 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // It is possible that the volume was (un)muted, but the actual volume level | 241 // It is possible that the volume was (un)muted, but the actual volume level |
| 235 // did not change. In that case, setting the value of the slider won't | 242 // did not change. In that case, setting the value of the slider won't |
| 236 // trigger an update. So explicitly trigger an update. | 243 // trigger an update. So explicitly trigger an update. |
| 237 Update(); | 244 Update(); |
| 238 slider_->set_enable_accessibility_events(true); | 245 slider_->set_enable_accessibility_events(true); |
| 239 } | 246 } |
| 240 | 247 |
| 241 private: | 248 private: |
| 242 // Updates bar_, device_type_ icon, and more_ buttons. | 249 // Updates bar_, device_type_ icon, and more_ buttons. |
| 243 void UpdateDeviceTypeAndMore() { | 250 void UpdateDeviceTypeAndMore() { |
| 244 if (!UseNewAudioHandler() || !is_default_view_) { | 251 if (!ShowAudioDeviceMenu() || !is_default_view_) { |
| 245 more_->SetVisible(false); | 252 more_->SetVisible(false); |
| 246 bar_->SetVisible(false); | 253 bar_->SetVisible(false); |
| 247 device_type_->SetVisible(false); | 254 device_type_->SetVisible(false); |
| 248 return; | 255 return; |
| 249 } | 256 } |
| 250 | 257 |
| 251 chromeos::CrasAudioHandler* audio_handler = | 258 chromeos::CrasAudioHandler* audio_handler = |
| 252 chromeos::CrasAudioHandler::Get(); | 259 chromeos::CrasAudioHandler::Get(); |
| 253 bool show_more = audio_handler->has_alternative_output() || | 260 bool show_more = audio_handler->has_alternative_output() || |
| 254 audio_handler->has_alternative_input(); | 261 audio_handler->has_alternative_input(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 bool TrayAudio::GetInitialVisibility() { | 504 bool TrayAudio::GetInitialVisibility() { |
| 498 return IsAudioMuted(); | 505 return IsAudioMuted(); |
| 499 } | 506 } |
| 500 | 507 |
| 501 views::View* TrayAudio::CreateDefaultView(user::LoginStatus status) { | 508 views::View* TrayAudio::CreateDefaultView(user::LoginStatus status) { |
| 502 volume_view_ = new tray::VolumeView(this, true); | 509 volume_view_ = new tray::VolumeView(this, true); |
| 503 return volume_view_; | 510 return volume_view_; |
| 504 } | 511 } |
| 505 | 512 |
| 506 views::View* TrayAudio::CreateDetailedView(user::LoginStatus status) { | 513 views::View* TrayAudio::CreateDetailedView(user::LoginStatus status) { |
| 507 if (!UseNewAudioHandler() || pop_up_volume_view_) { | 514 if (!ShowAudioDeviceMenu() || pop_up_volume_view_) { |
| 508 volume_view_ = new tray::VolumeView(this, false); | 515 volume_view_ = new tray::VolumeView(this, false); |
| 509 return volume_view_; | 516 return volume_view_; |
| 510 } else { | 517 } else { |
| 511 audio_detail_ = new tray::AudioDetailedView(this, status); | 518 audio_detail_ = new tray::AudioDetailedView(this, status); |
| 512 return audio_detail_; | 519 return audio_detail_; |
| 513 } | 520 } |
| 514 } | 521 } |
| 515 | 522 |
| 516 void TrayAudio::DestroyDefaultView() { | 523 void TrayAudio::DestroyDefaultView() { |
| 517 volume_view_ = NULL; | 524 volume_view_ = NULL; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 610 |
| 604 void TrayAudio::Update() { | 611 void TrayAudio::Update() { |
| 605 if (audio_detail_) | 612 if (audio_detail_) |
| 606 audio_detail_->Update(); | 613 audio_detail_->Update(); |
| 607 if (volume_view_) | 614 if (volume_view_) |
| 608 volume_view_->Update(); | 615 volume_view_->Update(); |
| 609 } | 616 } |
| 610 | 617 |
| 611 } // namespace internal | 618 } // namespace internal |
| 612 } // namespace ash | 619 } // namespace ash |
| OLD | NEW |