OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ |
6 #define ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ | 6 #define ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ |
7 | 7 |
8 #include "ash/system/tray/system_tray_item.h" | 8 #include "ash/system/tray/system_tray_item.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "chromeos/dbus/power_manager_client.h" | 11 #include "chromeos/dbus/power_manager_client.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace tray { | 14 namespace tray { |
15 class BrightnessView; | 15 class BrightnessView; |
16 } | 16 } |
17 | 17 |
18 class ASH_EXPORT TrayBrightness | 18 class ASH_EXPORT TrayBrightness |
19 : public SystemTrayItem, | 19 : public SystemTrayItem, |
20 public chromeos::PowerManagerClient::Observer { | 20 public chromeos::PowerManagerClient::Observer { |
21 public: | 21 public: |
22 explicit TrayBrightness(SystemTray* system_tray); | 22 explicit TrayBrightness(SystemTray* system_tray); |
23 virtual ~TrayBrightness(); | 23 ~TrayBrightness() override; |
24 | 24 |
25 private: | 25 private: |
26 friend class TrayBrightnessTest; | 26 friend class TrayBrightnessTest; |
27 | 27 |
28 // Sends a request to get the current screen brightness so |current_percent_| | 28 // Sends a request to get the current screen brightness so |current_percent_| |
29 // can be initialized. | 29 // can be initialized. |
30 void GetInitialBrightness(); | 30 void GetInitialBrightness(); |
31 | 31 |
32 // Updates |current_percent_| with the initial brightness requested by | 32 // Updates |current_percent_| with the initial brightness requested by |
33 // GetInitialBrightness(), if we haven't seen the brightness already in the | 33 // GetInitialBrightness(), if we haven't seen the brightness already in the |
34 // meantime. | 34 // meantime. |
35 void HandleInitialBrightness(double percent); | 35 void HandleInitialBrightness(double percent); |
36 | 36 |
37 // Overridden from SystemTrayItem. | 37 // Overridden from SystemTrayItem. |
38 virtual views::View* CreateTrayView(user::LoginStatus status) override; | 38 views::View* CreateTrayView(user::LoginStatus status) override; |
39 virtual views::View* CreateDefaultView(user::LoginStatus status) override; | 39 views::View* CreateDefaultView(user::LoginStatus status) override; |
40 virtual views::View* CreateDetailedView(user::LoginStatus status) override; | 40 views::View* CreateDetailedView(user::LoginStatus status) override; |
41 virtual void DestroyTrayView() override; | 41 void DestroyTrayView() override; |
42 virtual void DestroyDefaultView() override; | 42 void DestroyDefaultView() override; |
43 virtual void DestroyDetailedView() override; | 43 void DestroyDetailedView() override; |
44 virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) override; | 44 void UpdateAfterLoginStatusChange(user::LoginStatus status) override; |
45 virtual bool ShouldHideArrow() const override; | 45 bool ShouldHideArrow() const override; |
46 virtual bool ShouldShowShelf() const override; | 46 bool ShouldShowShelf() const override; |
47 | 47 |
48 // Overriden from PowerManagerClient::Observer. | 48 // Overriden from PowerManagerClient::Observer. |
49 virtual void BrightnessChanged(int level, bool user_initiated) override; | 49 void BrightnessChanged(int level, bool user_initiated) override; |
50 | 50 |
51 void HandleBrightnessChanged(double percent, bool user_initiated); | 51 void HandleBrightnessChanged(double percent, bool user_initiated); |
52 | 52 |
53 tray::BrightnessView* brightness_view_; | 53 tray::BrightnessView* brightness_view_; |
54 | 54 |
55 // Brightness level in the range [0.0, 100.0] that we've heard about most | 55 // Brightness level in the range [0.0, 100.0] that we've heard about most |
56 // recently. | 56 // recently. |
57 double current_percent_; | 57 double current_percent_; |
58 | 58 |
59 // Has |current_percent_| been initialized? | 59 // Has |current_percent_| been initialized? |
60 bool got_current_percent_; | 60 bool got_current_percent_; |
61 | 61 |
62 base::WeakPtrFactory<TrayBrightness> weak_ptr_factory_; | 62 base::WeakPtrFactory<TrayBrightness> weak_ptr_factory_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(TrayBrightness); | 64 DISALLOW_COPY_AND_ASSIGN(TrayBrightness); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace ash | 67 } // namespace ash |
68 | 68 |
69 #endif // ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ | 69 #endif // ASH_SYSTEM_CHROMEOS_BRIGHTNESS_TRAY_BRIGHTNESS_H_ |
OLD | NEW |