Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/bubble/bubble_manager.h

Issue 1251633002: Add BubbleManager to manage bubbles and ChromeBubbleManager for events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "components/bubble/bubble_close_reason.h"
13
14 class BubbleController;
15 class BubbleDelegate;
16
17 typedef base::WeakPtr<BubbleController> BubbleReference;
18
19 // Inherit from BubbleManager to show, update, and close bubbles.
20 // Any class that inherits from BubbleManager should capture any events that
21 // should dismiss a bubble or update its anchor point.
22 // This class assumes that we won't be showing a lot of bubbles simultaneously.
23 // TODO(hcarmona): Handle simultaneous bubbles. http://crbug.com/366937
24 class BubbleManager {
25 public:
26 BubbleManager();
27 virtual ~BubbleManager();
28
29 // Shows a specific bubble and returns a reference to it.
30 // This reference should be used through the BubbleManager.
31 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble);
32
33 // Notify a bubble of an event that might trigger close.
34 // Returns true if the bubble was actually closed.
35 bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason);
36
37 // Notify all bubbles of an event that might trigger close.
38 void CloseAllBubbles(BubbleCloseReason reason);
39
40 // Notify all bubbles that their anchor or parent may have changed.
41 void UpdateAllBubbleAnchors();
42
43 private:
44 enum ManagerStates {
45 SHOW_BUBBLES,
46 QUEUE_BUBBLES,
47 NO_MORE_BUBBLES,
48 };
49
50 // Show any bubbles that were added to |show_queue_|.
51 void ShowPendingBubbles();
52
53 // Verify that calls that affect the UI are done on the UI thread.
54 base::ThreadChecker ui_thread_checker_;
55
56 // Determines what happens to a bubble when |ShowBubble| is called.
57 ManagerStates manager_state_;
58
59 // The bubbles that are being managed.
60 ScopedVector<BubbleController> controllers_;
61
62 // The bubbles queued to be shown when possible.
63 ScopedVector<BubbleController> show_queue_;
64
65 DISALLOW_COPY_AND_ASSIGN(BubbleManager);
66 };
67
68 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698