Add Chrome Remote Desktop to approved extensions list of metrics-private API.
[chromium-blink-merge.git] / ash / shelf / shelf_tooltip_manager.h
blob8850f49ad9a4177de666ac9e6863cc1a258f0aff
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.
5 #ifndef ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_
6 #define ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_
8 #include "ash/ash_export.h"
9 #include "ash/shelf/shelf_layout_manager_observer.h"
10 #include "ash/shelf/shelf_types.h"
11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "ui/events/event_handler.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/bubble/bubble_border.h"
17 #include "ui/views/bubble/bubble_delegate.h"
19 namespace base {
20 class Timer;
23 namespace views {
24 class BubbleDelegateView;
25 class Label;
28 namespace ash {
29 class ShelfView;
30 class ShelfLayoutManager;
32 namespace test {
33 class ShelfTooltipManagerTest;
34 class ShelfViewTest;
37 // ShelfTooltipManager manages the tooltip balloon poping up on shelf items.
38 class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler,
39 public ShelfLayoutManagerObserver {
40 public:
41 ShelfTooltipManager(ShelfLayoutManager* shelf_layout_manager,
42 ShelfView* shelf_view);
43 ~ShelfTooltipManager() override;
45 ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; }
47 // Called when the bubble is closed.
48 void OnBubbleClosed(views::BubbleDelegateView* view);
50 // Shows the tooltip after a delay. It also has the appearing animation.
51 void ShowDelayed(views::View* anchor, const base::string16& text);
53 // Shows the tooltip immediately. It omits the appearing animation.
54 void ShowImmediately(views::View* anchor, const base::string16& text);
56 // Closes the tooltip.
57 void Close();
59 // Changes the arrow location of the tooltip in case that the launcher
60 // arrangement has changed.
61 void UpdateArrow();
63 // Resets the timer for the delayed showing |view_|. If the timer isn't
64 // running, it starts a new timer.
65 void ResetTimer();
67 // Stops the timer for the delayed showing |view_|.
68 void StopTimer();
70 // Returns true if the tooltip is currently visible.
71 bool IsVisible();
73 // Returns the view to which the tooltip bubble is anchored. May be NULL.
74 views::View* GetCurrentAnchorView() { return anchor_; }
76 // Create an instant timer for test purposes.
77 void CreateZeroDelayTimerForTest();
79 protected:
80 // ui::EventHandler overrides:
81 void OnMouseEvent(ui::MouseEvent* event) override;
82 void OnTouchEvent(ui::TouchEvent* event) override;
83 void OnGestureEvent(ui::GestureEvent* event) override;
84 void OnCancelMode(ui::CancelModeEvent* event) override;
86 // ShelfLayoutManagerObserver overrides:
87 void WillDeleteShelf() override;
88 void WillChangeVisibilityState(ShelfVisibilityState new_state) override;
89 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
91 private:
92 class ShelfTooltipBubble;
93 friend class test::ShelfViewTest;
94 friend class test::ShelfTooltipManagerTest;
96 void CancelHidingAnimation();
97 void CloseSoon();
98 void ShowInternal();
99 void CreateBubble(views::View* anchor, const base::string16& text);
100 void CreateTimer(int delay_in_ms);
102 ShelfTooltipBubble* view_;
103 views::Widget* widget_;
104 views::View* anchor_;
105 base::string16 text_;
106 scoped_ptr<base::Timer> timer_;
108 ShelfLayoutManager* shelf_layout_manager_;
109 ShelfView* shelf_view_;
111 base::WeakPtrFactory<ShelfTooltipManager> weak_factory_;
113 DISALLOW_COPY_AND_ASSIGN(ShelfTooltipManager);
116 } // namespace ash
118 #endif // ASH_SHELF_SHELF_TOOLTIP_MANAGER_H_