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

Side by Side Diff: chrome/browser/ui/views/aura/volume_controller_chromeos.cc

Issue 9570044: Rename chrome/browser/ui/views/{aura => ash}/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 9 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/views/aura/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/chromeos/ui/brightness_bubble.h"
10 #include "chrome/browser/chromeos/ui/volume_bubble.h"
11 #include "chrome/browser/extensions/system/system_api.h"
12 #include "content/public/browser/user_metrics.h"
13
14 namespace {
15
16 // Percent by which the volume should be changed when a volume key is pressed.
17 const double kStepPercentage = 4.0;
18
19 // Percent to which the volume should be set when the "volume up" key is pressed
20 // while we're muted and have the volume set to 0. See
21 // http://crosbug.com/13618.
22 const double kVolumePercentOnVolumeUpWhileMuted = 25.0;
23
24 void ShowVolumeBubble() {
25 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
26 chromeos::VolumeBubble::GetInstance()->ShowBubble(
27 audio_handler->GetVolumePercent(),
28 !audio_handler->IsMuted());
29 chromeos::BrightnessBubble::GetInstance()->HideBubble();
30 }
31
32 } // namespace
33
34 bool VolumeController::HandleVolumeMute(const ui::Accelerator& accelerator) {
35 if (accelerator.key_code() == ui::VKEY_F8)
36 content::RecordAction(content::UserMetricsAction("Accel_VolumeMute_F8"));
37
38 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
39
40 // Always muting (and not toggling) as per final decision on
41 // http://crosbug.com/3751
42 audio_handler->SetMuted(true);
43
44 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
45 audio_handler->IsMuted());
46 ShowVolumeBubble();
47 return true;
48 }
49
50 bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) {
51 if (accelerator.key_code() == ui::VKEY_F9)
52 content::RecordAction(content::UserMetricsAction("Accel_VolumeDown_F9"));
53
54 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
55 if (audio_handler->IsMuted())
56 audio_handler->SetVolumePercent(0.0);
57 else
58 audio_handler->AdjustVolumeByPercent(-kStepPercentage);
59
60 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
61 audio_handler->IsMuted());
62 ShowVolumeBubble();
63 return true;
64 }
65
66 bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) {
67 if (accelerator.key_code() == ui::VKEY_F10)
68 content::RecordAction(content::UserMetricsAction("Accel_VolumeUp_F10"));
69
70 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
71 if (audio_handler->IsMuted()) {
72 audio_handler->SetMuted(false);
73 if (audio_handler->GetVolumePercent() <= 0.1) // float comparison
74 audio_handler->SetVolumePercent(kVolumePercentOnVolumeUpWhileMuted);
75 } else {
76 audio_handler->AdjustVolumeByPercent(kStepPercentage);
77 }
78
79 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
80 audio_handler->IsMuted());
81 ShowVolumeBubble();
82 return true;
83 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/aura/volume_controller_chromeos.h ('k') | chrome/browser/ui/views/frame/browser_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698