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

Side by Side Diff: chrome/browser/ui/ash/volume_controller_chromeos.cc

Issue 10694127: browser: Move some ash files into ui/ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/audio/audio_handler.h"
9 #include "chrome/browser/extensions/system/system_api.h"
10 #include "content/public/browser/user_metrics.h"
11
12 namespace {
13
14 // Percent by which the volume should be changed when a volume key is pressed.
15 const double kStepPercentage = 4.0;
16
17 } // namespace
18
19 bool VolumeController::HandleVolumeMute(const ui::Accelerator& accelerator) {
20 if (accelerator.key_code() == ui::VKEY_F8)
21 content::RecordAction(content::UserMetricsAction("Accel_VolumeMute_F8"));
22
23 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
24
25 // Always muting (and not toggling) as per final decision on
26 // http://crosbug.com/3751
27 audio_handler->SetMuted(true);
28
29 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
30 audio_handler->IsMuted());
31 return true;
32 }
33
34 bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) {
35 if (accelerator.key_code() == ui::VKEY_F9)
36 content::RecordAction(content::UserMetricsAction("Accel_VolumeDown_F9"));
37
38 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
39 if (audio_handler->IsMuted())
40 audio_handler->SetVolumePercent(0.0);
41 else
42 audio_handler->AdjustVolumeByPercent(-kStepPercentage);
43
44 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
45 audio_handler->IsMuted());
46 return true;
47 }
48
49 bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) {
50 if (accelerator.key_code() == ui::VKEY_F10)
51 content::RecordAction(content::UserMetricsAction("Accel_VolumeUp_F10"));
52
53 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
54 if (audio_handler->IsMuted()) {
55 audio_handler->SetMuted(false);
56 // If volume percent is still 0.0 after reset the mute status, it means that
57 // the mute status was done by VolumeDown, so we need to increase
58 // the volume as usual.
59 if (audio_handler->GetVolumePercent() == 0.0)
60 audio_handler->AdjustVolumeByPercent(kStepPercentage);
61 } else {
62 audio_handler->AdjustVolumeByPercent(kStepPercentage);
63 }
64
65 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
66 audio_handler->IsMuted());
67 return true;
68 }
69
70 void VolumeController::SetVolumePercent(double percent) {
71 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
72 audio_handler->SetVolumePercent(percent);
73 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
74 audio_handler->IsMuted());
75 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/volume_controller_chromeos.h ('k') | chrome/browser/ui/views/ash/caps_lock_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698