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

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

Issue 213153002: Fixing a lifetime issue for Speech Recognition Bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests Created 6 years, 9 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
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();
}
« 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