OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_recognition_bubble.h" | 5 #include "chrome/browser/speech/speech_recognition_bubble.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 11 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
13 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 13 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
14 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 14 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
16 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
17 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 17 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
18 #include "content/public/browser/resource_context.h" | 18 #include "content/public/browser/resource_context.h" |
19 #include "content/public/browser/speech_recognition_manager.h" | 19 #include "content/public/browser/speech_recognition_manager.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_view.h" |
21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
23 #include "ui/base/gtk/gtk_hig_constants.h" | 24 #include "ui/base/gtk/gtk_hig_constants.h" |
24 #include "ui/base/gtk/owned_widget_gtk.h" | 25 #include "ui/base/gtk/owned_widget_gtk.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/gfx/gtk_util.h" | 28 #include "ui/gfx/gtk_util.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 | 30 |
30 using content::WebContents; | 31 using content::WebContents; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 g_signal_connect(try_again_button_, "clicked", | 170 g_signal_connect(try_again_button_, "clicked", |
170 G_CALLBACK(&OnTryAgainClickedThunk), this); | 171 G_CALLBACK(&OnTryAgainClickedThunk), this); |
171 | 172 |
172 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0); | 173 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0); |
173 gtk_alignment_set_padding(GTK_ALIGNMENT(content), | 174 gtk_alignment_set_padding(GTK_ALIGNMENT(content), |
174 kBubbleControlVerticalSpacing, kBubbleControlVerticalSpacing, | 175 kBubbleControlVerticalSpacing, kBubbleControlVerticalSpacing, |
175 kBubbleControlHorizontalSpacing, kBubbleControlHorizontalSpacing); | 176 kBubbleControlHorizontalSpacing, kBubbleControlHorizontalSpacing); |
176 gtk_container_add(GTK_CONTAINER(content), vbox); | 177 gtk_container_add(GTK_CONTAINER(content), vbox); |
177 | 178 |
178 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); | 179 GtkThemeService* theme_provider = GtkThemeService::GetFrom(profile); |
179 GtkWidget* reference_widget = GetWebContents()->GetNativeView(); | 180 GtkWidget* reference_widget = GetWebContents()->GetView()->GetNativeView(); |
180 gfx::Rect container_rect; | 181 gfx::Rect container_rect; |
181 GetWebContents()->GetContainerBounds(&container_rect); | 182 GetWebContents()->GetView()->GetContainerBounds(&container_rect); |
182 gfx::Rect target_rect(element_rect_.right() - kBubbleTargetOffsetX, | 183 gfx::Rect target_rect(element_rect_.right() - kBubbleTargetOffsetX, |
183 element_rect_.bottom(), 1, 1); | 184 element_rect_.bottom(), 1, 1); |
184 | 185 |
185 if (target_rect.x() < 0 || target_rect.y() < 0 || | 186 if (target_rect.x() < 0 || target_rect.y() < 0 || |
186 target_rect.x() > container_rect.width() || | 187 target_rect.x() > container_rect.width() || |
187 target_rect.y() > container_rect.height()) { | 188 target_rect.y() > container_rect.height()) { |
188 // Target is not in screen view, so point to wrench. | 189 // Target is not in screen view, so point to wrench. |
189 Browser* browser = chrome::FindBrowserWithWebContents(GetWebContents()); | 190 Browser* browser = chrome::FindBrowserWithWebContents(GetWebContents()); |
190 BrowserWindowGtk* browser_window = | 191 BrowserWindowGtk* browser_window = |
191 BrowserWindowGtk::GetBrowserWindowForNativeWindow( | 192 BrowserWindowGtk::GetBrowserWindowForNativeWindow( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 291 } |
291 | 292 |
292 } // namespace | 293 } // namespace |
293 | 294 |
294 SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( | 295 SpeechRecognitionBubble* SpeechRecognitionBubble::CreateNativeBubble( |
295 WebContents* web_contents, | 296 WebContents* web_contents, |
296 Delegate* delegate, | 297 Delegate* delegate, |
297 const gfx::Rect& element_rect) { | 298 const gfx::Rect& element_rect) { |
298 return new SpeechRecognitionBubbleGtk(web_contents, delegate, element_rect); | 299 return new SpeechRecognitionBubbleGtk(web_contents, delegate, element_rect); |
299 } | 300 } |
OLD | NEW |