Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/ui/views/frame/taskbar_decorator_win.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 5 #include "chrome/browser/ui/views/frame/taskbar_decorator.h"
6 6
7 #include <shobjidl.h> 7 #include <shobjidl.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace { 24 namespace {
25 25
26 // Responsible for invoking TaskbarList::SetOverlayIcon(). The call to 26 // Responsible for invoking TaskbarList::SetOverlayIcon(). The call to
27 // TaskbarList::SetOverlayIcon() runs a nested message loop that proves 27 // TaskbarList::SetOverlayIcon() runs a nested message loop that proves
28 // problematic when called on the UI thread. Additionally it seems the call may 28 // problematic when called on the UI thread. Additionally it seems the call may
29 // take a while to complete. For this reason we call it on a worker thread. 29 // take a while to complete. For this reason we call it on a worker thread.
30 // 30 //
31 // Docs for TaskbarList::SetOverlayIcon() say it does nothing if the HWND is not 31 // Docs for TaskbarList::SetOverlayIcon() say it does nothing if the HWND is not
32 // valid. 32 // valid.
33 void SetOverlayIcon(HWND hwnd, scoped_ptr<SkBitmap> bitmap) { 33 void SetOverlayIcon(HWND hwnd, std::unique_ptr<SkBitmap> bitmap) {
34 base::win::ScopedComPtr<ITaskbarList3> taskbar; 34 base::win::ScopedComPtr<ITaskbarList3> taskbar;
35 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, nullptr, 35 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, nullptr,
36 CLSCTX_INPROC_SERVER); 36 CLSCTX_INPROC_SERVER);
37 if (FAILED(result) || FAILED(taskbar->HrInit())) 37 if (FAILED(result) || FAILED(taskbar->HrInit()))
38 return; 38 return;
39 39
40 base::win::ScopedGDIObject<HICON> icon; 40 base::win::ScopedGDIObject<HICON> icon;
41 if (bitmap.get()) { 41 if (bitmap.get()) {
42 DCHECK_GE(bitmap.get()->width(), bitmap.get()->height()); 42 DCHECK_GE(bitmap.get()->width(), bitmap.get()->height());
43 // Maintain aspect ratio on resize. 43 // Maintain aspect ratio on resize.
(...skipping 29 matching lines...) Expand all
73 73
74 HWND hwnd = views::HWNDForNativeWindow(window); 74 HWND hwnd = views::HWNDForNativeWindow(window);
75 75
76 // SetOverlayIcon() does nothing if the window is not visible so testing here 76 // SetOverlayIcon() does nothing if the window is not visible so testing here
77 // avoids all the wasted effort of the image resizing. 77 // avoids all the wasted effort of the image resizing.
78 if (!::IsWindowVisible(hwnd)) 78 if (!::IsWindowVisible(hwnd))
79 return; 79 return;
80 80
81 // Copy the image since we're going to use it on a separate thread and 81 // Copy the image since we're going to use it on a separate thread and
82 // gfx::Image isn't thread safe. 82 // gfx::Image isn't thread safe.
83 scoped_ptr<SkBitmap> bitmap; 83 std::unique_ptr<SkBitmap> bitmap;
84 if (image) { 84 if (image) {
85 bitmap.reset(new SkBitmap( 85 bitmap.reset(new SkBitmap(
86 profiles::GetAvatarIconAsSquare(*image->ToSkBitmap(), 1))); 86 profiles::GetAvatarIconAsSquare(*image->ToSkBitmap(), 1)));
87 } 87 }
88 content::BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( 88 content::BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
89 FROM_HERE, base::Bind(&SetOverlayIcon, hwnd, base::Passed(&bitmap)), 89 FROM_HERE, base::Bind(&SetOverlayIcon, hwnd, base::Passed(&bitmap)),
90 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 90 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
91 } 91 }
92 92
93 } // namespace chrome 93 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/system_menu_model_builder.h ('k') | chrome/browser/ui/views/frame/test_with_browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698