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

Unified Diff: chrome/browser/speech/speech_input_bubble_views.cc

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
« no previous file with comments | « chrome/browser/speech/speech_input_bubble_mac.mm ('k') | chrome/browser/speech/speech_input_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/speech_input_bubble_views.cc
diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_input_bubble_views.cc
index 3027da3bf626959f0dd605f07ea20b6e4af80e8f..2140ef47d2012ea47229a648f64ec0e5c4c30e39 100644
--- a/chrome/browser/speech/speech_input_bubble_views.cc
+++ b/chrome/browser/speech/speech_input_bubble_views.cc
@@ -13,10 +13,6 @@
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/views/info_bubble.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
#include "gfx/canvas.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -200,8 +196,7 @@ void ContentView::Layout() {
// Implementation of SpeechInputBubble.
class SpeechInputBubbleImpl
: public SpeechInputBubbleBase,
- public InfoBubbleDelegate,
- public NotificationObserver {
+ public InfoBubbleDelegate {
public:
SpeechInputBubbleImpl(TabContents* tab_contents,
Delegate* delegate,
@@ -220,11 +215,6 @@ class SpeechInputBubbleImpl
// |element_rect| is the html element's bounds in page coordinates.
gfx::Rect GetInfoBubbleTarget(const gfx::Rect& element_rect);
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
// InfoBubbleDelegate
virtual void InfoBubbleClosing(InfoBubble* info_bubble,
bool closed_by_escape);
@@ -234,9 +224,7 @@ class SpeechInputBubbleImpl
private:
Delegate* delegate_;
InfoBubble* info_bubble_;
- TabContents* tab_contents_;
ContentView* bubble_content_;
- NotificationRegistrar registrar_;
gfx::Rect element_rect_;
// Set to true if the object is being destroyed normally instead of the
@@ -249,9 +237,9 @@ class SpeechInputBubbleImpl
SpeechInputBubbleImpl::SpeechInputBubbleImpl(TabContents* tab_contents,
Delegate* delegate,
const gfx::Rect& element_rect)
- : delegate_(delegate),
+ : SpeechInputBubbleBase(tab_contents),
+ delegate_(delegate),
info_bubble_(NULL),
- tab_contents_(tab_contents),
bubble_content_(NULL),
element_rect_(element_rect),
did_invoke_close_(false) {
@@ -265,26 +253,14 @@ SpeechInputBubbleImpl::~SpeechInputBubbleImpl() {
gfx::Rect SpeechInputBubbleImpl::GetInfoBubbleTarget(
const gfx::Rect& element_rect) {
gfx::Rect container_rect;
- tab_contents_->GetContainerBounds(&container_rect);
+ tab_contents()->GetContainerBounds(&container_rect);
return gfx::Rect(
container_rect.x() + element_rect.x() + kBubbleTargetOffsetX,
container_rect.y() + element_rect.y() + element_rect.height(), 1, 1);
}
-void SpeechInputBubbleImpl::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
- delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL);
- } else {
- NOTREACHED() << "Unknown notification";
- }
-}
-
void SpeechInputBubbleImpl::InfoBubbleClosing(InfoBubble* info_bubble,
bool closed_by_escape) {
- registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED,
- Source<TabContents>(tab_contents_));
info_bubble_ = NULL;
bubble_content_ = NULL;
if (!did_invoke_close_)
@@ -307,7 +283,7 @@ void SpeechInputBubbleImpl::Show() {
UpdateLayout();
views::Widget* parent = views::Widget::GetWidgetFromNativeWindow(
- tab_contents_->view()->GetTopLevelNativeWindow());
+ tab_contents()->view()->GetTopLevelNativeWindow());
info_bubble_ = InfoBubble::Show(parent,
GetInfoBubbleTarget(element_rect_),
BubbleBorder::TOP_LEFT, bubble_content_,
@@ -319,9 +295,6 @@ void SpeechInputBubbleImpl::Show() {
// to end so the caller can manage this object's life cycle like a normal
// stack based or member variable object.
info_bubble_->set_fade_away_on_close(false);
-
- registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
- Source<TabContents>(tab_contents_));
}
void SpeechInputBubbleImpl::Hide() {
« no previous file with comments | « chrome/browser/speech/speech_input_bubble_mac.mm ('k') | chrome/browser/speech/speech_input_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698