Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_GFX_ICON_UTIL_H_ | 5 #ifndef UI_GFX_ICON_UTIL_H_ | 
| 6 #define UI_GFX_ICON_UTIL_H_ | 6 #define UI_GFX_ICON_UTIL_H_ | 
| 7 | 7 | 
| 8 #include <windows.h> | 8 #include <windows.h> | 
| 9 #include <string> | 9 #include <string> | 
| 10 #include <vector> | 10 #include <vector> | 
| 11 | 11 | 
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" | 
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" | 
| 14 #include "base/md5.h" | |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" | 
| 15 #include "ui/base/ui_export.h" | 16 #include "ui/base/ui_export.h" | 
| 16 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" | 
| 17 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" | 
| 18 | 19 | 
| 19 namespace base { | 20 namespace base { | 
| 20 class FilePath; | 21 class FilePath; | 
| 21 } | 22 } | 
| 22 | 23 | 
| 23 namespace gfx { | 24 namespace gfx { | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 const gfx::ImageFamily& image_family, | 130 const gfx::ImageFamily& image_family, | 
| 130 const base::FilePath& icon_path); | 131 const base::FilePath& icon_path); | 
| 131 | 132 | 
| 132 // Creates a cursor of the specified size from the DIB passed in. | 133 // Creates a cursor of the specified size from the DIB passed in. | 
| 133 // Returns the cursor on success or NULL on failure. | 134 // Returns the cursor on success or NULL on failure. | 
| 134 static HICON CreateCursorFromDIB(const gfx::Size& icon_size, | 135 static HICON CreateCursorFromDIB(const gfx::Size& icon_size, | 
| 135 const gfx::Point& hotspot, | 136 const gfx::Point& hotspot, | 
| 136 const void* dib_bits, | 137 const void* dib_bits, | 
| 137 size_t dib_size); | 138 size_t dib_size); | 
| 138 | 139 | 
| 140 // Calculates checksum of an icon family using MD5. | |
| 141 // The checksum is derived from all of the icons in the family. | |
| 142 static void GetImageCheckSum(const gfx::ImageFamily& image, | |
| 143 base::MD5Digest* digest); | |
| 
 
gab
2013/05/08 13:01:08
Forward-declare base::MD5Digest instead of includi
 
calamity
2013/05/09 06:12:16
Done in new CL.
 
 | |
| 144 | |
| 145 // Saves |image| as an |icon_file| with the checksum. | |
| 146 static bool SaveIconWithCheckSum(const base::FilePath& icon_file, | |
| 147 const gfx::ImageFamily& image); | |
| 148 | |
| 149 // Returns true if |icon_file| is missing or different from |image|. | |
| 150 static bool ShouldUpdateIcon(const base::FilePath& icon_file, | |
| 151 const gfx::ImageFamily& image); | |
| 152 | |
| 139 private: | 153 private: | 
| 140 // The icon format is published in the MSDN but there is no definition of | 154 // The icon format is published in the MSDN but there is no definition of | 
| 141 // the icon file structures in any of the Windows header files so we need to | 155 // the icon file structures in any of the Windows header files so we need to | 
| 142 // define these structure within the class. We must make sure we use 2 byte | 156 // define these structure within the class. We must make sure we use 2 byte | 
| 143 // packing so that the structures are layed out properly within the file. | 157 // packing so that the structures are layed out properly within the file. | 
| 144 // See: http://msdn.microsoft.com/en-us/library/ms997538.aspx | 158 // See: http://msdn.microsoft.com/en-us/library/ms997538.aspx | 
| 145 #pragma pack(push) | 159 #pragma pack(push) | 
| 146 #pragma pack(2) | 160 #pragma pack(2) | 
| 147 | 161 | 
| 148 // ICONDIRENTRY contains meta data for an individual icon image within a | 162 // ICONDIRENTRY contains meta data for an individual icon image within a | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 // A helper function of CreateSkBitmapFromHICON. | 278 // A helper function of CreateSkBitmapFromHICON. | 
| 265 static SkBitmap CreateSkBitmapFromHICONHelper(HICON icon, | 279 static SkBitmap CreateSkBitmapFromHICONHelper(HICON icon, | 
| 266 const gfx::Size& s); | 280 const gfx::Size& s); | 
| 267 | 281 | 
| 268 // Prevent clients from instantiating objects of that class by declaring the | 282 // Prevent clients from instantiating objects of that class by declaring the | 
| 269 // ctor/dtor as private. | 283 // ctor/dtor as private. | 
| 270 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); | 284 DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); | 
| 271 }; | 285 }; | 
| 272 | 286 | 
| 273 #endif // UI_GFX_ICON_UTIL_H_ | 287 #endif // UI_GFX_ICON_UTIL_H_ | 
| OLD | NEW |