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

Unified Diff: chrome/browser/ui/views/speech_recognition_bubble_views.cc

Issue 240223010: Merge 261737 "Fixing a lifetime issue for Speech Recognition Bubble" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698