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

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: Apply Feedback 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__
msw 2015/08/13 03:37:23 nit: remove extra trailing underscore here and bel
hcarmona 2015/08/15 02:03:21 Done.
6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_H__
7
8 #include "base/callback_forward.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/weak_ptr.h"
11 #include "components/bubble/bubble_controller.h"
12
13 class BubbleDelegate;
14
15 typedef base::WeakPtr<BubbleController> BubbleReference;
16
17 // Showing bubbles should go through the BubbleManager.
msw 2015/08/13 03:37:23 nit: consider more prescriptive behavior like: "Us
hcarmona 2015/08/15 02:03:20 Done.
18 //
19 // This class assumes that we won't be showing a lot of bubbles simultaneously.
20 // If this assumption ever stops being true, please file a bug against whatever
msw 2015/08/13 03:37:23 I already filed http://crbug.com/366937 a long tim
hcarmona 2015/08/15 02:03:20 Done.
21 // is bombarding the user with many bubbles at the same time.
22 class BubbleManager {
23 public:
24 virtual ~BubbleManager();
25
26 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble);
msw 2015/08/13 03:37:23 nit: explicitly include the scoped_ptr header too.
hcarmona 2015/08/15 02:03:20 Done.
27 void CloseBubble(BubbleReference bubble);
msw 2015/08/13 03:37:23 q: should this class offer a HideBubble function t
groby-ooo-7-16 2015/08/13 18:44:38 I don't think it should. It's bad enough that Perm
msw 2015/08/13 19:18:58 I agree, I hope we can eliminate hiding altogether
28 bool ShouldUpdateBubble(BubbleReference bubble);
msw 2015/08/13 03:37:23 nit: ditto on explanatory comments, especially whe
29 void UpdateBubble(BubbleReference bubble);
30
31 protected:
32 enum CloseOption {
33 ALLOW_HIDE,
34 FORCE_CLOSE,
35 };
36
37 // This class should be subclassed to hook into all the appropriate events.
msw 2015/08/13 03:37:23 Should you just omit a default constructor if this
hcarmona 2015/08/15 02:03:20 This class is "complex", so it needs a constructor
38 BubbleManager();
39
40 void MassUpdateBubbles(
msw 2015/08/13 03:37:23 nit: consider renaming this UpdateMatchingBubbles
hcarmona 2015/08/15 02:03:20 Acknowledged.
41 void* context,
42 base::Callback<void(base::WeakPtr<BubbleController>)> callback);
43
44 // For mass updating of bubbles:
msw 2015/08/13 03:37:23 Did you mean for this comment to go with MassUpdat
hcarmona 2015/08/15 02:03:20 Yes, but no longer necessary.
45 void CloseMatchingBubbles(void* context,
46 CloseOption close_option,
msw 2015/08/13 03:37:23 nit: a simple |allow_hide| or |force_close| bool (
hcarmona 2015/08/13 20:50:35 Using the enum makes it more clear what will happe
msw 2015/08/13 21:41:37 Acknowledged.
47 BubbleCloseReason reason);
48
49 // Override and call Show on the controller when it's convenient.
50 void ShowBubbleUI(base::WeakPtr<BubbleController> controller);
51 void UpdateBubbleUI(base::WeakPtr<BubbleController> controller);
52
53 private:
54 ScopedVector<BubbleController> controllers_;
55
56 DISALLOW_COPY_AND_ASSIGN(BubbleManager);
57 };
58
59 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698