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 CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/timer/timer.h" |
11 #include "ui/views/controls/image_view.h" | 12 #include "ui/views/controls/image_view.h" |
12 | 13 |
13 // A tooltip icon (just an ImageView with a tooltip). Looks like (?). | 14 namespace autofill { |
| 15 |
| 16 class InfoBubble; |
| 17 |
| 18 // A tooltip icon that shows a bubble on hover. Looks like (?). |
14 class TooltipIcon : public views::ImageView { | 19 class TooltipIcon : public views::ImageView { |
15 public: | 20 public: |
16 explicit TooltipIcon(const base::string16& tooltip); | 21 explicit TooltipIcon(const base::string16& tooltip); |
17 virtual ~TooltipIcon(); | 22 virtual ~TooltipIcon(); |
18 | 23 |
19 // views::View implementation | 24 static const char kViewClassName[]; |
20 virtual bool GetTooltipText(const gfx::Point& p, | 25 |
21 base::string16* tooltip) const OVERRIDE; | 26 // views::ImageView: |
| 27 virtual const char* GetClassName() const OVERRIDE; |
| 28 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 29 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 30 |
22 private: | 31 private: |
| 32 // Changes this view's image to the resource indicated by |idr|. |
| 33 void ChangeImageTo(int idr); |
| 34 |
| 35 // Starts a timer to hide |bubble_|. |
| 36 void StartHideTimer(); |
| 37 |
| 38 // Helpers to hide and show |bubble_|. |
| 39 void HideBubble(); |
| 40 void ShowBubble(); |
| 41 |
| 42 // The text to show in a bubble when hovered. |
23 base::string16 tooltip_; | 43 base::string16 tooltip_; |
24 | 44 |
| 45 // A bubble shown on hover. Weak; owns itself. NULL while hiding. |
| 46 InfoBubble* bubble_; |
| 47 |
| 48 // A timer to delay hiding |bubble_|. |
| 49 base::OneShotTimer<TooltipIcon> hide_timer_; |
| 50 |
25 DISALLOW_COPY_AND_ASSIGN(TooltipIcon); | 51 DISALLOW_COPY_AND_ASSIGN(TooltipIcon); |
26 }; | 52 }; |
27 | 53 |
| 54 } // namespace autofill |
| 55 |
28 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ | 56 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ |
OLD | NEW |