1 // Copyright (c) 2012 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_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_
6 #define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_
8 #include "ash/ash_export.h"
9 #include "ash/shelf_types.h"
10 #include "ash/wm/session_state_observer.h"
11 #include "ash/wm/shelf_layout_manager.h"
12 #include "base/basictypes.h"
13 #include "base/string16.h"
14 #include "ui/base/events/event_handler.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/views/bubble/bubble_border.h"
17 #include "ui/views/bubble/bubble_delegate.h"
24 class BubbleDelegateView
;
30 class LauncherTooltipManagerTest
;
31 class LauncherViewTest
;
37 // LauncherTooltipManager manages the tooltip balloon poping up on launcher
39 class ASH_EXPORT LauncherTooltipManager
: public ui::EventHandler
,
40 public ShelfLayoutManager::Observer
,
41 public SessionStateObserver
{
43 LauncherTooltipManager(ShelfLayoutManager
* shelf_layout_manager
,
44 LauncherView
* launcher_view
);
45 virtual ~LauncherTooltipManager();
47 ShelfLayoutManager
* shelf_layout_manager() {
48 return shelf_layout_manager_
;
51 // Called when the bubble is closed.
52 void OnBubbleClosed(views::BubbleDelegateView
* view
);
54 // Shows the tooltip after a delay. It also has the appearing animation.
55 void ShowDelayed(views::View
* anchor
, const string16
& text
);
57 // Shows the tooltip immediately. It omits the appearing animation.
58 void ShowImmediately(views::View
* anchor
, const string16
& text
);
60 // Closes the tooltip.
63 // Changes the arrow location of the tooltip in case that the launcher
64 // arrangement has changed.
65 void UpdateArrowLocation();
67 // Resets the timer for the delayed showing |view_|. If the timer isn't
68 // running, it starts a new timer.
71 // Stops the timer for the delayed showing |view_|.
74 // Returns true if the tooltip is currently visible.
78 // ui::EventHandler overrides:
79 virtual void OnMouseEvent(ui::MouseEvent
* event
) OVERRIDE
;
80 virtual void OnTouchEvent(ui::TouchEvent
* event
) OVERRIDE
;
81 virtual void OnGestureEvent(ui::GestureEvent
* event
) OVERRIDE
;
83 // SessionStateObserver override:
84 virtual void OnSessionStateEvent(SessionStateObserver::EventType event
)
87 // ShelfLayoutManager::Observer overrides:
88 virtual void WillDeleteShelf() OVERRIDE
;
89 virtual void WillChangeVisibilityState(
90 ShelfVisibilityState new_state
) OVERRIDE
;
91 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state
) OVERRIDE
;
94 class LauncherTooltipBubble
;
95 friend class test::LauncherViewTest
;
96 friend class test::LauncherTooltipManagerTest
;
98 void CancelHidingAnimation();
101 void CreateBubble(views::View
* anchor
, const string16
& text
);
103 LauncherTooltipBubble
* view_
;
104 views::Widget
* widget_
;
105 views::View
* anchor_
;
107 scoped_ptr
<base::Timer
> timer_
;
109 ShelfLayoutManager
* shelf_layout_manager_
;
110 LauncherView
* launcher_view_
;
112 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager
);
115 } // namespace internal
118 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_