Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 #include "chrome/browser/media/window_icon_util.h" | |
| 6 | |
| 7 #include "ui/gfx/icon_util.h" | |
| 8 | |
| 9 class WindowIconUtilWin : public WindowIconUtil { | |
| 10 public: | |
| 11 WindowIconUtilWin() {} | |
| 12 gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) override; | |
| 13 }; | |
| 14 | |
| 15 gfx::ImageSkia WindowIconUtilWin::GetWindowIcon(content::DesktopMediaID id) { | |
| 16 HWND hwnd = reinterpret_cast<HWND>(id.id); | |
| 17 | |
| 18 HICON icon_handle = | |
| 19 reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_BIG, 0)); | |
| 20 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.
| |
| 21 icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICON); | |
| 22 if (icon_handle == NULL) | |
| 23 icon_handle = | |
| 24 reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0)); | |
| 25 if (icon_handle == NULL) | |
| 26 icon_handle = | |
| 27 reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL2, 0)); | |
| 28 if (icon_handle == NULL) | |
| 29 icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICONSM); | |
| 30 | |
| 31 if (icon_handle == NULL) | |
| 32 return gfx::ImageSkia(); | |
| 33 | |
| 34 std::unique_ptr<SkBitmap> icon_bitmap( | |
| 35 IconUtil::CreateSkBitmapFromHICON(icon_handle)); | |
| 36 | |
| 37 return gfx::ImageSkia::CreateFrom1xBitmap(*icon_bitmap); | |
| 38 } | |
| 39 | |
| 40 std::unique_ptr<WindowIconUtil> WindowIconUtil::Create( | |
| 41 const webrtc::DesktopCaptureOptions& options) { | |
| 42 return std::unique_ptr<WindowIconUtil>(new WindowIconUtilWin()); | |
| 43 } | |
| OLD | NEW |