summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/ash/brightness_controller_chromeos.cc
blob: 9099445230a86ce747c2b8eb1fa6aa611c24fd3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/ash/brightness_controller_chromeos.h"

#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "content/public/browser/user_metrics.h"
#include "ui/base/accelerators/accelerator.h"

bool BrightnessController::HandleBrightnessDown(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_F6)
    content::RecordAction(
        content::UserMetricsAction("Accel_BrightnessDown_F6"));

  chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
      DecreaseScreenBrightness(true);
  return true;
}

bool BrightnessController::HandleBrightnessUp(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_F7)
    content::RecordAction(content::UserMetricsAction("Accel_BrightnessUp_F7"));

  chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
      IncreaseScreenBrightness();
  return true;
}

void BrightnessController::SetBrightnessPercent(double percent, bool gradual) {
  chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
      SetScreenBrightnessPercent(percent, gradual);
}

void BrightnessController::GetBrightnessPercent(
    const base::Callback<void(double)>& callback) {
  chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
      GetScreenBrightnessPercent(callback);
}