blob: 78d35df4bc77c5a910d94807b9bb6610d9e9ee42 [file] [log] [blame]
Torne (Richard Coles)4e180b62013-10-18 15:46:22 +01001// Copyright 2013 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 "ash/system/chromeos/brightness/brightness_controller_chromeos.h"
6
7#include "chromeos/dbus/dbus_thread_manager.h"
8#include "chromeos/dbus/power_manager_client.h"
9#include "content/public/browser/user_metrics.h"
10#include "ui/base/accelerators/accelerator.h"
11
12namespace ash {
13namespace system {
14
15bool BrightnessControllerChromeos::HandleBrightnessDown(
16 const ui::Accelerator& accelerator) {
17 if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_DOWN)
18 content::RecordAction(
19 content::UserMetricsAction("Accel_BrightnessDown_F6"));
20
21 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
22 DecreaseScreenBrightness(true);
23 return true;
24}
25
26bool BrightnessControllerChromeos::HandleBrightnessUp(
27 const ui::Accelerator& accelerator) {
28 if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_UP)
29 content::RecordAction(content::UserMetricsAction("Accel_BrightnessUp_F7"));
30
31 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
32 IncreaseScreenBrightness();
33 return true;
34}
35
36void BrightnessControllerChromeos::SetBrightnessPercent(double percent,
37 bool gradual) {
38 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
39 SetScreenBrightnessPercent(percent, gradual);
40}
41
42void BrightnessControllerChromeos::GetBrightnessPercent(
43 const base::Callback<void(double)>& callback) {
44 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
45 GetScreenBrightnessPercent(callback);
46}
47
48} // namespace system
49} // namespace ash