Chromium Code Reviews| Index: chrome/browser/media/window_icon_util_win.cc |
| diff --git a/chrome/browser/media/window_icon_util_win.cc b/chrome/browser/media/window_icon_util_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3af6d95846c03bda1a859f051fe2a9a67e5e18b8 |
| --- /dev/null |
| +++ b/chrome/browser/media/window_icon_util_win.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media/window_icon_util.h" |
| + |
| +#include "ui/gfx/icon_util.h" |
| + |
| +class WindowIconUtilWin : public WindowIconUtil { |
| + public: |
| + WindowIconUtilWin() {} |
| + gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) override; |
| +}; |
| + |
| +gfx::ImageSkia WindowIconUtilWin::GetWindowIcon(content::DesktopMediaID id) { |
| + HWND hwnd = reinterpret_cast<HWND>(id.id); |
| + |
| + HICON icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_BIG, 0)); |
| + if (icon_handle == NULL) |
|
Sergey Ulanov
2016/08/15 22:28:39
use nullptr instead of NULL.
qiangchen
2016/08/16 22:29:52
Done.
|
| + icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICON); |
| + if (icon_handle == NULL) |
| + icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0)); |
| + if (icon_handle == NULL) |
| + icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL2, 0)); |
| + if (icon_handle == NULL) |
| + icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICONSM); |
| + |
| + if (icon_handle == NULL) |
| + return gfx::ImageSkia(); |
| + |
| + std::unique_ptr<SkBitmap> icon_bitmap( |
| + IconUtil::CreateSkBitmapFromHICON(icon_handle)); |
| + |
| + return gfx::ImageSkia::CreateFrom1xBitmap(*icon_bitmap); |
| +} |
| + |
| +std::unique_ptr<WindowIconUtil> WindowIconUtil::Create( |
| + const webrtc::DesktopCaptureOptions& options) { |
| + return std::unique_ptr<WindowIconUtil>(new WindowIconUtilWin()); |
| +} |