Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3489)

Unified Diff: chrome/browser/speech/speech_input_bubble_controller.h

Issue 6115001: Listen for tab close notifications and cancel active speech sessions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..04c92b557f1559cee4025114a71f11aba96ffd76 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,14 @@ 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);
+
// Only accessed in the IO thread.
Delegate* delegate_;
@@ -102,7 +123,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
« no previous file with comments | « chrome/browser/speech/speech_input_bubble.cc ('k') | chrome/browser/speech/speech_input_bubble_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698