| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/speech/speech_input_bubble.h" | 5 #include "chrome/browser/speech/speech_input_bubble.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, | 105 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, |
| 106 bool active) { | 106 bool active) { |
| 107 if (widget == GetWidget() && !active) | 107 if (widget == GetWidget() && !active) |
| 108 delegate_->InfoBubbleFocusChanged(); | 108 delegate_->InfoBubbleFocusChanged(); |
| 109 BubbleDelegateView::OnWidgetActivationChanged(widget, active); | 109 BubbleDelegateView::OnWidgetActivationChanged(widget, active); |
| 110 } | 110 } |
| 111 | 111 |
| 112 gfx::Rect SpeechInputBubbleView::GetAnchorRect() { | 112 gfx::Rect SpeechInputBubbleView::GetAnchorRect() { |
| 113 gfx::Rect container_rect; | 113 gfx::Rect container_rect; |
| 114 tab_contents_->GetContainerBounds(&container_rect); | 114 tab_contents_->GetContainerBounds(&container_rect); |
| 115 gfx::Point anchor(container_rect.x() + element_rect_.CenterPoint().x(), | 115 gfx::Rect anchor(element_rect_); |
| 116 container_rect.y() + element_rect_.bottom()); | 116 anchor.Offset(container_rect.origin()); |
| 117 if (!container_rect.Contains(anchor)) | 117 if (!container_rect.Intersects(anchor)) |
| 118 return BubbleDelegateView::GetAnchorRect(); | 118 return BubbleDelegateView::GetAnchorRect(); |
| 119 return gfx::Rect(anchor, gfx::Size()); | 119 return anchor; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void SpeechInputBubbleView::Init() { | 122 void SpeechInputBubbleView::Init() { |
| 123 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 123 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 124 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); | 124 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); |
| 125 | 125 |
| 126 heading_ = new views::Label( | 126 heading_ = new views::Label( |
| 127 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); | 127 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); |
| 128 heading_->set_border(views::Border::CreateEmptyBorder( | 128 heading_->set_border(views::Border::CreateEmptyBorder( |
| 129 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); | 129 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 369 } |
| 370 | 370 |
| 371 } // namespace | 371 } // namespace |
| 372 | 372 |
| 373 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( | 373 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( |
| 374 TabContents* tab_contents, | 374 TabContents* tab_contents, |
| 375 SpeechInputBubble::Delegate* delegate, | 375 SpeechInputBubble::Delegate* delegate, |
| 376 const gfx::Rect& element_rect) { | 376 const gfx::Rect& element_rect) { |
| 377 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); | 377 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); |
| 378 } | 378 } |
| OLD | NEW |