OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 10 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
11 #include "chrome/browser/chromeos/status/status_area_button.h" | 11 #include "chrome/browser/chromeos/status/status_area_button.h" |
12 #include "ui/views/controls/button/menu_button_delegate.h" | 12 #include "ui/views/controls/button/menu_button_listener.h" |
13 #include "ui/views/controls/menu/menu_delegate.h" | 13 #include "ui/views/controls/menu/menu_delegate.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class TimeDelta; | 16 class TimeDelta; |
17 } | 17 } |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class MenuRunner; | 20 class MenuRunner; |
21 } | 21 } |
22 | 22 |
23 namespace chromeos { | 23 namespace chromeos { |
24 | 24 |
25 class StatusAreaBubbleContentView; | 25 class StatusAreaBubbleContentView; |
26 | 26 |
27 // The power menu button in the status area. | 27 // The power menu button in the status area. |
28 // This class will handle getting the power status and populating the menu. | 28 // This class will handle getting the power status and populating the menu. |
29 class PowerMenuButton : public StatusAreaButton, | 29 class PowerMenuButton : public StatusAreaButton, |
30 public views::MenuDelegate, | 30 public views::MenuDelegate, |
31 public views::MenuButtonDelegate, | 31 public views::MenuButtonListener, |
32 public PowerManagerClient::Observer { | 32 public PowerManagerClient::Observer { |
33 public: | 33 public: |
34 explicit PowerMenuButton(StatusAreaButton::Delegate* delegate); | 34 explicit PowerMenuButton(StatusAreaButton::Delegate* delegate); |
35 virtual ~PowerMenuButton(); | 35 virtual ~PowerMenuButton(); |
36 | 36 |
37 // PowerManagerClient::Observer implementation. | 37 // PowerManagerClient::Observer implementation. |
38 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE; | 38 virtual void PowerChanged(const PowerSupplyStatus& power_status) OVERRIDE; |
39 virtual void SystemResumed() OVERRIDE {} | 39 virtual void SystemResumed() OVERRIDE {} |
40 | 40 |
41 protected: | 41 protected: |
42 virtual int icon_width() OVERRIDE; | 42 virtual int icon_width() OVERRIDE; |
43 | 43 |
44 private: | 44 private: |
45 // views::View | 45 // views::View |
46 virtual void OnLocaleChanged() OVERRIDE; | 46 virtual void OnLocaleChanged() OVERRIDE; |
47 | 47 |
48 // views::MenuButtonDelegate implementation. | 48 // views::MenuButtonListener implementation. |
49 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 49 virtual void OnMenuButtonClicked(views::View* source, |
| 50 const gfx::Point& point) OVERRIDE; |
50 | 51 |
51 // Format strings with power status | 52 // Format strings with power status |
52 string16 GetBatteryIsChargedText() const; | 53 string16 GetBatteryIsChargedText() const; |
53 | 54 |
54 // Update the power icon and menu label info depending on the power status. | 55 // Update the power icon and menu label info depending on the power status. |
55 void UpdateIconAndLabelInfo(); | 56 void UpdateIconAndLabelInfo(); |
56 | 57 |
57 // Update status view | 58 // Update status view |
58 void UpdateStatusView(); | 59 void UpdateStatusView(); |
59 | 60 |
(...skipping 17 matching lines...) Expand all Loading... |
77 | 78 |
78 // If non-null the menu is showing. | 79 // If non-null the menu is showing. |
79 scoped_ptr<views::MenuRunner> menu_runner_; | 80 scoped_ptr<views::MenuRunner> menu_runner_; |
80 | 81 |
81 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); | 82 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); |
82 }; | 83 }; |
83 | 84 |
84 } // namespace chromeos | 85 } // namespace chromeos |
85 | 86 |
86 #endif // CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_STATUS_POWER_MENU_BUTTON_H_ |
OLD | NEW |