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_win.h" | 5 #include "content/browser/web_contents/web_contents_view_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "content/browser/renderer_host/render_view_host_factory.h" | 9 #include "content/browser/renderer_host/render_view_host_factory.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 #include "content/browser/renderer_host/render_widget_host_view_win.h" | 11 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
12 #include "content/browser/web_contents/interstitial_page_impl.h" | 12 #include "content/browser/web_contents/interstitial_page_impl.h" |
13 #include "content/browser/web_contents/web_contents_drag_win.h" | 13 #include "content/browser/web_contents/web_contents_drag_win.h" |
14 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
15 #include "content/browser/web_contents/web_drag_dest_win.h" | 15 #include "content/browser/web_contents/web_drag_dest_win.h" |
16 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
17 #include "content/public/browser/web_contents_view_delegate.h" | 17 #include "content/public/browser/web_contents_view_delegate.h" |
18 #include "ui/base/win/hidden_window.h" | 18 #include "ui/base/win/hidden_window.h" |
19 #include "ui/base/win/hwnd_subclass.h" | 19 #include "ui/base/win/hwnd_subclass.h" |
20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 #include "ui/snapshot/snapshot.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 WebContentsViewPort* CreateWebContentsView( | 24 WebContentsViewPort* CreateWebContentsView( |
24 WebContentsImpl* web_contents, | 25 WebContentsImpl* web_contents, |
25 WebContentsViewDelegate* delegate, | 26 WebContentsViewDelegate* delegate, |
26 RenderViewHostDelegateView** render_view_host_delegate_view) { | 27 RenderViewHostDelegateView** render_view_host_delegate_view) { |
27 WebContentsViewWin* rv = new WebContentsViewWin(web_contents, delegate); | 28 WebContentsViewWin* rv = new WebContentsViewWin(web_contents, delegate); |
28 *render_view_host_delegate_view = rv; | 29 *render_view_host_delegate_view = rv; |
29 return rv; | 30 return rv; |
30 } | 31 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 283 } |
283 | 284 |
284 void WebContentsViewWin::TakeFocus(bool reverse) { | 285 void WebContentsViewWin::TakeFocus(bool reverse) { |
285 if (web_contents_->GetDelegate() && | 286 if (web_contents_->GetDelegate() && |
286 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 287 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
287 delegate_.get()) { | 288 delegate_.get()) { |
288 delegate_->TakeFocus(reverse); | 289 delegate_->TakeFocus(reverse); |
289 } | 290 } |
290 } | 291 } |
291 | 292 |
| 293 bool WebContentsViewWin::GrabSnapshot(const std::string& format, |
| 294 int quality, |
| 295 double scale, |
| 296 std::vector<uint8>* data) { |
| 297 if (format != "png" || scale != 1) { |
| 298 LOG(ERROR) << "Can only capture non-scaled PNG snapshots."; |
| 299 return false; |
| 300 } |
| 301 return ui::GrabViewSnapshot(GetNativeView(), data, GetViewBounds()); |
| 302 } |
| 303 |
292 void WebContentsViewWin::EndDragging() { | 304 void WebContentsViewWin::EndDragging() { |
293 drag_handler_ = NULL; | 305 drag_handler_ = NULL; |
294 web_contents_->SystemDragEnded(); | 306 web_contents_->SystemDragEnded(); |
295 } | 307 } |
296 | 308 |
297 void WebContentsViewWin::CloseTab() { | 309 void WebContentsViewWin::CloseTab() { |
298 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 310 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
299 rvh->GetDelegate()->Close(rvh); | 311 rvh->GetDelegate()->Close(rvh); |
300 } | 312 } |
301 | 313 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 si.nPage = 10; | 467 si.nPage = 10; |
456 si.nPos = 50; | 468 si.nPos = 50; |
457 | 469 |
458 ::SetScrollInfo(hwnd(), SB_HORZ, &si, FALSE); | 470 ::SetScrollInfo(hwnd(), SB_HORZ, &si, FALSE); |
459 ::SetScrollInfo(hwnd(), SB_VERT, &si, FALSE); | 471 ::SetScrollInfo(hwnd(), SB_VERT, &si, FALSE); |
460 | 472 |
461 return 1; | 473 return 1; |
462 } | 474 } |
463 | 475 |
464 } // namespace content | 476 } // namespace content |
OLD | NEW |