| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/views/frame/taskbar_decorator_win.h" | 5 #include "chrome/browser/ui/views/frame/taskbar_decorator_win.h" |
| 6 | 6 |
| 7 #include <objbase.h> | 7 #include <objbase.h> |
| 8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/task_scheduler/post_task.h" | 12 #include "base/task_scheduler/post_task.h" |
| 13 #include "base/win/scoped_comptr.h" | 13 #include "base/win/scoped_comptr.h" |
| 14 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
| 15 #include "base/win/windows_version.h" | |
| 16 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 15 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 17 #include "skia/ext/image_operations.h" | 16 #include "skia/ext/image_operations.h" |
| 18 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
| 19 #include "ui/gfx/icon_util.h" | 18 #include "ui/gfx/icon_util.h" |
| 20 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 21 #include "ui/views/win/hwnd_util.h" | 20 #include "ui/views/win/hwnd_util.h" |
| 22 | 21 |
| 23 namespace chrome { | 22 namespace chrome { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 icon = IconUtil::CreateHICONFromSkBitmap(offscreen_bitmap); | 61 icon = IconUtil::CreateHICONFromSkBitmap(offscreen_bitmap); |
| 63 if (!icon.is_valid()) | 62 if (!icon.is_valid()) |
| 64 return; | 63 return; |
| 65 } | 64 } |
| 66 taskbar->SetOverlayIcon(hwnd, icon.get(), L""); | 65 taskbar->SetOverlayIcon(hwnd, icon.get(), L""); |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace | 68 } // namespace |
| 70 | 69 |
| 71 void DrawTaskbarDecoration(gfx::NativeWindow window, const gfx::Image* image) { | 70 void DrawTaskbarDecoration(gfx::NativeWindow window, const gfx::Image* image) { |
| 72 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
| 73 return; | |
| 74 | |
| 75 HWND hwnd = views::HWNDForNativeWindow(window); | 71 HWND hwnd = views::HWNDForNativeWindow(window); |
| 76 | 72 |
| 77 // SetOverlayIcon() does nothing if the window is not visible so testing here | 73 // SetOverlayIcon() does nothing if the window is not visible so testing here |
| 78 // avoids all the wasted effort of the image resizing. | 74 // avoids all the wasted effort of the image resizing. |
| 79 if (!::IsWindowVisible(hwnd)) | 75 if (!::IsWindowVisible(hwnd)) |
| 80 return; | 76 return; |
| 81 | 77 |
| 82 // Copy the image since we're going to use it on a separate thread and | 78 // Copy the image since we're going to use it on a separate thread and |
| 83 // gfx::Image isn't thread safe. | 79 // gfx::Image isn't thread safe. |
| 84 std::unique_ptr<SkBitmap> bitmap; | 80 std::unique_ptr<SkBitmap> bitmap; |
| 85 if (image) { | 81 if (image) { |
| 86 bitmap.reset(new SkBitmap( | 82 bitmap.reset(new SkBitmap( |
| 87 profiles::GetAvatarIconAsSquare(*image->ToSkBitmap(), 1))); | 83 profiles::GetAvatarIconAsSquare(*image->ToSkBitmap(), 1))); |
| 88 } | 84 } |
| 89 // TODO(robliao): Annotate this task with .WithCOM() once supported. | 85 // TODO(robliao): Annotate this task with .WithCOM() once supported. |
| 90 // https://crbug.com/662122 | 86 // https://crbug.com/662122 |
| 91 base::PostTaskWithTraits( | 87 base::PostTaskWithTraits( |
| 92 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, | 88 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
| 93 base::Bind(&SetOverlayIcon, hwnd, base::Passed(&bitmap))); | 89 base::Bind(&SetOverlayIcon, hwnd, base::Passed(&bitmap))); |
| 94 } | 90 } |
| 95 | 91 |
| 96 } // namespace chrome | 92 } // namespace chrome |
| OLD | NEW |