| 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_close_reason.h" |
| 12 |
| 13 class BubbleController; |
| 14 class BubbleDelegate; |
| 15 |
| 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 BubbleManager(); |
| 26 virtual ~BubbleManager(); |
| 27 |
| 28 // Shows a specific bubble and returns a reference to it. |
| 29 // This reference should be used through the BubbleManager. |
| 30 BubbleReference ShowBubble(scoped_ptr<BubbleDelegate> bubble); |
| 31 |
| 32 // Notify a bubble of an event that might trigger close. |
| 33 // Returns true if the bubble was actually closed. |
| 34 bool CloseBubble(BubbleReference bubble, BubbleCloseReason reason); |
| 35 |
| 36 // Notify all bubbles of an event that might trigger close. |
| 37 void CloseAllBubbles(BubbleCloseReason reason); |
| 38 |
| 39 // Notify all bubbles that their anchor or parent may have changed. |
| 40 void UpdateAllBubbleAnchors(); |
| 41 |
| 42 private: |
| 43 enum ManagerStates { |
| 44 SHOW_BUBBLES, |
| 45 QUEUE_BUBBLES, |
| 46 NO_MORE_BUBBLES, |
| 47 }; |
| 48 |
| 49 // Show any bubbles that were added to |show_queue_|. |
| 50 void ShowPendingBubbles(); |
| 51 |
| 52 // Determines what happens to a bubble when |ShowBubble| is called. |
| 53 ManagerStates manager_state_; |
| 54 |
| 55 // The bubbles that are being managed. |
| 56 ScopedVector<BubbleController> controllers_; |
| 57 |
| 58 // The bubbles queued to be shown when possible. |
| 59 ScopedVector<BubbleController> show_queue_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(BubbleManager); |
| 62 }; |
| 63 |
| 64 #endif // COMPONENTS_BUBBLE_BUBBLE_MANAGER_H_ |
| OLD | NEW |