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

Side by Side Diff: chrome/browser/ui/views/elevation_icon_setter.cc

Issue 1752233002: Convert Pass()→std::move() on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/elevation_icon_setter.h" 5 #include "chrome/browser/ui/views/elevation_icon_setter.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // Helpers -------------------------------------------------------------------- 23 // Helpers --------------------------------------------------------------------
24 24
25 namespace { 25 namespace {
26 26
27 scoped_ptr<SkBitmap> GetElevationIcon() { 27 scoped_ptr<SkBitmap> GetElevationIcon() {
28 scoped_ptr<SkBitmap> icon; 28 scoped_ptr<SkBitmap> icon;
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 if ((base::win::GetVersion() < base::win::VERSION_VISTA) || 30 if ((base::win::GetVersion() < base::win::VERSION_VISTA) ||
31 !base::win::UserAccountControlIsEnabled()) 31 !base::win::UserAccountControlIsEnabled())
32 return icon.Pass(); 32 return icon;
33 33
34 SHSTOCKICONINFO icon_info = { sizeof(SHSTOCKICONINFO) }; 34 SHSTOCKICONINFO icon_info = { sizeof(SHSTOCKICONINFO) };
35 typedef HRESULT (STDAPICALLTYPE *GetStockIconInfo)(SHSTOCKICONID, 35 typedef HRESULT (STDAPICALLTYPE *GetStockIconInfo)(SHSTOCKICONID,
36 UINT, 36 UINT,
37 SHSTOCKICONINFO*); 37 SHSTOCKICONINFO*);
38 // Even with the runtime guard above, we have to use GetProcAddress() 38 // Even with the runtime guard above, we have to use GetProcAddress()
39 // here, because otherwise the loader will try to resolve the function 39 // here, because otherwise the loader will try to resolve the function
40 // address on startup, which will break on XP. 40 // address on startup, which will break on XP.
41 GetStockIconInfo func = reinterpret_cast<GetStockIconInfo>( 41 GetStockIconInfo func = reinterpret_cast<GetStockIconInfo>(
42 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetStockIconInfo")); 42 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetStockIconInfo"));
43 // TODO(pkasting): Run on a background thread since this call spins a nested 43 // TODO(pkasting): Run on a background thread since this call spins a nested
44 // message loop. 44 // message loop.
45 if (FAILED((*func)(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, &icon_info))) 45 if (FAILED((*func)(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, &icon_info)))
46 return icon.Pass(); 46 return icon;
47 47
48 icon.reset(IconUtil::CreateSkBitmapFromHICON( 48 icon.reset(IconUtil::CreateSkBitmapFromHICON(
49 icon_info.hIcon, 49 icon_info.hIcon,
50 gfx::Size(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)))); 50 gfx::Size(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON))));
51 DestroyIcon(icon_info.hIcon); 51 DestroyIcon(icon_info.hIcon);
52 #endif 52 #endif
53 return icon; 53 return icon;
54 } 54 }
55 55
56 } // namespace 56 } // namespace
(...skipping 29 matching lines...) Expand all
86 button_->SetImage( 86 button_->SetImage(
87 views::Button::STATE_NORMAL, 87 views::Button::STATE_NORMAL,
88 gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor))); 88 gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor)));
89 button_->SizeToPreferredSize(); 89 button_->SizeToPreferredSize();
90 if (button_->parent()) 90 if (button_->parent())
91 button_->parent()->Layout(); 91 button_->parent()->Layout();
92 if (!callback.is_null()) 92 if (!callback.is_null())
93 callback.Run(); 93 callback.Run();
94 } 94 }
95 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698