| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | |
| 6 #define ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ash/shelf/wm_shelf_observer.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/timer/timer.h" | |
| 13 #include "ui/events/event_handler.h" | |
| 14 #include "ui/views/pointer_watcher.h" | |
| 15 | |
| 16 namespace views { | |
| 17 class BubbleDialogDelegateView; | |
| 18 class View; | |
| 19 } | |
| 20 | |
| 21 namespace ash { | |
| 22 class ShelfView; | |
| 23 | |
| 24 namespace test { | |
| 25 class ShelfTooltipManagerTest; | |
| 26 class ShelfViewTest; | |
| 27 } | |
| 28 | |
| 29 // ShelfTooltipManager manages the tooltip bubble that appears for shelf items. | |
| 30 class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler, | |
| 31 public views::PointerWatcher, | |
| 32 public WmShelfObserver { | |
| 33 public: | |
| 34 explicit ShelfTooltipManager(ShelfView* shelf_view); | |
| 35 ~ShelfTooltipManager() override; | |
| 36 | |
| 37 // Initializes the tooltip manager once the shelf is shown. | |
| 38 void Init(); | |
| 39 | |
| 40 // Closes the tooltip. | |
| 41 void Close(); | |
| 42 | |
| 43 // Returns true if the tooltip is currently visible. | |
| 44 bool IsVisible() const; | |
| 45 | |
| 46 // Returns the view to which the tooltip bubble is anchored. May be null. | |
| 47 views::View* GetCurrentAnchorView() const; | |
| 48 | |
| 49 // Show the tooltip bubble for the specified view. | |
| 50 void ShowTooltip(views::View* view); | |
| 51 void ShowTooltipWithDelay(views::View* view); | |
| 52 | |
| 53 // Set the timer delay in ms for testing. | |
| 54 void set_timer_delay_for_test(int timer_delay) { timer_delay_ = timer_delay; } | |
| 55 | |
| 56 protected: | |
| 57 // ui::EventHandler overrides: | |
| 58 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 59 | |
| 60 // views::PointerWatcher overrides: | |
| 61 void OnPointerEventObserved(const ui::PointerEvent& event, | |
| 62 const gfx::Point& location_in_screen, | |
| 63 views::Widget* target) override; | |
| 64 | |
| 65 // WmShelfObserver overrides: | |
| 66 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | |
| 67 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | |
| 68 | |
| 69 private: | |
| 70 class ShelfTooltipBubble; | |
| 71 friend class test::ShelfViewTest; | |
| 72 friend class test::ShelfTooltipManagerTest; | |
| 73 | |
| 74 // A helper function to check for shelf visibility and view validity. | |
| 75 bool ShouldShowTooltipForView(views::View* view); | |
| 76 | |
| 77 int timer_delay_; | |
| 78 base::OneShotTimer timer_; | |
| 79 | |
| 80 ShelfView* shelf_view_; | |
| 81 views::BubbleDialogDelegateView* bubble_; | |
| 82 | |
| 83 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager); | |
| 86 }; | |
| 87 | |
| 88 } // namespace ash | |
| 89 | |
| 90 #endif // ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_ | |
| OLD | NEW |