Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for getting the 256x256 app icon on Windows as a SkBitmap.

Also, adds an icon (a copy of chrome/app/theme/chromium/chromium.ico) to ui_unittests.exe, which is needed by the tests for this new functionality.

The icon was landed here: https://codereview.chromium.org/11877018/

BUG=167277
TEST=New unit tests in icon_util_unittests.cc.

Review URL: https://chromiumcodereview.appspot.com/11778073

git-svn-id: http://src.chromium.org/svn/trunk/src/chrome/browser@176700 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information...
commit 4c0f8172b783e31c0c51e6e83aac0357e7e57b4b 1 parent 8a19876
asvitkine@chromium.org authored
View
31 app_icon_win.cc
@@ -6,32 +6,35 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_constants.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/icon_util.h"
#if defined(GOOGLE_CHROME_BUILD)
#include "chrome/installer/util/install_util.h"
#endif
-HICON GetAppIcon() {
+namespace {
+
+// Returns the resource id of the application icon.
+int GetAppIconResourceId() {
int icon_id = IDR_MAINFRAME;
#if defined(GOOGLE_CHROME_BUILD)
if (InstallUtil::IsChromeSxSProcess())
icon_id = IDR_SXS;
#endif
+ return icon_id;
+}
+
+} // namespace
+
+HICON GetAppIcon() {
+ const int icon_id = GetAppIconResourceId();
return LoadIcon(GetModuleHandle(chrome::kBrowserResourcesDll),
MAKEINTRESOURCE(icon_id));
}
-HICON GetAppIconForSize(int size) {
- int icon_id = IDR_MAINFRAME;
-#if defined(GOOGLE_CHROME_BUILD)
- if (InstallUtil::IsChromeSxSProcess())
- icon_id = IDR_SXS;
-#endif
- return static_cast<HICON>(
- LoadImage(GetModuleHandle(chrome::kBrowserResourcesDll),
- MAKEINTRESOURCE(icon_id),
- IMAGE_ICON,
- size,
- size,
- LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
+scoped_ptr<SkBitmap> GetAppIconForSize(int size) {
+ const int icon_id = GetAppIconResourceId();
+ return IconUtil::CreateSkBitmapFromIconResource(
+ GetModuleHandle(chrome::kBrowserResourcesDll), icon_id, size);
}
View
8 app_icon_win.h
@@ -7,11 +7,15 @@
#include <windows.h>
+#include "base/memory/scoped_ptr.h"
+
+class SkBitmap;
+
HICON GetAppIcon();
// Retrieve the application icon for the given size. Note that if you specify a
// size other than what is contained in chrome.dll (16x16, 32x32, 48x48), this
-// might return a handle to a poorly resized icon.
-HICON GetAppIconForSize(int size);
+// might return a poorly resized icon.
+scoped_ptr<SkBitmap> GetAppIconForSize(int size);
#endif // CHROME_BROWSER_APP_ICON_WIN_H_
View
5 profiles/profile_shortcut_manager_win.cc
@@ -59,10 +59,7 @@ FilePath CreateChromeDesktopShortcutIconForProfile(
const FilePath& profile_path,
const SkBitmap& avatar_bitmap) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- HICON app_icon_handle = GetAppIconForSize(kShortcutIconSize);
- scoped_ptr<SkBitmap> app_icon_bitmap(
- IconUtil::CreateSkBitmapFromHICON(app_icon_handle));
- DestroyIcon(app_icon_handle);
+ scoped_ptr<SkBitmap> app_icon_bitmap(GetAppIconForSize(kShortcutIconSize));
if (!app_icon_bitmap.get())
return FilePath();
Please sign in to comment.
Something went wrong with that request. Please try again.