summaryrefslogtreecommitdiffstats
path: root/ash/system/chromeos/keyboard_brightness_controller.cc
blob: bad8d09cde438ab61e4cf30224494aefed3c0521 (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
// 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 "ash/system/chromeos/keyboard_brightness_controller.h"

#include "ash/shell.h"
#include "ash/shell_delegate.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"

namespace ash {

bool KeyboardBrightnessController::HandleKeyboardBrightnessDown(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_DOWN) {
    Shell::GetInstance()->delegate()->RecordUserMetricsAction(
        UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6);
  }

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

bool KeyboardBrightnessController::HandleKeyboardBrightnessUp(
    const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_UP) {
    Shell::GetInstance()->delegate()->RecordUserMetricsAction(
        UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7);
  }

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

}  // namespace ash