1 // Copyright 2015 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 COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread_checker.h"
11 #include "components/bubble/bubble_close_reason.h"
12 #include "components/bubble/bubble_reference.h"
16 // Inherit from BubbleManager to show, update, and close bubbles.
17 // Any class that inherits from BubbleManager should capture any events that
18 // should dismiss a bubble or update its anchor point.
19 // This class assumes that we won't be showing a lot of bubbles simultaneously.
20 // TODO(hcarmona): Handle simultaneous bubbles. http://crbug.com/366937
23 // Should be instantiated on the UI thread.
25 virtual ~BubbleManager();
27 // Shows a specific bubble and returns a reference to it.
28 // This reference should be used through the BubbleManager.
29 BubbleReference
ShowBubble(scoped_ptr
<BubbleDelegate
> bubble
);
31 // Notify a bubble of an event that might trigger close.
32 // Returns true if the bubble was actually closed.
33 bool CloseBubble(BubbleReference bubble
, BubbleCloseReason reason
);
35 // Notify all bubbles of an event that might trigger close.
36 void CloseAllBubbles(BubbleCloseReason reason
);
38 // Notify all bubbles that their anchor or parent may have changed.
39 void UpdateAllBubbleAnchors();
48 // Show any bubbles that were added to |show_queue_|.
49 void ShowPendingBubbles();
51 // Verify that functions that affect the UI are done on the same thread.
52 base::ThreadChecker thread_checker_
;
54 // Determines what happens to a bubble when |ShowBubble| is called.
55 ManagerStates manager_state_
;
57 // The bubbles that are being managed.
58 ScopedVector
<BubbleController
> controllers_
;
60 // The bubbles queued to be shown when possible.
61 ScopedVector
<BubbleController
> show_queue_
;
63 DISALLOW_COPY_AND_ASSIGN(BubbleManager
);
66 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_