OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/chromeos/cros/power_library.h" | 9 #include "chrome/browser/chromeos/cros/power_library.h" |
10 #include "chrome/browser/chromeos/status/status_area_button.h" | 10 #include "chrome/browser/chromeos/status/status_area_button.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual ~PowerMenuButton(); | 30 virtual ~PowerMenuButton(); |
31 | 31 |
32 // views::MenuDelegate implementation. | 32 // views::MenuDelegate implementation. |
33 virtual std::wstring GetLabel(int id) const; | 33 virtual std::wstring GetLabel(int id) const; |
34 virtual bool IsCommandEnabled(int id) const; | 34 virtual bool IsCommandEnabled(int id) const; |
35 | 35 |
36 // PowerLibrary::Observer implementation. | 36 // PowerLibrary::Observer implementation. |
37 virtual void PowerChanged(PowerLibrary* obj); | 37 virtual void PowerChanged(PowerLibrary* obj); |
38 virtual void SystemResumed() {} | 38 virtual void SystemResumed() {} |
39 | 39 |
40 int icon_id() const { return icon_id_; } | 40 int battery_index() const { return battery_index_; } |
41 | 41 |
42 protected: | 42 protected: |
43 virtual int icon_width(); | 43 virtual int icon_width(); |
44 | 44 |
45 private: | 45 private: |
| 46 class StatusView; |
| 47 |
46 // views::View | 48 // views::View |
47 virtual void OnLocaleChanged() OVERRIDE; | 49 virtual void OnLocaleChanged() OVERRIDE; |
48 | 50 |
49 // views::ViewMenuDelegate implementation. | 51 // views::ViewMenuDelegate implementation. |
50 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 52 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
51 | 53 |
52 // Format strings with power status | 54 // Format strings with power status |
53 string16 GetBatteryPercentageText() const; | 55 string16 GetBatteryPercentageText() const; |
54 string16 GetBatteryIsChargedText() const; | 56 string16 GetBatteryIsChargedText() const; |
55 | 57 |
56 // Update the power icon and menu label info depending on the power status. | 58 // Update the power icon and menu label info depending on the power status. |
57 void UpdateIconAndLabelInfo(); | 59 void UpdateIconAndLabelInfo(); |
58 | 60 |
59 // Update Battery time. Try to make it monotonically decreasing unless | 61 // Update Battery time. Try to make it monotonically decreasing unless |
60 // there's a large delta. | 62 // there's a large delta. |
61 void UpdateBatteryTime(base::TimeDelta* previous, | 63 void UpdateBatteryTime(base::TimeDelta* previous, |
62 const base::TimeDelta& current); | 64 const base::TimeDelta& current); |
63 | 65 |
64 // Update the menu entries. | |
65 void UpdateMenu(); | |
66 | |
67 // The number of power images. | |
68 static const int kNumPowerImages; | |
69 | |
70 // Stored data gathered from CrosLibrary::PowerLibrary. | 66 // Stored data gathered from CrosLibrary::PowerLibrary. |
71 bool battery_is_present_; | 67 bool battery_is_present_; |
72 bool line_power_on_; | 68 bool line_power_on_; |
73 bool battery_fully_charged_; | |
74 double battery_percentage_; | 69 double battery_percentage_; |
| 70 string16 percentage_text_; |
| 71 int battery_index_; |
75 base::TimeDelta battery_time_to_full_; | 72 base::TimeDelta battery_time_to_full_; |
76 base::TimeDelta battery_time_to_empty_; | 73 base::TimeDelta battery_time_to_empty_; |
77 | 74 |
78 // The currently showing icon bitmap id. | 75 // The currently showing status view. NULL if menu is not being displayed. |
79 int icon_id_; | 76 StatusView* status_; |
80 | 77 |
81 // The power menu. This needs to be initialized last since it calls into | 78 // The currently showing menu. NULL if menu is not being displayed. |
82 // GetLabelAt() during construction. | 79 views::MenuItemView* menu_; |
83 scoped_ptr<views::MenuItemView> menu_; | |
84 | 80 |
85 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); | 81 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); |
86 }; | 82 }; |
87 | 83 |
88 } // namespace chromeos | 84 } // namespace chromeos |
89 | 85 |
90 #endif // CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ | 86 #endif // CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ |
OLD | NEW |