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 f7a122c5f24f4c1251d2bcceca1dac7bee0eb3c2..ed09345dfe39182997a6ba54e5339f706a3588c7 100644 |
--- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc |
+++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc |
@@ -312,7 +312,7 @@ void SpeechRecognitionBubbleView::Layout() { |
// Implementation of SpeechRecognitionBubble. |
class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase { |
public: |
- SpeechRecognitionBubbleImpl(WebContents* web_contents, |
+ SpeechRecognitionBubbleImpl(int render_process_id, int render_view_id, |
Delegate* delegate, |
const gfx::Rect& element_rect); |
virtual ~SpeechRecognitionBubbleImpl(); |
@@ -334,9 +334,9 @@ class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase { |
}; |
SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl( |
- WebContents* web_contents, Delegate* delegate, |
+ int render_process_id, int render_view_id, Delegate* delegate, |
const gfx::Rect& element_rect) |
- : SpeechRecognitionBubbleBase(web_contents), |
+ : SpeechRecognitionBubbleBase(render_process_id, render_view_id), |
delegate_(delegate), |
bubble_(NULL), |
element_rect_(element_rect) { |
@@ -350,11 +350,14 @@ SpeechRecognitionBubbleImpl::~SpeechRecognitionBubbleImpl() { |
} |
void SpeechRecognitionBubbleImpl::Show() { |
+ WebContents* web_contents = GetWebContents(); |
+ if (!web_contents) |
+ return; |
+ |
if (!bubble_) { |
views::View* icon = NULL; |
// Anchor to the location bar, in case |element_rect| is offscreen. |
- WebContents* web_contents = GetWebContents(); |
Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
if (browser) { |
BrowserView* browser_view = |
@@ -380,25 +383,29 @@ void SpeechRecognitionBubbleImpl::Show() { |
} |
void SpeechRecognitionBubbleImpl::Hide() { |
- if (bubble_) |
+ WebContents* web_contents = GetWebContents(); |
+ if (bubble_ && web_contents) |
Primiano Tucci (use gerrit)
2014/02/10 21:43:37
nit: You could fit all in one line, without the we
tommi (sloooow) - chröme
2014/02/10 22:32:53
+1 that also avoids calling GetWebContents if bubb
Tommy Widenflycht
2014/02/12 11:35:43
Done.
Tommy Widenflycht
2014/02/12 11:35:43
Done.
|
bubble_->GetWidget()->Hide(); |
} |
void SpeechRecognitionBubbleImpl::UpdateLayout() { |
- if (bubble_) |
+ WebContents* web_contents = GetWebContents(); |
+ if (bubble_ && web_contents) |
bubble_->UpdateLayout(display_mode(), message_text(), icon_image()); |
} |
void SpeechRecognitionBubbleImpl::UpdateImage() { |
- if (bubble_) |
+ WebContents* web_contents = GetWebContents(); |
+ if (bubble_ && web_contents) |
bubble_->SetImage(icon_image()); |
} |
} // namespace |
SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( |
- WebContents* web_contents, |
+ int render_process_id, int render_view_id, |
SpeechRecognitionBubble::Delegate* delegate, |
const gfx::Rect& element_rect) { |
- return new SpeechRecognitionBubbleImpl(web_contents, delegate, element_rect); |
+ return new SpeechRecognitionBubbleImpl(render_process_id, render_view_id, |
+ delegate, element_rect); |
} |