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

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

Issue 11417144: Use rewriting to make ChromeOS keyboard F<number> keys produce extended keycodes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding3 Created 8 years 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
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"
11 11
12 namespace { 12 namespace {
13 13
14 // Percent by which the volume should be changed when a volume key is pressed. 14 // Percent by which the volume should be changed when a volume key is pressed.
15 const double kStepPercentage = 4.0; 15 const double kStepPercentage = 4.0;
16 16
17 } // namespace 17 } // namespace
18 18
19 bool VolumeController::HandleVolumeMute(const ui::Accelerator& accelerator) { 19 bool VolumeController::HandleVolumeMute(const ui::Accelerator& accelerator) {
20 if (accelerator.key_code() == ui::VKEY_F8) 20 if (accelerator.key_code() == ui::VKEY_VOLUME_MUTE)
21 content::RecordAction(content::UserMetricsAction("Accel_VolumeMute_F8")); 21 content::RecordAction(content::UserMetricsAction("Accel_VolumeMute_F8"));
22 22
23 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 23 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
24 24
25 // Always muting (and not toggling) as per final decision on 25 // Always muting (and not toggling) as per final decision on
26 // http://crosbug.com/3751 26 // http://crosbug.com/3751
27 audio_handler->SetMuted(true); 27 audio_handler->SetMuted(true);
28 28
29 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), 29 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
30 audio_handler->IsMuted()); 30 audio_handler->IsMuted());
31 return true; 31 return true;
32 } 32 }
33 33
34 bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) { 34 bool VolumeController::HandleVolumeDown(const ui::Accelerator& accelerator) {
35 if (accelerator.key_code() == ui::VKEY_F9) 35 if (accelerator.key_code() == ui::VKEY_VOLUME_DOWN)
36 content::RecordAction(content::UserMetricsAction("Accel_VolumeDown_F9")); 36 content::RecordAction(content::UserMetricsAction("Accel_VolumeDown_F9"));
37 37
38 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 38 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
39 if (audio_handler->IsMuted()) 39 if (audio_handler->IsMuted())
40 audio_handler->SetVolumePercent(0.0); 40 audio_handler->SetVolumePercent(0.0);
41 else 41 else
42 audio_handler->AdjustVolumeByPercent(-kStepPercentage); 42 audio_handler->AdjustVolumeByPercent(-kStepPercentage);
43 43
44 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), 44 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
45 audio_handler->IsMuted()); 45 audio_handler->IsMuted());
46 return true; 46 return true;
47 } 47 }
48 48
49 bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) { 49 bool VolumeController::HandleVolumeUp(const ui::Accelerator& accelerator) {
50 if (accelerator.key_code() == ui::VKEY_F10) 50 if (accelerator.key_code() == ui::VKEY_VOLUME_UP)
51 content::RecordAction(content::UserMetricsAction("Accel_VolumeUp_F10")); 51 content::RecordAction(content::UserMetricsAction("Accel_VolumeUp_F10"));
52 52
53 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 53 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
54 if (audio_handler->IsMuted()) { 54 if (audio_handler->IsMuted()) {
55 audio_handler->SetMuted(false); 55 audio_handler->SetMuted(false);
56 } else { 56 } else {
57 audio_handler->AdjustVolumeByPercent(kStepPercentage); 57 audio_handler->AdjustVolumeByPercent(kStepPercentage);
58 } 58 }
59 59
60 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), 60 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
(...skipping 18 matching lines...) Expand all
79 void VolumeController::SetVolumeLevel(float level) { 79 void VolumeController::SetVolumeLevel(float level) {
80 SetVolumePercent(level * 100.f); 80 SetVolumePercent(level * 100.f);
81 } 81 }
82 82
83 void VolumeController::SetVolumePercent(double percent) { 83 void VolumeController::SetVolumePercent(double percent) {
84 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 84 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
85 audio_handler->SetVolumePercent(percent); 85 audio_handler->SetVolumePercent(percent);
86 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(), 86 extensions::DispatchVolumeChangedEvent(audio_handler->GetVolumePercent(),
87 audio_handler->IsMuted()); 87 audio_handler->IsMuted());
88 } 88 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/event_rewriter_unittest.cc ('k') | chrome/browser/ui/views/accelerator_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698