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_CAPS_LOCK_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_CAPS_LOCK_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_CAPS_LOCK_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_CAPS_LOCK_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/timer.h" |
11 #include "chrome/browser/chromeos/status/status_area_button.h" | 12 #include "chrome/browser/chromeos/status/status_area_button.h" |
12 #include "chrome/browser/chromeos/system_key_event_listener.h" | 13 #include "chrome/browser/chromeos/system_key_event_listener.h" |
13 #include "chrome/browser/prefs/pref_member.h" | 14 #include "chrome/browser/prefs/pref_member.h" |
14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
15 #include "views/controls/menu/menu_delegate.h" | 16 #include "views/controls/menu/menu_delegate.h" |
16 #include "views/controls/menu/view_menu_delegate.h" | 17 #include "views/controls/menu/view_menu_delegate.h" |
17 | 18 |
| 19 class Bubble; |
| 20 |
18 namespace views { | 21 namespace views { |
19 class MenuRunner; | 22 class MenuRunner; |
20 } | 23 } |
21 | 24 |
22 namespace chromeos { | 25 namespace chromeos { |
23 | 26 |
24 class StatusAreaHost; | 27 class StatusAreaHost; |
25 | 28 |
26 // A class for the button in the status area which alerts the user when caps | 29 // A class for the button in the status area which alerts the user when caps |
27 // lock is active. | 30 // lock is active. |
(...skipping 20 matching lines...) Expand all Loading... |
48 virtual void OnCapsLockChange(bool enabled); | 51 virtual void OnCapsLockChange(bool enabled); |
49 | 52 |
50 // content::NotificationObserver implementation | 53 // content::NotificationObserver implementation |
51 virtual void Observe(int type, | 54 virtual void Observe(int type, |
52 const content::NotificationSource& source, | 55 const content::NotificationSource& source, |
53 const content::NotificationDetails& details); | 56 const content::NotificationDetails& details); |
54 | 57 |
55 // Updates the accessible name. | 58 // Updates the accessible name. |
56 void UpdateAccessibleName(); | 59 void UpdateAccessibleName(); |
57 | 60 |
58 // Gets the text for the drop-down menu. | 61 // Gets the text for the drop-down menu and bubble. |
59 string16 GetText() const; | 62 string16 GetText() const; |
60 | 63 |
61 // Updates the UI from the current state. | 64 // Updates the button from the current state. |
62 void UpdateUIFromCurrentCapsLock(bool enabled); | 65 void UpdateUIFromCurrentCapsLock(bool enabled); |
63 | 66 |
64 private: | 67 private: |
65 class StatusView; | 68 class StatusView; |
66 | 69 |
| 70 // Returns true if the Search key is assigned to Caps Lock. |
| 71 bool HasCapsLock() const; |
| 72 |
| 73 bool IsMenuShown() const; |
| 74 void HideMenu(); |
| 75 |
| 76 bool IsBubbleShown() const; |
| 77 void MaybeShowBubble(); |
| 78 void CreateAndShowBubble(); |
| 79 void HideBubble(); |
| 80 |
67 PrefService* prefs_; | 81 PrefService* prefs_; |
68 IntegerPrefMember remap_search_key_to_; | 82 IntegerPrefMember remap_search_key_to_; |
69 | 83 |
70 // The currently showing status view. NULL if menu is not being displayed. | 84 // The currently showing status view. NULL if menu is not being displayed. |
71 StatusView* status_; | 85 StatusView* status_; |
72 | |
73 // If non-null the menu is showing. | 86 // If non-null the menu is showing. |
74 scoped_ptr<views::MenuRunner> menu_runner_; | 87 scoped_ptr<views::MenuRunner> menu_runner_; |
75 | 88 |
| 89 // The currently showing bubble. NULL if bubble is not being displayed. |
| 90 Bubble* bubble_; |
| 91 // If true, |bubble_| is shown when both shift keys are pressed. |
| 92 bool should_show_bubble_; |
| 93 // # of times |bubble_| is shown. |
| 94 size_t bubble_count_; |
| 95 // TODO(yusukes): Save should_show_bubble_ and bubble_count_ in Preferences. |
| 96 |
| 97 // The timer for hiding the bubble. |
| 98 base::OneShotTimer<CapsLockMenuButton> bubble_timer_; |
| 99 |
76 DISALLOW_COPY_AND_ASSIGN(CapsLockMenuButton); | 100 DISALLOW_COPY_AND_ASSIGN(CapsLockMenuButton); |
77 }; | 101 }; |
78 | 102 |
79 } // namespace chromeos | 103 } // namespace chromeos |
80 | 104 |
81 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CAPS_LOCK_MENU_BUTTON_H_ | 105 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CAPS_LOCK_MENU_BUTTON_H_ |
OLD | NEW |