OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ | 5 #ifndef COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
6 #define COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ | 6 #define COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "components/bubble/bubble_close_reason.h" | 12 #include "components/bubble/bubble_close_reason.h" |
13 | 13 |
14 class BubbleUi; | 14 class BubbleUi; |
15 | 15 |
16 // Inherit from this class to define a bubble. A bubble is a small transient UI | 16 // Inherit from this class to define a bubble. A bubble is a small transient UI |
17 // surface anchored to a parent window. Most bubbles are dismissed when they | 17 // surface anchored to a parent window. Most bubbles are dismissed when they |
18 // lose focus. | 18 // lose focus. |
19 class BubbleDelegate { | 19 class BubbleDelegate { |
20 public: | 20 public: |
21 BubbleDelegate(); | 21 BubbleDelegate(); |
22 virtual ~BubbleDelegate(); | 22 virtual ~BubbleDelegate(); |
23 | 23 |
24 // Called by BubbleController to notify a bubble of an event that the bubble | 24 // Called by BubbleController to notify a bubble of an event that the bubble |
25 // might want to close on. Return true if the bubble should close for the | 25 // might want to close on. Return true if the bubble should close for the |
26 // specified reason. | 26 // specified reason. If you return false, be sure not to reference frames that |
27 // are destroyed before the bubble. | |
hcarmona
2016/01/11 19:07:22
I'm not 100% happy with this comment because it se
| |
27 virtual bool ShouldClose(BubbleCloseReason reason) const; | 28 virtual bool ShouldClose(BubbleCloseReason reason) const; |
28 | 29 |
29 // Called by BubbleController to notify a bubble that it has closed. | 30 // Called by BubbleController to notify a bubble that it has closed. |
30 virtual void DidClose(); | 31 virtual void DidClose(); |
31 | 32 |
32 // Called by BubbleController to build the UI that will represent this bubble. | 33 // Called by BubbleController to build the UI that will represent this bubble. |
33 // BubbleDelegate should not keep a reference to this newly created UI. | 34 // BubbleDelegate should not keep a reference to this newly created UI. |
34 virtual scoped_ptr<BubbleUi> BuildBubbleUi() = 0; | 35 virtual scoped_ptr<BubbleUi> BuildBubbleUi() = 0; |
35 | 36 |
36 // Called to update an existing UI. This is the same BubbleUi that was created | 37 // Called to update an existing UI. This is the same BubbleUi that was created |
37 // in |BuildBubbleUi|. | 38 // in |BuildBubbleUi|. |
38 // Return true to indicate the UI was updated. | 39 // Return true to indicate the UI was updated. |
39 virtual bool UpdateBubbleUi(BubbleUi* bubble_ui); | 40 virtual bool UpdateBubbleUi(BubbleUi* bubble_ui); |
40 | 41 |
41 // Used to identify a bubble for collecting metrics. | 42 // Used to identify a bubble for collecting metrics. |
42 virtual std::string GetName() const = 0; | 43 virtual std::string GetName() const = 0; |
43 | 44 |
44 private: | 45 private: |
45 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate); |
46 }; | 47 }; |
47 | 48 |
48 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ | 49 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |