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_ACCESSIBILITY_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/chromeos/status/status_area_button.h" | 9 #include "chrome/browser/chromeos/status/status_area_button.h" |
10 #include "chrome/browser/prefs/pref_member.h" | 10 #include "chrome/browser/prefs/pref_member.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.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 views { | 15 namespace views { |
16 class MenuRunner; | 16 class MenuRunner; |
17 } | 17 } |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 class StatusAreaBubbleController; | 21 class StatusAreaBubbleController; |
22 | 22 |
23 // A class for the button in the status area which alerts the user when | 23 // A class for the button in the status area which alerts the user when |
24 // accessibility features are enabled. | 24 // accessibility features are enabled. |
25 class AccessibilityMenuButton : public StatusAreaButton, | 25 class AccessibilityMenuButton : public StatusAreaButton, |
26 public views::MenuButtonDelegate, | 26 public views::MenuButtonListener, |
27 public views::MenuDelegate, | 27 public views::MenuDelegate, |
28 public content::NotificationObserver { | 28 public content::NotificationObserver { |
29 public: | 29 public: |
30 explicit AccessibilityMenuButton(StatusAreaButton::Delegate* delegate); | 30 explicit AccessibilityMenuButton(StatusAreaButton::Delegate* delegate); |
31 virtual ~AccessibilityMenuButton(); | 31 virtual ~AccessibilityMenuButton(); |
32 | 32 |
33 // views::MenuButtonDelegate implementation | 33 // Overridden from views::MenuButtonListener: |
34 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 34 virtual void OnMenuButtonClicked(views::View* source, |
| 35 const gfx::Point& point) OVERRIDE; |
35 | 36 |
36 // views::MenuDelegate implementation | 37 // Overridden from views::MenuDelegate: |
37 virtual void ExecuteCommand(int id) OVERRIDE; | 38 virtual void ExecuteCommand(int id) OVERRIDE; |
38 | 39 |
39 // content::NotificationObserver implementation | 40 // content::NotificationObserver implementation |
40 virtual void Observe(int type, | 41 virtual void Observe(int type, |
41 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
42 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
43 | 44 |
44 private: | 45 private: |
45 // Updates the state along with the preferences. | 46 // Updates the state along with the preferences. |
46 void Update(); | 47 void Update(); |
47 | 48 |
48 // Prepares menu before showing it. | 49 // Prepares menu before showing it. |
49 void PrepareMenu(); | 50 void PrepareMenu(); |
50 | 51 |
51 // An object synced to the preference, representing if accessibility feature | 52 // An object synced to the preference, representing if accessibility feature |
52 // is enabled or not. | 53 // is enabled or not. |
53 BooleanPrefMember accessibility_enabled_; | 54 BooleanPrefMember accessibility_enabled_; |
54 // An object to show menu. | 55 // An object to show menu. |
55 scoped_ptr<views::MenuRunner> menu_runner_; | 56 scoped_ptr<views::MenuRunner> menu_runner_; |
56 // The currently showing bubble controller. | 57 // The currently showing bubble controller. |
57 scoped_ptr<StatusAreaBubbleController> bubble_controller_; | 58 scoped_ptr<StatusAreaBubbleController> bubble_controller_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(AccessibilityMenuButton); | 60 DISALLOW_COPY_AND_ASSIGN(AccessibilityMenuButton); |
60 }; | 61 }; |
61 | 62 |
62 } // namespace chromeos | 63 } // namespace chromeos |
63 | 64 |
64 #endif // CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_ | 65 #endif // CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_ |
OLD | NEW |