| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 TabContents* tab_contents); | 50 TabContents* tab_contents); |
| 51 | 51 |
| 52 void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode, | 52 void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode, |
| 53 const string16& message_text, | 53 const string16& message_text, |
| 54 const SkBitmap& image); | 54 const SkBitmap& image); |
| 55 void SetImage(const SkBitmap& image); | 55 void SetImage(const SkBitmap& image); |
| 56 | 56 |
| 57 // views::BubbleDelegateView methods. | 57 // views::BubbleDelegateView methods. |
| 58 virtual void OnWidgetActivationChanged(views::Widget* widget, | 58 virtual void OnWidgetActivationChanged(views::Widget* widget, |
| 59 bool active) OVERRIDE; | 59 bool active) OVERRIDE; |
| 60 virtual gfx::Point GetAnchorPoint() OVERRIDE; | 60 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
| 61 virtual void Init() OVERRIDE; | 61 virtual void Init() OVERRIDE; |
| 62 | 62 |
| 63 // views::ButtonListener methods. | 63 // views::ButtonListener methods. |
| 64 virtual void ButtonPressed(views::Button* source, const views::Event& event); | 64 virtual void ButtonPressed(views::Button* source, const views::Event& event); |
| 65 | 65 |
| 66 // views::LinkListener methods. | 66 // views::LinkListener methods. |
| 67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 67 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 68 | 68 |
| 69 // views::View overrides. | 69 // views::View overrides. |
| 70 virtual gfx::Size GetPreferredSize(); | 70 virtual gfx::Size GetPreferredSize(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 set_close_on_deactivate(false); | 104 set_close_on_deactivate(false); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, | 107 void SpeechInputBubbleView::OnWidgetActivationChanged(views::Widget* widget, |
| 108 bool active) { | 108 bool active) { |
| 109 if (widget == GetWidget() && !active) | 109 if (widget == GetWidget() && !active) |
| 110 delegate_->InfoBubbleFocusChanged(); | 110 delegate_->InfoBubbleFocusChanged(); |
| 111 BubbleDelegateView::OnWidgetActivationChanged(widget, active); | 111 BubbleDelegateView::OnWidgetActivationChanged(widget, active); |
| 112 } | 112 } |
| 113 | 113 |
| 114 gfx::Point SpeechInputBubbleView::GetAnchorPoint() { | 114 gfx::Rect SpeechInputBubbleView::GetAnchorRect() { |
| 115 gfx::Rect container_rect; | 115 gfx::Rect container_rect; |
| 116 tab_contents_->GetContainerBounds(&container_rect); | 116 tab_contents_->GetContainerBounds(&container_rect); |
| 117 gfx::Point anchor(container_rect.x() + element_rect_.CenterPoint().x(), | 117 gfx::Point anchor(container_rect.x() + element_rect_.CenterPoint().x(), |
| 118 container_rect.y() + element_rect_.bottom()); | 118 container_rect.y() + element_rect_.bottom()); |
| 119 if (!container_rect.Contains(anchor)) | 119 if (!container_rect.Contains(anchor)) |
| 120 return BubbleDelegateView::GetAnchorPoint(); | 120 return BubbleDelegateView::GetAnchorRect(); |
| 121 return anchor; | 121 return gfx::Rect(anchor, gfx::Size()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void SpeechInputBubbleView::Init() { | 124 void SpeechInputBubbleView::Init() { |
| 125 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 125 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 126 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); | 126 const gfx::Font& font = rb.GetFont(ResourceBundle::MediumFont); |
| 127 | 127 |
| 128 heading_ = new views::Label( | 128 heading_ = new views::Label( |
| 129 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); | 129 l10n_util::GetStringUTF16(IDS_SPEECH_INPUT_BUBBLE_HEADING)); |
| 130 heading_->set_border(views::Border::CreateEmptyBorder( | 130 heading_->set_border(views::Border::CreateEmptyBorder( |
| 131 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); | 131 kBubbleHeadingVertMargin, 0, kBubbleHeadingVertMargin, 0)); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace | 372 } // namespace |
| 373 | 373 |
| 374 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( | 374 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( |
| 375 TabContents* tab_contents, | 375 TabContents* tab_contents, |
| 376 SpeechInputBubble::Delegate* delegate, | 376 SpeechInputBubble::Delegate* delegate, |
| 377 const gfx::Rect& element_rect) { | 377 const gfx::Rect& element_rect) { |
| 378 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); | 378 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); |
| 379 } | 379 } |
| OLD | NEW |