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.
5 #ifndef ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_
6 #define ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_
8 #include "ash/system/tray/system_tray_item.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/dbus/power_manager_client.h"
18 class ASH_EXPORT TrayBrightness
19 : public SystemTrayItem,
20 public chromeos::PowerManagerClient::Observer {
22 explicit TrayBrightness(SystemTray* system_tray);
23 virtual ~TrayBrightness();
26 friend class TrayBrightnessTest;
28 // Sends a request to get the current screen brightness so |current_percent_|
29 // can be initialized.
30 void GetInitialBrightness();
32 // Updates |current_percent_| with the initial brightness requested by
33 // GetInitialBrightness(), if we haven't seen the brightness already in the
35 void HandleInitialBrightness(double percent);
37 // Overridden from SystemTrayItem.
38 virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
39 virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
40 virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
41 virtual void DestroyTrayView() OVERRIDE;
42 virtual void DestroyDefaultView() OVERRIDE;
43 virtual void DestroyDetailedView() OVERRIDE;
44 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
45 virtual bool ShouldHideArrow() const OVERRIDE;
46 virtual bool ShouldShowShelf() const OVERRIDE;
48 // Overriden from PowerManagerClient::Observer.
49 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE;
51 void HandleBrightnessChanged(double percent, bool user_initiated);
53 base::WeakPtrFactory<TrayBrightness> weak_ptr_factory_;
55 tray::BrightnessView* brightness_view_;
57 // Brightness level in the range [0.0, 100.0] that we've heard about most
59 double current_percent_;
61 // Has |current_percent_| been initialized?
62 bool got_current_percent_;
64 DISALLOW_COPY_AND_ASSIGN(TrayBrightness);
69 #endif // ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_