| OLD | NEW |
| (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_ |
| 6 #define COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/bubble/bubble_delegate.h" |
| 12 |
| 13 class BubbleController; |
| 14 |
| 15 // TODO(hcarmona): Don't expose BubbleController functions to users of this API. |
| 16 typedef base::WeakPtr<BubbleController> BubbleReference; |
| 17 |
| 18 // Inherit from BubbleManager to show, update, and close bubbles. |
| 19 // Any class that inherits from BubbleManager should capture any events that |
| 20 // should dismiss a bubble or update its anchor point. |
| 21 // This class assumes that we won't be showing a lot of bubbles simultaneously. |
| 22 // TODO(hcarmona): Handle simultaneous bubbles. http://crbug.com/366937 |
| 23 class BubbleManager { |
| 24 public: |
| 25 virtual ~BubbleManager(); |
| 26 |
| 27 // Shows a specific bubble and returns a reference to it. |
| 28 // This reference should be used through the BubbleManager. |
| 29 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble); |
| 30 |
| 31 // Close a specific bubble with a given reason. |
| 32 // Returns true if the bubble was actually closed. |
| 33 bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason); |
| 34 |
| 35 // Notify all bubbles that their anchor or parent may have changed. |
| 36 void UpdateAllBubbleAnchors(); |
| 37 |
| 38 protected: |
| 39 BubbleManager(); |
| 40 |
| 41 // Notify all bubbles of a potential close event. |
| 42 void CloseAllBubbles(BubbleCloseReason reason); |
| 43 |
| 44 // Show a specific bubble. |
| 45 virtual void ShowBubbleUI(base::WeakPtr<BubbleController> controller); |
| 46 |
| 47 // Close a specific bubble. |
| 48 virtual bool ShouldClose(base::WeakPtr<BubbleController> controller, |
| 49 BubbleCloseReason reason); |
| 50 |
| 51 // Update a specific bubble's anchor position. |
| 52 virtual void UpdateAnchorPosition(base::WeakPtr<BubbleController> controller); |
| 53 |
| 54 private: |
| 55 ScopedVector<BubbleController> controllers_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(BubbleManager); |
| 58 }; |
| 59 |
| 60 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_ |
| OLD | NEW |