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 "content/browser/web_contents/web_contents_view_gtk.h" | 5 #include "content/browser/web_contents/web_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/browser/web_contents/web_drag_dest_gtk.h" | 21 #include "content/browser/web_contents/web_drag_dest_gtk.h" |
22 #include "content/browser/web_contents/web_drag_source_gtk.h" | 22 #include "content/browser/web_contents/web_drag_source_gtk.h" |
23 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
24 #include "content/public/browser/web_contents_view_delegate.h" | 24 #include "content/public/browser/web_contents_view_delegate.h" |
25 #include "content/public/common/drop_data.h" | 25 #include "content/public/common/drop_data.h" |
26 #include "ui/base/gtk/gtk_expanded_container.h" | 26 #include "ui/base/gtk/gtk_expanded_container.h" |
27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
28 #include "ui/gfx/point.h" | 28 #include "ui/gfx/point.h" |
29 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
30 #include "ui/gfx/size.h" | 30 #include "ui/gfx/size.h" |
| 31 #include "ui/snapshot/snapshot.h" |
31 | 32 |
32 using WebKit::WebDragOperation; | 33 using WebKit::WebDragOperation; |
33 using WebKit::WebDragOperationsMask; | 34 using WebKit::WebDragOperationsMask; |
34 | 35 |
35 namespace content { | 36 namespace content { |
36 namespace { | 37 namespace { |
37 | 38 |
38 // Called when the mouse leaves the widget. We notify our delegate. | 39 // Called when the mouse leaves the widget. We notify our delegate. |
39 gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, | 40 gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, |
40 WebContentsImpl* web_contents) { | 41 WebContentsImpl* web_contents) { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 void WebContentsViewGtk::TakeFocus(bool reverse) { | 295 void WebContentsViewGtk::TakeFocus(bool reverse) { |
295 if (!web_contents_->GetDelegate()) | 296 if (!web_contents_->GetDelegate()) |
296 return; | 297 return; |
297 if (!web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 298 if (!web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
298 GetTopLevelNativeWindow()) { | 299 GetTopLevelNativeWindow()) { |
299 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), | 300 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), |
300 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); | 301 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
| 305 bool WebContentsViewGtk::GrabSnapshot(const std::string& format, |
| 306 int quality, |
| 307 double scale, |
| 308 std::vector<uint8>* data) { |
| 309 if (format != "png" || scale != 1) { |
| 310 LOG(ERROR) << "Can only capture non-scaled PNG snapshots."; |
| 311 return false; |
| 312 } |
| 313 return ui::GrabViewSnapshot(GetNativeView(), data, GetViewBounds()); |
| 314 } |
| 315 |
304 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { | 316 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { |
305 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget); | 317 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget); |
306 } | 318 } |
307 | 319 |
308 void WebContentsViewGtk::UpdateDragDest(RenderViewHost* host) { | 320 void WebContentsViewGtk::UpdateDragDest(RenderViewHost* host) { |
309 gfx::NativeView content_view = host->GetView()->GetNativeView(); | 321 gfx::NativeView content_view = host->GetView()->GetNativeView(); |
310 | 322 |
311 // If the host is already used by the drag_dest_, there's no point in deleting | 323 // If the host is already used by the drag_dest_, there's no point in deleting |
312 // the old one to create an identical copy. | 324 // the old one to create an identical copy. |
313 if (drag_dest_.get() && drag_dest_->widget() == content_view) | 325 if (drag_dest_.get() && drag_dest_->widget() == content_view) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 // We manually tell our RWHV to resize the renderer content. This avoids | 421 // We manually tell our RWHV to resize the renderer content. This avoids |
410 // spurious resizes from GTK+. | 422 // spurious resizes from GTK+. |
411 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 423 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
412 if (rwhv) | 424 if (rwhv) |
413 rwhv->SetSize(size); | 425 rwhv->SetSize(size); |
414 if (web_contents_->GetInterstitialPage()) | 426 if (web_contents_->GetInterstitialPage()) |
415 web_contents_->GetInterstitialPage()->SetSize(size); | 427 web_contents_->GetInterstitialPage()->SetSize(size); |
416 } | 428 } |
417 | 429 |
418 } // namespace content | 430 } // namespace content |
OLD | NEW |