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

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

Issue 148343008: Speech Recognition API: Safeguarding against page closes during startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 6 years, 10 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
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..70025c5ba4b6ae49b3c7cd1604fc9d1c6c6d4649 100644
--- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc
+++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc
@@ -312,7 +312,10 @@ void SpeechRecognitionBubbleView::Layout() {
// Implementation of SpeechRecognitionBubble.
class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase {
public:
- SpeechRecognitionBubbleImpl(WebContents* web_contents,
+ SpeechRecognitionBubbleImpl(WebContents* test_web_contents,
+ Delegate* delegate,
+ const gfx::Rect& element_rect);
+ SpeechRecognitionBubbleImpl(int render_process_id, int render_view_id,
Delegate* delegate,
const gfx::Rect& element_rect);
virtual ~SpeechRecognitionBubbleImpl();
@@ -334,9 +337,18 @@ class SpeechRecognitionBubbleImpl : public SpeechRecognitionBubbleBase {
};
SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl(
- WebContents* web_contents, Delegate* delegate,
+ WebContents* test_web_contents, Delegate* delegate,
const gfx::Rect& element_rect)
- : SpeechRecognitionBubbleBase(web_contents),
+ : SpeechRecognitionBubbleBase(test_web_contents),
+ delegate_(delegate),
+ bubble_(NULL),
+ element_rect_(element_rect) {
+}
+
+SpeechRecognitionBubbleImpl::SpeechRecognitionBubbleImpl(
+ int render_process_id, int render_view_id, Delegate* delegate,
+ const gfx::Rect& element_rect)
+ : SpeechRecognitionBubbleBase(render_process_id, render_view_id),
delegate_(delegate),
bubble_(NULL),
element_rect_(element_rect) {
@@ -350,11 +362,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 +395,34 @@ void SpeechRecognitionBubbleImpl::Show() {
}
void SpeechRecognitionBubbleImpl::Hide() {
- if (bubble_)
+ if (bubble_ && GetWebContents())
bubble_->GetWidget()->Hide();
}
void SpeechRecognitionBubbleImpl::UpdateLayout() {
- if (bubble_)
+ if (bubble_ && GetWebContents())
bubble_->UpdateLayout(display_mode(), message_text(), icon_image());
}
void SpeechRecognitionBubbleImpl::UpdateImage() {
- if (bubble_)
+ if (bubble_ && GetWebContents())
bubble_->SetImage(icon_image());
}
} // namespace
SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble(
- WebContents* web_contents,
+ WebContents* test_web_contents,
+ SpeechRecognitionBubble::Delegate* delegate,
+ const gfx::Rect& element_rect) {
+ return new SpeechRecognitionBubbleImpl(test_web_contents, delegate,
+ element_rect);
+}
+
+SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble(
+ 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);
}

Powered by Google App Engine
This is Rietveld 408576698