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 <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.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 namespace content { | 16 namespace content { |
17 class RenderFrameHost; | 17 class RenderFrameHost; |
18 } | 18 } |
19 | 19 |
20 // Inherit from this class to define a bubble. A bubble is a small transient UI | 20 // Inherit from this class to define a bubble. A bubble is a small transient UI |
21 // surface anchored to a parent window. Most bubbles are dismissed when they | 21 // surface anchored to a parent window. Most bubbles are dismissed when they |
22 // lose focus. | 22 // lose focus. |
23 class BubbleDelegate { | 23 class BubbleDelegate { |
24 public: | 24 public: |
25 BubbleDelegate(); | 25 BubbleDelegate(); |
26 virtual ~BubbleDelegate(); | 26 virtual ~BubbleDelegate(); |
27 | 27 |
28 // Called by BubbleController to notify a bubble of an event that the bubble | 28 // Called by BubbleController to notify a bubble of an event that the bubble |
29 // might want to close on. Return true if the bubble should close for the | 29 // might want to close on. Return true if the bubble should close for the |
30 // specified reason. | 30 // specified reason. |
31 virtual bool ShouldClose(BubbleCloseReason reason) const; | 31 virtual bool ShouldClose(BubbleCloseReason reason) const; |
32 | 32 |
33 // Called by BubbleController to notify a bubble that it has closed. | 33 // Called by BubbleController to notify a bubble that it has closed. |
34 virtual void DidClose(BubbleCloseReason reason); | 34 virtual void DidClose(BubbleCloseReason reason); |
35 | 35 |
36 // Called by BubbleController to build the UI that will represent this bubble. | 36 // Called by BubbleController to build the UI that will represent this bubble. |
37 // BubbleDelegate should not keep a reference to this newly created UI. | 37 // BubbleDelegate should not keep a reference to this newly created UI. |
38 virtual scoped_ptr<BubbleUi> BuildBubbleUi() = 0; | 38 virtual std::unique_ptr<BubbleUi> BuildBubbleUi() = 0; |
39 | 39 |
40 // Called to update an existing UI. This is the same BubbleUi that was created | 40 // Called to update an existing UI. This is the same BubbleUi that was created |
41 // in |BuildBubbleUi|. | 41 // in |BuildBubbleUi|. |
42 // Return true to indicate the UI was updated. | 42 // Return true to indicate the UI was updated. |
43 virtual bool UpdateBubbleUi(BubbleUi* bubble_ui); | 43 virtual bool UpdateBubbleUi(BubbleUi* bubble_ui); |
44 | 44 |
45 // Used to identify a bubble for collecting metrics. | 45 // Used to identify a bubble for collecting metrics. |
46 virtual std::string GetName() const = 0; | 46 virtual std::string GetName() const = 0; |
47 | 47 |
48 // If this returns non-null, the bubble will be closed when the returned frame | 48 // If this returns non-null, the bubble will be closed when the returned frame |
49 // is destroyed. | 49 // is destroyed. |
50 virtual const content::RenderFrameHost* OwningFrame() const = 0; | 50 virtual const content::RenderFrameHost* OwningFrame() const = 0; |
51 | 51 |
52 private: | 52 private: |
53 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate); | 53 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate); |
54 }; | 54 }; |
55 | 55 |
56 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ | 56 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |