| 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" |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" | 11 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 13 #include "chrome/browser/ui/views/toolbar_view.h" | 13 #include "chrome/browser/ui/views/toolbar_view.h" |
| 14 #include "chrome/browser/ui/views/window.h" |
| 14 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
| 15 #include "content/browser/tab_contents/tab_contents_view.h" | 16 #include "content/browser/tab_contents/tab_contents_view.h" |
| 16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 18 #include "media/audio/audio_manager.h" | 19 #include "media/audio/audio_manager.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/views/bubble/bubble_delegate.h" | 22 #include "ui/views/bubble/bubble_delegate.h" |
| 22 #include "ui/views/layout/layout_constants.h" | 23 #include "ui/views/layout/layout_constants.h" |
| 23 #include "views/controls/button/text_button.h" | 24 #include "views/controls/button/text_button.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 337 |
| 337 // Anchor to the location icon view, in case |element_rect| is offscreen. | 338 // Anchor to the location icon view, in case |element_rect| is offscreen. |
| 338 Profile* profile = | 339 Profile* profile = |
| 339 Profile::FromBrowserContext(tab_contents()->browser_context()); | 340 Profile::FromBrowserContext(tab_contents()->browser_context()); |
| 340 Browser* browser = Browser::GetOrCreateTabbedBrowser(profile); | 341 Browser* browser = Browser::GetOrCreateTabbedBrowser(profile); |
| 341 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 342 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 342 views::View* icon = browser_view->GetLocationBarView() ? | 343 views::View* icon = browser_view->GetLocationBarView() ? |
| 343 browser_view->GetLocationBarView()->location_icon_view() : NULL; | 344 browser_view->GetLocationBarView()->location_icon_view() : NULL; |
| 344 bubble_ = new SpeechInputBubbleView(delegate_, icon, element_rect_, | 345 bubble_ = new SpeechInputBubbleView(delegate_, icon, element_rect_, |
| 345 tab_contents()); | 346 tab_contents()); |
| 346 views::BubbleDelegateView::CreateBubble(bubble_); | 347 browser::CreateViewsBubble(bubble_); |
| 347 UpdateLayout(); | 348 UpdateLayout(); |
| 348 bubble_->Show(); | 349 bubble_->Show(); |
| 349 } | 350 } |
| 350 | 351 |
| 351 void SpeechInputBubbleImpl::Hide() { | 352 void SpeechInputBubbleImpl::Hide() { |
| 352 if (bubble_) { | 353 if (bubble_) { |
| 353 // Remove the observer to ignore deactivation when the bubble is explicitly | 354 // Remove the observer to ignore deactivation when the bubble is explicitly |
| 354 // closed, otherwise SpeechInputController::InfoBubbleFocusChanged fails. | 355 // closed, otherwise SpeechInputController::InfoBubbleFocusChanged fails. |
| 355 bubble_->GetWidget()->RemoveObserver(bubble_); | 356 bubble_->GetWidget()->RemoveObserver(bubble_); |
| 356 bubble_->GetWidget()->Close(); | 357 bubble_->GetWidget()->Close(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace | 372 } // namespace |
| 372 | 373 |
| 373 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( | 374 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( |
| 374 TabContents* tab_contents, | 375 TabContents* tab_contents, |
| 375 SpeechInputBubble::Delegate* delegate, | 376 SpeechInputBubble::Delegate* delegate, |
| 376 const gfx::Rect& element_rect) { | 377 const gfx::Rect& element_rect) { |
| 377 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); | 378 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); |
| 378 } | 379 } |
| OLD | NEW |