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 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/web_contents/web_contents_view_mac.h" | 7 #import "content/browser/web_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #import "base/mac/scoped_sending_event.h" | 11 #import "base/mac/scoped_sending_event.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #import "base/message_loop/message_pump_mac.h" | 13 #import "base/message_loop/message_pump_mac.h" |
14 #include "content/browser/renderer_host/popup_menu_helper_mac.h" | 14 #include "content/browser/renderer_host/popup_menu_helper_mac.h" |
15 #include "content/browser/renderer_host/render_view_host_factory.h" | 15 #include "content/browser/renderer_host/render_view_host_factory.h" |
16 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
19 #import "content/browser/web_contents/web_drag_dest_mac.h" | 19 #import "content/browser/web_contents/web_drag_dest_mac.h" |
20 #import "content/browser/web_contents/web_drag_source_mac.h" | 20 #import "content/browser/web_contents/web_drag_source_mac.h" |
21 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
22 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
23 #include "content/public/browser/web_contents_view_delegate.h" | 23 #include "content/public/browser/web_contents_view_delegate.h" |
24 #include "skia/ext/skia_utils_mac.h" | 24 #include "skia/ext/skia_utils_mac.h" |
25 #import "third_party/mozilla/NSPasteboard+Utils.h" | 25 #import "third_party/mozilla/NSPasteboard+Utils.h" |
26 #include "ui/base/clipboard/custom_data_helper.h" | 26 #include "ui/base/clipboard/custom_data_helper.h" |
27 #import "ui/base/cocoa/focus_tracker.h" | 27 #import "ui/base/cocoa/focus_tracker.h" |
28 #include "ui/base/dragdrop/cocoa_dnd_util.h" | 28 #include "ui/base/dragdrop/cocoa_dnd_util.h" |
29 #include "ui/gfx/image/image_skia_util_mac.h" | 29 #include "ui/gfx/image/image_skia_util_mac.h" |
| 30 #include "ui/snapshot/snapshot.h" |
30 | 31 |
31 using WebKit::WebDragOperation; | 32 using WebKit::WebDragOperation; |
32 using WebKit::WebDragOperationsMask; | 33 using WebKit::WebDragOperationsMask; |
33 using content::DropData; | 34 using content::DropData; |
34 using content::PopupMenuHelper; | 35 using content::PopupMenuHelper; |
35 using content::RenderViewHostFactory; | 36 using content::RenderViewHostFactory; |
36 using content::RenderWidgetHostView; | 37 using content::RenderWidgetHostView; |
37 using content::RenderWidgetHostViewMac; | 38 using content::RenderWidgetHostViewMac; |
38 using content::WebContents; | 39 using content::WebContents; |
39 using content::WebContentsImpl; | 40 using content::WebContentsImpl; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // This is called when the renderer asks us to take focus back (i.e., it has | 222 // This is called when the renderer asks us to take focus back (i.e., it has |
222 // iterated past the last focusable element on the page). | 223 // iterated past the last focusable element on the page). |
223 void WebContentsViewMac::TakeFocus(bool reverse) { | 224 void WebContentsViewMac::TakeFocus(bool reverse) { |
224 if (reverse) { | 225 if (reverse) { |
225 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; | 226 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; |
226 } else { | 227 } else { |
227 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; | 228 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; |
228 } | 229 } |
229 } | 230 } |
230 | 231 |
| 232 bool WebContentsViewMac::GrabSnapshot(const std::string& format, |
| 233 int quality, |
| 234 double scale, |
| 235 std::vector<uint8>* data) { |
| 236 if (format != "png" || scale != 1) { |
| 237 LOG(ERROR) << "Can only capture non-scaled PNG snapshots."; |
| 238 return false; |
| 239 } |
| 240 return ui::GrabViewSnapshot(GetNativeView(), data, GetViewBounds()); |
| 241 } |
| 242 |
231 void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { | 243 void WebContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { |
232 // Allow delegates to handle the context menu operation first. | 244 // Allow delegates to handle the context menu operation first. |
233 if (web_contents_->GetDelegate() && | 245 if (web_contents_->GetDelegate() && |
234 web_contents_->GetDelegate()->HandleContextMenu(params)) { | 246 web_contents_->GetDelegate()->HandleContextMenu(params)) { |
235 return; | 247 return; |
236 } | 248 } |
237 | 249 |
238 if (delegate()) | 250 if (delegate()) |
239 delegate()->ShowContextMenu(params); | 251 delegate()->ShowContextMenu(params); |
240 else | 252 else |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 [[[notification userInfo] objectForKey:kSelectionDirection] | 567 [[[notification userInfo] objectForKey:kSelectionDirection] |
556 unsignedIntegerValue]; | 568 unsignedIntegerValue]; |
557 if (direction == NSDirectSelection) | 569 if (direction == NSDirectSelection) |
558 return; | 570 return; |
559 | 571 |
560 [self webContents]-> | 572 [self webContents]-> |
561 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 573 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
562 } | 574 } |
563 | 575 |
564 @end | 576 @end |
OLD | NEW |