• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_
7 #pragma once
8 
9 #include "chrome/browser/ui/views/tabs/native_view_photobooth.h"
10 
11 namespace views {
12 class Widget;
13 }
14 
15 ///////////////////////////////////////////////////////////////////////////////
16 // HWNDPhotobooth
17 //
18 //  An object that a HWND "steps into" to have its picture taken. This is used
19 //  to generate a full size screen shot of the contents of a HWND including
20 //  any child windows.
21 //
22 //  Implementation note: This causes the HWND to be re-parented to a mostly
23 //  off-screen layered window.
24 //
25 class NativeViewPhotoboothWin : public NativeViewPhotobooth {
26  public:
27   // Creates the photo booth. Constructs a nearly off-screen window, parents
28   // the HWND, then shows it. The caller is responsible for destroying this
29   // window, since the photo-booth will detach it before it is destroyed.
30   // |canvas| is a canvas to paint the contents into, and dest_bounds is the
31   // target area in |canvas| to which painted contents will be clipped.
32   explicit NativeViewPhotoboothWin(gfx::NativeView initial_view);
33 
34   // Destroys the photo booth window.
35   virtual ~NativeViewPhotoboothWin();
36 
37   // Replaces the view in the photo booth with the specified one.
38   virtual void Replace(gfx::NativeView new_view) OVERRIDE;
39 
40   // Paints the current display image of the window into |canvas|, clipped to
41   // |target_bounds|.
42   virtual void PaintScreenshotIntoCanvas(
43       gfx::Canvas* canvas,
44       const gfx::Rect& target_bounds) OVERRIDE;
45 
46  private:
47   // Creates a mostly off-screen window to contain the HWND to be captured.
48   void CreateCaptureWindow(HWND initial_hwnd);
49 
50   // The nearly off-screen photo-booth layered window used to hold the HWND.
51   views::Widget* capture_window_;
52 
53   // The current HWND being captured.
54   HWND current_hwnd_;
55 
56   DISALLOW_COPY_AND_ASSIGN(NativeViewPhotoboothWin);
57 };
58 
59 #endif  // CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_
60