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..8ee06b73f9ddca4b4329b48b791b184507f2755a |
| --- /dev/null |
| +++ b/chrome/browser/media/window_icon_util_win.cc |
| @@ -0,0 +1,32 @@ |
| +// 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" |
| + |
| +gfx::ImageSkia WindowIconUtil::GetWindowIcon(content::DesktopMediaID id) { |
| + HWND hwnd = reinterpret_cast<HWND>(id.id); |
|
Sergey Ulanov
2016/08/18 05:38:18
DCHECK that the id.type is TYPE_WINDOW
qiangchen
2016/08/18 20:07:46
Done.
|
| + |
| + HICON icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_BIG, 0)); |
| + if (icon_handle == nullptr) |
|
Sergey Ulanov
2016/08/18 05:38:18
nit: "!icon_handle" instead of "icon_handle == nul
qiangchen
2016/08/18 20:07:46
Done.
|
| + icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICON); |
|
Sergey Ulanov
2016/08/18 05:38:18
Don't use c-style casts. In this case I think you
qiangchen
2016/08/18 20:07:46
Done.
|
| + if (icon_handle == nullptr) |
|
Sergey Ulanov
2016/08/18 05:38:18
add {} for multi-line if statement
https://google.
qiangchen
2016/08/18 20:07:46
Done.
|
| + icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0)); |
| + if (icon_handle == nullptr) |
| + icon_handle = |
| + reinterpret_cast<HICON>(SendMessage(hwnd, WM_GETICON, ICON_SMALL2, 0)); |
| + if (icon_handle == nullptr) |
| + icon_handle = (HICON)GetClassLongPtr(hwnd, GCLP_HICONSM); |
|
Sergey Ulanov
2016/08/18 05:38:18
static_cast<>
qiangchen
2016/08/18 20:07:46
Done.
|
| + |
| + if (icon_handle == nullptr) |
| + return gfx::ImageSkia(); |
| + |
| + std::unique_ptr<SkBitmap> icon_bitmap( |
| + IconUtil::CreateSkBitmapFromHICON(icon_handle)); |
| + |
| + return gfx::ImageSkia::CreateFrom1xBitmap(*icon_bitmap); |
| +} |