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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "components/bubble/bubble_close_reason.h" | 12 #include "components/bubble/bubble_close_reason.h" |
13 | 13 |
14 class BubbleDelegate; | 14 class BubbleDelegate; |
15 class BubbleManager; | 15 class BubbleManager; |
16 class BubbleUi; | 16 class BubbleUi; |
17 | 17 |
| 18 namespace content { |
| 19 class RenderFrameHost; |
| 20 } |
| 21 |
18 // BubbleController is responsible for the lifetime of the delegate and its UI. | 22 // BubbleController is responsible for the lifetime of the delegate and its UI. |
19 class BubbleController : public base::SupportsWeakPtr<BubbleController> { | 23 class BubbleController : public base::SupportsWeakPtr<BubbleController> { |
20 public: | 24 public: |
21 explicit BubbleController(BubbleManager* manager, | 25 explicit BubbleController(BubbleManager* manager, |
22 scoped_ptr<BubbleDelegate> delegate); | 26 scoped_ptr<BubbleDelegate> delegate); |
23 virtual ~BubbleController(); | 27 virtual ~BubbleController(); |
24 | 28 |
25 // Calls CloseBubble on the associated BubbleManager. | 29 // Calls CloseBubble on the associated BubbleManager. |
26 bool CloseBubble(BubbleCloseReason reason); | 30 bool CloseBubble(BubbleCloseReason reason); |
27 | 31 |
(...skipping 13 matching lines...) Expand all Loading... |
41 // Creates and shows the UI for the delegate. | 45 // Creates and shows the UI for the delegate. |
42 void Show(); | 46 void Show(); |
43 | 47 |
44 // Notifies the bubble UI that it should update its anchor location. | 48 // Notifies the bubble UI that it should update its anchor location. |
45 // Important when there's a UI change (ex: fullscreen transition). | 49 // Important when there's a UI change (ex: fullscreen transition). |
46 void UpdateAnchorPosition(); | 50 void UpdateAnchorPosition(); |
47 | 51 |
48 // Returns true if the bubble should be closed. | 52 // Returns true if the bubble should be closed. |
49 bool ShouldClose(BubbleCloseReason reason) const; | 53 bool ShouldClose(BubbleCloseReason reason) const; |
50 | 54 |
| 55 // Returns true if |frame| owns this bubble. |
| 56 bool OwningFrameIs(const content::RenderFrameHost* frame) const; |
| 57 |
51 // Cleans up the delegate and its UI. | 58 // Cleans up the delegate and its UI. |
52 void DoClose(); | 59 void DoClose(); |
53 | 60 |
54 BubbleManager* manager_; | 61 BubbleManager* manager_; |
55 scoped_ptr<BubbleDelegate> delegate_; | 62 scoped_ptr<BubbleDelegate> delegate_; |
56 scoped_ptr<BubbleUi> bubble_ui_; | 63 scoped_ptr<BubbleUi> bubble_ui_; |
57 | 64 |
58 // Verify that functions that affect the UI are done on the same thread. | 65 // Verify that functions that affect the UI are done on the same thread. |
59 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
60 | 67 |
61 // To keep track of the amount of time a bubble was visible. | 68 // To keep track of the amount of time a bubble was visible. |
62 base::TimeTicks show_time_; | 69 base::TimeTicks show_time_; |
63 | 70 |
64 DISALLOW_COPY_AND_ASSIGN(BubbleController); | 71 DISALLOW_COPY_AND_ASSIGN(BubbleController); |
65 }; | 72 }; |
66 | 73 |
67 #endif // COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ | 74 #endif // COMPONENTS_BUBBLE_BUBBLE_CONTROLLER_H_ |
OLD | NEW |