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_CONTROLLER_H_ | 5 #ifndef COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ |
6 #define COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ | 6 #define COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
12 #include "components/bubble/bubble_close_reason.h" | 13 #include "components/bubble/bubble_close_reason.h" |
13 | 14 |
14 class BubbleDelegate; | 15 class BubbleDelegate; |
15 class BubbleManager; | 16 class BubbleManager; |
16 class BubbleUi; | 17 class BubbleUi; |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class RenderFrameHost; | 20 class RenderFrameHost; |
20 } | 21 } |
21 | 22 |
22 // BubbleController is responsible for the lifetime of the delegate and its UI. | 23 // BubbleController is responsible for the lifetime of the delegate and its UI. |
23 class BubbleController : public base::SupportsWeakPtr<BubbleController> { | 24 class BubbleController : public base::SupportsWeakPtr<BubbleController> { |
24 public: | 25 public: |
25 explicit BubbleController(BubbleManager* manager, | 26 explicit BubbleController(BubbleManager* manager, |
26 scoped_ptr<BubbleDelegate> delegate); | 27 std::unique_ptr<BubbleDelegate> delegate); |
27 virtual ~BubbleController(); | 28 virtual ~BubbleController(); |
28 | 29 |
29 // Calls CloseBubble on the associated BubbleManager. | 30 // Calls CloseBubble on the associated BubbleManager. |
30 bool CloseBubble(BubbleCloseReason reason); | 31 bool CloseBubble(BubbleCloseReason reason); |
31 | 32 |
32 // Calls UpdateBubbleUi on the associated BubbleManager. | 33 // Calls UpdateBubbleUi on the associated BubbleManager. |
33 // Returns true if the UI was updated. | 34 // Returns true if the UI was updated. |
34 bool UpdateBubbleUi(); | 35 bool UpdateBubbleUi(); |
35 | 36 |
36 // Used to identify a bubble for collecting metrics. | 37 // Used to identify a bubble for collecting metrics. |
(...skipping 15 matching lines...) Expand all Loading... |
52 // Returns true if the bubble should be closed. | 53 // Returns true if the bubble should be closed. |
53 bool ShouldClose(BubbleCloseReason reason) const; | 54 bool ShouldClose(BubbleCloseReason reason) const; |
54 | 55 |
55 // Returns true if |frame| owns this bubble. | 56 // Returns true if |frame| owns this bubble. |
56 bool OwningFrameIs(const content::RenderFrameHost* frame) const; | 57 bool OwningFrameIs(const content::RenderFrameHost* frame) const; |
57 | 58 |
58 // Cleans up the delegate and its UI. | 59 // Cleans up the delegate and its UI. |
59 void DoClose(BubbleCloseReason reason); | 60 void DoClose(BubbleCloseReason reason); |
60 | 61 |
61 BubbleManager* manager_; | 62 BubbleManager* manager_; |
62 scoped_ptr<BubbleDelegate> delegate_; | 63 std::unique_ptr<BubbleDelegate> delegate_; |
63 scoped_ptr<BubbleUi> bubble_ui_; | 64 std::unique_ptr<BubbleUi> bubble_ui_; |
64 | 65 |
65 // Verify that functions that affect the UI are done on the same thread. | 66 // Verify that functions that affect the UI are done on the same thread. |
66 base::ThreadChecker thread_checker_; | 67 base::ThreadChecker thread_checker_; |
67 | 68 |
68 // To keep track of the amount of time a bubble was visible. | 69 // To keep track of the amount of time a bubble was visible. |
69 base::TimeTicks show_time_; | 70 base::TimeTicks show_time_; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(BubbleController); | 72 DISALLOW_COPY_AND_ASSIGN(BubbleController); |
72 }; | 73 }; |
73 | 74 |
74 #endif // COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ | 75 #endif // COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ |
OLD | NEW |