| Index: chrome/browser/ui/views/speech_recognition_bubble_views.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/speech_recognition_bubble_views.cc (revision 264642)
|
| +++ chrome/browser/ui/views/speech_recognition_bubble_views.cc (working copy)
|
| @@ -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;
|
|
|
| @@ -310,7 +311,9 @@
|
| }
|
|
|
| // 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,
|
| @@ -325,6 +328,9 @@
|
| virtual void UpdateLayout() OVERRIDE;
|
| virtual void UpdateImage() OVERRIDE;
|
|
|
| + // views::WidgetObserver methods.
|
| + virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
|
| +
|
| private:
|
| Delegate* delegate_;
|
| SpeechRecognitionBubbleView* bubble_;
|
| @@ -344,11 +350,16 @@
|
|
|
| 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)
|
| @@ -378,7 +389,8 @@
|
|
|
| views::BubbleDelegateView::CreateBubble(bubble_);
|
| UpdateLayout();
|
| - }
|
| + bubble_->GetWidget()->AddObserver(this);
|
| + }
|
| bubble_->GetWidget()->Show();
|
| }
|
|
|
|
|