OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_PANELS_TASKBAR_WINDOW_THUMBNAILER_WIN_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_TASKBAR_WINDOW_THUMBNAILER_WIN_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/macros.h" | |
12 #include "ui/base/win/hwnd_subclass.h" | |
13 | |
14 class SkBitmap; | |
15 | |
16 class TaskbarWindowThumbnailerDelegateWin { | |
17 public: | |
18 // Returns the list of handles for all windows that are used to construct the | |
19 // thumbnail. If empty list is returned, the snapshot of current window | |
20 // is used. | |
21 virtual std::vector<HWND> GetSnapshotWindowHandles() const = 0; | |
22 }; | |
23 | |
24 // Provides the custom thumbnail and live preview for the window that appears | |
25 // in the taskbar (Windows 7 and later). | |
26 class TaskbarWindowThumbnailerWin : public ui::HWNDMessageFilter { | |
27 public: | |
28 TaskbarWindowThumbnailerWin(HWND hwnd, | |
29 TaskbarWindowThumbnailerDelegateWin* delegate); | |
30 ~TaskbarWindowThumbnailerWin() override; | |
31 | |
32 // Starts using the custom snapshot for live preview. The snapshot is only | |
33 // captured once when the system requests it, so the updates of the panels' | |
34 // content will not be automatically reflected in the thumbnail. | |
35 void Start(); | |
36 | |
37 // Stops providing the custom snapshot for live preview. | |
38 void Stop(); | |
39 | |
40 // Captures the snapshot now instead of when the system requests it. | |
41 void CaptureSnapshot(); | |
42 | |
43 // Invalidates the snapshot such that a fresh copy can be obtained next time | |
44 // when the system requests it. | |
45 void InvalidateSnapshot(); | |
46 | |
47 // Provide the snapshot to the new window. If the snapshot is captured for the | |
48 // old window, it will also be used for the new window. | |
49 void ReplaceWindow(HWND new_hwnd); | |
50 | |
51 private: | |
52 // Overridden from ui::HWNDMessageFilter: | |
53 bool FilterMessage(HWND hwnd, | |
54 UINT message, | |
55 WPARAM w_param, | |
56 LPARAM l_param, | |
57 LRESULT* l_result) override; | |
58 | |
59 // Message handlers. | |
60 bool OnDwmSendIconicThumbnail(int width, int height, LRESULT* l_result); | |
61 bool OnDwmSendIconicLivePreviewBitmap(LRESULT* l_result); | |
62 | |
63 // Captures and returns the screenshot of the window. The caller is | |
64 // responsible to release the returned SkBitmap instance. | |
65 SkBitmap* CaptureWindowImage() const; | |
66 | |
67 HWND hwnd_; | |
68 TaskbarWindowThumbnailerDelegateWin* delegate_; // Weak, owns us. | |
69 std::unique_ptr<SkBitmap> capture_bitmap_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(TaskbarWindowThumbnailerWin); | |
72 }; | |
73 | |
74 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_TASKBAR_WINDOW_THUMBNAILER_WIN_H_ | |
OLD | NEW |