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

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: gn nit 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
« no previous file with comments | « components/bubble/bubble_delegate.cc ('k') | components/bubble/bubble_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Should be instantiated on the UI thread.
27 BubbleManager();
28 virtual ~BubbleManager();
29
30 // Shows a specific bubble and returns a reference to it.
31 // This reference should be used through the BubbleManager.
32 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble);
33
34 // Notify a bubble of an event that might trigger close.
35 // Returns true if the bubble was actually closed.
36 bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason);
37
38 // Notify all bubbles of an event that might trigger close.
39 void CloseAllBubbles(BubbleCloseReason reason);
40
41 // Notify all bubbles that their anchor or parent may have changed.
42 void UpdateAllBubbleAnchors();
43
44 private:
45 enum ManagerStates {
46 SHOW_BUBBLES,
47 QUEUE_BUBBLES,
48 NO_MORE_BUBBLES,
49 };
50
51 // Show any bubbles that were added to |show_queue_|.
52 void ShowPendingBubbles();
53
54 // Verify that functions that affect the UI are done on the same thread.
55 base::ThreadChecker thread_checker_;
56
57 // Determines what happens to a bubble when |ShowBubble| is called.
58 ManagerStates manager_state_;
59
60 // The bubbles that are being managed.
61 ScopedVector<BubbleController> controllers_;
62
63 // The bubbles queued to be shown when possible.
64 ScopedVector<BubbleController> show_queue_;
65
66 DISALLOW_COPY_AND_ASSIGN(BubbleManager);
67 };
68
69 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
OLDNEW
« no previous file with comments | « components/bubble/bubble_delegate.cc ('k') | components/bubble/bubble_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698