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 "chrome/browser/ui/ash/volume_controller_chromeos.h" | 5 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/chromeos/audio/audio_handler.h" | 8 #include "chrome/browser/chromeos/audio/audio_handler.h" |
9 #include "chrome/browser/extensions/system/system_api.h" | 9 #include "chrome/browser/extensions/system/system_api.h" |
10 #include "content/public/browser/user_metrics.h" | 10 #include "content/public/browser/user_metrics.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 audio_handler->AdjustVolumeByPercent(kStepPercentage); | 60 audio_handler->AdjustVolumeByPercent(kStepPercentage); |
61 } else { | 61 } else { |
62 audio_handler->AdjustVolumeByPercent(kStepPercentage); | 62 audio_handler->AdjustVolumeByPercent(kStepPercentage); |
63 } | 63 } |
64 | 64 |
65 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), | 65 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), |
66 audio_handler->IsMuted()); | 66 audio_handler->IsMuted()); |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
| 70 bool VolumeController::IsAudioMuted() const { |
| 71 return chromeos::AudioHandler::GetInstance()->IsMuted(); |
| 72 } |
| 73 |
| 74 void VolumeController::SetAudioMuted(bool muted) { |
| 75 chromeos::AudioHandler::GetInstance()->SetMuted(muted); |
| 76 } |
| 77 |
| 78 // Gets the volume level. The range is [0, 1.0]. |
| 79 float VolumeController::GetVolumeLevel() const { |
| 80 return chromeos::AudioHandler::GetInstance()->GetVolumePercent() / 100.f; |
| 81 } |
| 82 |
| 83 // Sets the volume level. The range is [0, 1.0]. |
| 84 void VolumeController::SetVolumeLevel(float level) { |
| 85 chromeos::AudioHandler::GetInstance()->SetVolumePercent(level * 100.f); |
| 86 } |
| 87 |
70 void VolumeController::SetVolumePercent(double percent) { | 88 void VolumeController::SetVolumePercent(double percent) { |
71 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); | 89 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); |
72 audio_handler->SetVolumePercent(percent); | 90 audio_handler->SetVolumePercent(percent); |
73 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), | 91 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), |
74 audio_handler->IsMuted()); | 92 audio_handler->IsMuted()); |
75 } | 93 } |
OLD | NEW |