15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/tabs/native_view_photobooth.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace views { 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Widget; 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// HWNDPhotobooth 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// An object that a HWND "steps into" to have its picture taken. This is used 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to generate a full size screen shot of the contents of a HWND including 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// any child windows. 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Implementation note: This causes the HWND to be re-parented to a mostly 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// off-screen layered window. 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class NativeViewPhotoboothWin : public NativeViewPhotobooth { 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates the photo booth. Constructs a nearly off-screen window, parents 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the HWND, then shows it. The caller is responsible for destroying this 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // window, since the photo-booth will detach it before it is destroyed. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |canvas| is a canvas to paint the contents into, and dest_bounds is the 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // target area in |canvas| to which painted contents will be clipped. 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit NativeViewPhotoboothWin(gfx::NativeView initial_view); 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Destroys the photo booth window. 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~NativeViewPhotoboothWin(); 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Replaces the view in the photo booth with the specified one. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Replace(gfx::NativeView new_view) OVERRIDE; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Paints the current display image of the window into |canvas|, clipped to 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |target_bounds|. 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void PaintScreenshotIntoCanvas( 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Canvas* canvas, 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& target_bounds) OVERRIDE; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates a mostly off-screen window to contain the HWND to be captured. 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CreateCaptureWindow(HWND initial_hwnd); 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The nearly off-screen photo-booth layered window used to hold the HWND. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::Widget* capture_window_; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The current HWND being captured. 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) HWND current_hwnd_; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(NativeViewPhotoboothWin); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_VIEWS_TABS_NATIVE_VIEW_PHOTOBOOTH_WIN_H_ 59