Home | History | Annotate | Download | only in brightness
      1 // 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 "base/metrics/user_metrics.h"
      8 #include "chromeos/dbus/dbus_thread_manager.h"
      9 #include "chromeos/dbus/power_manager_client.h"
     10 #include "ui/base/accelerators/accelerator.h"
     11 
     12 namespace ash {
     13 namespace system {
     14 
     15 bool BrightnessControllerChromeos::HandleBrightnessDown(
     16     const ui::Accelerator& accelerator) {
     17   if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_DOWN)
     18     base::RecordAction(
     19         base::UserMetricsAction("Accel_BrightnessDown_F6"));
     20 
     21   chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
     22       DecreaseScreenBrightness(true);
     23   return true;
     24 }
     25 
     26 bool BrightnessControllerChromeos::HandleBrightnessUp(
     27     const ui::Accelerator& accelerator) {
     28   if (accelerator.key_code() == ui::VKEY_BRIGHTNESS_UP)
     29     base::RecordAction(base::UserMetricsAction("Accel_BrightnessUp_F7"));
     30 
     31   chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
     32       IncreaseScreenBrightness();
     33   return true;
     34 }
     35 
     36 void BrightnessControllerChromeos::SetBrightnessPercent(double percent,
     37                                                         bool gradual) {
     38   chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
     39       SetScreenBrightnessPercent(percent, gradual);
     40 }
     41 
     42 void 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
     50