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