| 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_DELEGATE_H_ |
| 6 #define COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 |
| 10 class BubbleUI; |
| 11 |
| 12 // List of reasons why a bubble might close. These correspond to various events |
| 13 // from the UI. Not all platforms will receive all events. |
| 14 enum BubbleCloseReason { |
| 15 // Bubble was closed without any user interaction. |
| 16 BUBBLE_CLOSE_IGNORE, |
| 17 |
| 18 // User did not interact with the bubble, but changed tab. |
| 19 BUBBLE_CLOSE_TABSWITCH, |
| 20 |
| 21 // User did not interact with the bubble, but changed tab. |
| 22 BUBBLE_CLOSE_TABDETACHED, |
| 23 |
| 24 // User dismissed the bubble. (ESC, close, etc.) |
| 25 BUBBLE_CLOSE_USER_DISMISSED, |
| 26 |
| 27 // There has been a navigation event. (Link, URL typed, refresh, etc.) |
| 28 BUBBLE_CLOSE_NAVIGATION, |
| 29 |
| 30 // Window has entered fullscreen mode. Will also be called for immersive |
| 31 // fullscreen. |
| 32 BUBBLE_CLOSE_FULLSCREEN, |
| 33 |
| 34 // User selected the "Accept" option in a bubble. |
| 35 BUBBLE_CLOSE_ACCEPT, |
| 36 |
| 37 // User selected the "Cancel" option in a bubble. |
| 38 BUBBLE_CLOSE_CANCEL, |
| 39 |
| 40 // The bubble WILL be closed regardless of return value for |ShouldClose|. |
| 41 // Ex: BubbleManager is being destroyed. |
| 42 BUBBLE_CLOSE_FORCED, |
| 43 }; |
| 44 |
| 45 // Inherit from this class to define a bubble. A bubble is a small piece of UI |
| 46 // that's intended to ask a user a question. Most bubbles are dismissed when |
| 47 // they lose focus. |
| 48 class BubbleDelegate { |
| 49 public: |
| 50 BubbleDelegate() {} |
| 51 virtual ~BubbleDelegate() {} |
| 52 |
| 53 // Called by BubbleController to notify a bubble of an event that the bubble |
| 54 // might want to close on. Return true if the bubble should close for the |
| 55 // specified reason. |
| 56 // IMPORTANT: DO NOT SHOW OR HIDE OTHER BUBBLES IN THIS FUNCTION. |
| 57 // If closing this bubble needs to chain with other bubbles, please chain in |
| 58 // the destructor. |
| 59 virtual bool ShouldClose(BubbleCloseReason reason); |
| 60 |
| 61 // Called by BubbleController to build the UI that will represent this bubble. |
| 62 // BubbleDelegate should not keep a reference to this newly created UI. |
| 63 virtual scoped_ptr<BubbleUI> BuildBubbleUI() = 0; |
| 64 |
| 65 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(BubbleDelegate); |
| 67 }; |
| 68 |
| 69 #endif // COMPONENTS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |