Add tests for redirect responses from SafeBrowsingProtocolManager.
[chromium-blink-merge.git] / ash / launcher / launcher_tooltip_manager.h
blobefe27f96541d8f4614a18f61ff7420ca3844b158
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"
19 namespace base {
20 class Timer;
23 namespace views {
24 class BubbleDelegateView;
25 class Label;
28 namespace ash {
29 namespace test {
30 class LauncherTooltipManagerTest;
31 class LauncherViewTest;
34 namespace internal {
35 class LauncherView;
37 // LauncherTooltipManager manages the tooltip balloon poping up on launcher
38 // items.
39 class ASH_EXPORT LauncherTooltipManager : public ui::EventHandler,
40 public ShelfLayoutManager::Observer,
41 public SessionStateObserver {
42 public:
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.
61 void Close();
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.
69 void ResetTimer();
71 // Stops the timer for the delayed showing |view_|.
72 void StopTimer();
74 // Returns true if the tooltip is currently visible.
75 bool IsVisible();
77 protected:
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)
85 OVERRIDE;
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;
93 private:
94 class LauncherTooltipBubble;
95 friend class test::LauncherViewTest;
96 friend class test::LauncherTooltipManagerTest;
98 void CancelHidingAnimation();
99 void CloseSoon();
100 void ShowInternal();
101 void CreateBubble(views::View* anchor, const string16& text);
103 LauncherTooltipBubble* view_;
104 views::Widget* widget_;
105 views::View* anchor_;
106 string16 text_;
107 scoped_ptr<base::Timer> timer_;
109 ShelfLayoutManager* shelf_layout_manager_;
110 LauncherView* launcher_view_;
112 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager);
115 } // namespace internal
116 } // namespace ash
118 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_