| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "ui/views/bubble/bubble_border.h" |
| 14 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/mouse_watcher.h" | 16 #include "ui/views/mouse_watcher.h" |
| 16 #include "ui/views/widget/widget_observer.h" | 17 #include "ui/views/widget/widget_observer.h" |
| 17 | 18 |
| 18 namespace autofill { | 19 namespace autofill { |
| 19 | 20 |
| 20 class InfoBubble; | 21 class InfoBubble; |
| 21 | 22 |
| 22 // A tooltip icon that shows a bubble on hover. Looks like (?). | 23 // A tooltip icon that shows a bubble on hover. Looks like (?). |
| 23 class TooltipIcon : public views::ImageView, | 24 class TooltipIcon : public views::ImageView, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 void OnMouseExited(const ui::MouseEvent& event) override; | 36 void OnMouseExited(const ui::MouseEvent& event) override; |
| 36 void OnGestureEvent(ui::GestureEvent* event) override; | 37 void OnGestureEvent(ui::GestureEvent* event) override; |
| 37 void GetAccessibleState(ui::AXViewState* state) override; | 38 void GetAccessibleState(ui::AXViewState* state) override; |
| 38 | 39 |
| 39 // views::MouseWatcherListener: | 40 // views::MouseWatcherListener: |
| 40 void MouseMovedOutOfHost() override; | 41 void MouseMovedOutOfHost() override; |
| 41 | 42 |
| 42 // views::WidgetObserver: | 43 // views::WidgetObserver: |
| 43 void OnWidgetDestroyed(views::Widget* widget) override; | 44 void OnWidgetDestroyed(views::Widget* widget) override; |
| 44 | 45 |
| 46 void set_bubble_arrow(views::BubbleBorder::Arrow arrow) { |
| 47 bubble_arrow_ = arrow; |
| 48 } |
| 49 |
| 45 private: | 50 private: |
| 46 // Changes this view's image to the resource indicated by |idr|. | 51 // Changes this view's image to the resource indicated by |idr|. |
| 47 void ChangeImageTo(int idr); | 52 void ChangeImageTo(int idr); |
| 48 | 53 |
| 49 // Creates and shows |bubble_|. If |bubble_| already exists, just cancels a | 54 // Creates and shows |bubble_|. If |bubble_| already exists, just cancels a |
| 50 // potential close timer. | 55 // potential close timer. |
| 51 void ShowBubble(); | 56 void ShowBubble(); |
| 52 | 57 |
| 53 // Hides |bubble_| if necessary. | 58 // Hides |bubble_| if necessary. |
| 54 void HideBubble(); | 59 void HideBubble(); |
| 55 | 60 |
| 56 // The text to show in a bubble when hovered. | 61 // The text to show in a bubble when hovered. |
| 57 base::string16 tooltip_; | 62 base::string16 tooltip_; |
| 58 | 63 |
| 59 // Whether the mouse is inside this tooltip. | 64 // Whether the mouse is inside this tooltip. |
| 60 bool mouse_inside_; | 65 bool mouse_inside_; |
| 61 | 66 |
| 62 // A bubble shown on hover. Weak; owns itself. NULL while hiding. | 67 // A bubble shown on hover. Weak; owns itself. NULL while hiding. |
| 63 InfoBubble* bubble_; | 68 InfoBubble* bubble_; |
| 64 | 69 |
| 70 // The position of the bubble's arrow. |
| 71 views::BubbleBorder::Arrow bubble_arrow_; |
| 72 |
| 65 // A timer to delay showing |bubble_|. | 73 // A timer to delay showing |bubble_|. |
| 66 base::OneShotTimer<TooltipIcon> show_timer_; | 74 base::OneShotTimer<TooltipIcon> show_timer_; |
| 67 | 75 |
| 68 // A watcher that keeps |bubble_| open if the user's mouse enters it. | 76 // A watcher that keeps |bubble_| open if the user's mouse enters it. |
| 69 scoped_ptr<views::MouseWatcher> mouse_watcher_; | 77 scoped_ptr<views::MouseWatcher> mouse_watcher_; |
| 70 | 78 |
| 71 ScopedObserver<views::Widget, TooltipIcon> observer_; | 79 ScopedObserver<views::Widget, TooltipIcon> observer_; |
| 72 | 80 |
| 73 DISALLOW_COPY_AND_ASSIGN(TooltipIcon); | 81 DISALLOW_COPY_AND_ASSIGN(TooltipIcon); |
| 74 }; | 82 }; |
| 75 | 83 |
| 76 } // namespace autofill | 84 } // namespace autofill |
| 77 | 85 |
| 78 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ | 86 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_TOOLTIP_ICON_H_ |
| OLD | NEW |