| Index: chrome/browser/ui/views/speech_recognition_bubble_views.cc
|
| diff --git a/chrome/browser/ui/views/speech_recognition_bubble_views.cc b/chrome/browser/ui/views/speech_recognition_bubble_views.cc
|
| index d22da84f82a2928294e5428cfcf33a346bd665bf..70ef9721f5d1aad55a794d87758f9efffb135caa 100644
|
| --- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc
|
| +++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc
|
| @@ -26,6 +26,7 @@
|
| #include "ui/views/controls/link.h"
|
| #include "ui/views/controls/link_listener.h"
|
| #include "ui/views/layout/layout_constants.h"
|
| +#include "ui/views/widget/widget_observer.h"
|
|
|
| using content::WebContents;
|
|
|
| @@ -327,7 +328,9 @@ void SpeechRecognitionBubbleView::Layout() {
|
| }
|
|
|
| // Implementation of SpeechRecognitionBubble.
|
| -class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase {
|
| +class SpeechRecognitionBubbleImpl
|
| + : public SpeechRecognitionBubbleBase,
|
| + public views::WidgetObserver {
|
| public:
|
| SpeechRecognitionBubbleImpl(int render_process_id, int render_view_id,
|
| Delegate* delegate,
|
| @@ -342,6 +345,9 @@ class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase {
|
| virtual void UpdateLayout() OVERRIDE;
|
| virtual void UpdateImage() OVERRIDE;
|
|
|
| + // views::WidgetObserver methods.
|
| + virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
|
| +
|
| private:
|
| Delegate* delegate_;
|
| SpeechRecognitionBubbleView* bubble_;
|
| @@ -361,11 +367,16 @@ SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl(
|
|
|
| SpeechRecognitionBubbleImpl::~SpeechRecognitionBubbleImpl() {
|
| if (bubble_) {
|
| + bubble_->GetWidget()->RemoveObserver(this);
|
| bubble_->set_notify_delegate_on_activation_change(false);
|
| bubble_->GetWidget()->Close();
|
| }
|
| }
|
|
|
| +void SpeechRecognitionBubbleImpl::OnWidgetDestroying(views::Widget* widget) {
|
| + bubble_ = NULL;
|
| +}
|
| +
|
| void SpeechRecognitionBubbleImpl::Show() {
|
| WebContents* web_contents = GetWebContents();
|
| if (!web_contents)
|
| @@ -395,7 +406,8 @@ void SpeechRecognitionBubbleImpl::Show() {
|
|
|
| views::BubbleDelegateView::CreateBubble(bubble_);
|
| UpdateLayout();
|
| - }
|
| + bubble_->GetWidget()->AddObserver(this);
|
| + }
|
| bubble_->GetWidget()->Show();
|
| }
|
|
|
|
|