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

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: TESTS! Created 5 years, 4 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 "components/bubble/bubble_delegate.h"
12
13 class BubbleController;
14
15 typedef base::WeakPtr<BubbleController> BubbleReference;
16
17 // Inherit from BubbleManager to show, update, and close bubbles.
18 // Any class that inherits from BubbleManager should capture any events that
19 // should dismiss a bubble or update its anchor point.
20 // This class assumes that we won't be showing a lot of bubbles simultaneously.
21 // TODO(hcarmona): Handle simultaneous bubbles. http://crbug.com/366937
22 class BubbleManager {
23 public:
24 virtual ~BubbleManager();
25
26 // Shows a specific bubble and returns a reference to it.
27 // This reference should be used through the BubbleManager.
28 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble);
29
30 // Close a specific bubble with a given reason.
msw 2015/08/21 01:48:31 nit: // Notify a specific bubble of an event that
hcarmona 2015/08/25 02:13:37 Done.
31 // Returns true if the bubble was actually closed.
32 bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason);
33
34 // Notify all bubbles that their anchor or parent may have changed.
35 void UpdateAllBubbleAnchors();
36
37 protected:
38 BubbleManager();
39
40 // Notify all bubbles of a potential close event.
msw 2015/08/21 01:48:31 // Notify all bubbles of an event that might trigg
hcarmona 2015/08/25 02:13:37 Done.
41 void CloseAllBubbles(BubbleCloseReason reason);
42
43 private:
44 // Show any bubbles that were added to show_queue_.
msw 2015/08/21 01:48:31 nit: |show_queue_|
hcarmona 2015/08/25 02:13:37 Done.
45 void ShowPendingBubbles();
46
47 // This will be false once the BubbleManager is being destroyed to prevent
msw 2015/08/21 01:48:31 nit: consider something like "A flag used to delay
hcarmona 2015/08/25 02:13:37 Renamed to |manager_state_| and updated the commen
48 // bubbles from adding additional bubbles when they're being cleaned up.
49 bool can_show_bubbles_;
50
51 // The bubbles that are being managed.
52 ScopedVector<BubbleController> controllers_;
53
54 // If a closing bubble needs to show another bubble, it will go here.
msw 2015/08/21 01:48:31 nit: // The bubbles queued to be shown when possib
hcarmona 2015/08/25 02:13:37 Done.
55 scoped_ptr<ScopedVector<BubbleController>> show_queue_;
msw 2015/08/21 01:48:31 Consider keeping this as a ScopedVector that's alw
hcarmona 2015/08/25 02:13:37 Done.
56
57 DISALLOW_COPY_AND_ASSIGN(BubbleManager);
58 };
59
60 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698