Chromium Code Reviews| Index: chrome/browser/speech/speech_input_bubble_controller.h |
| diff --git a/chrome/browser/speech/speech_input_bubble_controller.h b/chrome/browser/speech/speech_input_bubble_controller.h |
| index 0a2033357fc5c95f4404706cf1c99e7188adb169..2d6e05c9a19f250d5fb37392da62b126911d18ec 100644 |
| --- a/chrome/browser/speech/speech_input_bubble_controller.h |
| +++ b/chrome/browser/speech/speech_input_bubble_controller.h |
| @@ -11,10 +11,12 @@ |
| #include "base/ref_counted.h" |
| #include "base/scoped_ptr.h" |
| #include "chrome/browser/speech/speech_input_bubble.h" |
| +#include "chrome/common/notification_observer.h" |
| namespace gfx { |
| class Rect; |
| } |
| +class NotificationRegistrar; |
| namespace speech_input { |
| @@ -25,7 +27,8 @@ namespace speech_input { |
| // that bubble are reported to the delegate. |
| class SpeechInputBubbleController |
| : public base::RefCountedThreadSafe<SpeechInputBubbleController>, |
| - public SpeechInputBubbleDelegate { |
| + public SpeechInputBubbleDelegate, |
| + public NotificationObserver { |
| public: |
| // All methods of this delegate are called in the IO thread. |
| class Delegate { |
| @@ -73,6 +76,11 @@ class SpeechInputBubbleController |
| virtual void InfoBubbleButtonClicked(SpeechInputBubble::Button button); |
| virtual void InfoBubbleFocusChanged(); |
| + // NotificationObserver implementation. |
| + virtual void Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details); |
| + |
| private: |
| // The various calls received by this object and handled in the UI thread. |
| enum RequestType { |
| @@ -83,6 +91,11 @@ class SpeechInputBubbleController |
| REQUEST_CLOSE, |
| }; |
| + enum ManageSubscriptionAction { |
| + BUBBLE_ADDED, |
| + BUBBLE_REMOVED |
| + }; |
| + |
| void InvokeDelegateButtonClicked(int caller_id, |
| SpeechInputBubble::Button button); |
| void InvokeDelegateFocusChanged(int caller_id); |
| @@ -91,6 +104,19 @@ class SpeechInputBubbleController |
| const string16& text, |
| float volume); |
| + // Called whenever a bubble was added to or removed from the list. If the |
| + // bubble was being added, this method registers for close notifications with |
| + // the TabContents if this was the first bubble for the tab. Similarly if the |
| + // bubble was being removed, this method unregisters from TabContents if this |
| + // was the last bubble associated with that tab. |
| + void UpdateTabContentsSubscription(int caller_id, |
| + ManageSubscriptionAction action); |
| + |
| + // Whether the given bubble (IDed by caller_id) is the only one in our list |
| + // linked to that TabContents. Returns false if there are more such bubbles |
| + // in our list. |
| + bool IsOnlyBubbleForTab(int caller_id); |
|
bulach
2011/01/06 14:31:44
remove?
Satish
2011/01/07 10:57:34
Done.
|
| + |
| // Only accessed in the IO thread. |
| Delegate* delegate_; |
| @@ -102,7 +128,10 @@ class SpeechInputBubbleController |
| // Map of caller-ids to bubble objects. The bubbles are weak pointers owned by |
| // this object and get destroyed by |CloseBubble|. |
| - std::map<int, SpeechInputBubble*> bubbles_; |
| + typedef std::map<int, SpeechInputBubble*> BubbleCallerIdMap; |
| + BubbleCallerIdMap bubbles_; |
| + |
| + scoped_ptr<NotificationRegistrar> registrar_; |
| }; |
| // This typedef is to workaround the issue with certain versions of |