summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/jumplist_win.cc5
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_win.cc16
-rw-r--r--chrome/browser/ui/web_applications/web_app_ui.cc13
-rw-r--r--chrome/browser/web_applications/web_app_win.cc39
4 files changed, 46 insertions, 27 deletions
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc
index de8aaa9..f2b0372 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -47,6 +47,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/icon_util.h"
+#include "ui/gfx/image/image_family.h"
using content::BrowserThread;
@@ -236,7 +237,9 @@ bool CreateIconFile(const SkBitmap& bitmap,
// Create an icon file from the favicon attached to the given |page|, and
// save it as the temporary file.
- if (!IconUtil::CreateIconFileFromSkBitmap(bitmap, SkBitmap(), path))
+ gfx::ImageFamily image_family;
+ image_family.Add(gfx::Image::CreateFrom1xBitmap(bitmap));
+ if (!IconUtil::CreateIconFileFromImageFamily(image_family, path))
return false;
// Add this icon file to the list and return its absolute path.
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 4620240..6d02c63 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -36,6 +36,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/icon_util.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_family.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/skia_util.h"
@@ -148,19 +149,20 @@ base::FilePath CreateChromeDesktopShortcutIconForProfile(
if (!app_icon_bitmap.get())
return base::FilePath();
- const SkBitmap badged_bitmap = BadgeIcon(*app_icon_bitmap,
- avatar_bitmap_1x, 1);
+ gfx::ImageFamily badged_bitmaps;
+ badged_bitmaps.Add(gfx::Image::CreateFrom1xBitmap(
+ BadgeIcon(*app_icon_bitmap, avatar_bitmap_1x, 1)));
- SkBitmap large_badged_bitmap;
app_icon_bitmap = GetAppIconForSize(IconUtil::kLargeIconSize);
- if (app_icon_bitmap.get())
- large_badged_bitmap = BadgeIcon(*app_icon_bitmap, avatar_bitmap_2x, 2);
+ if (app_icon_bitmap.get()) {
+ badged_bitmaps.Add(gfx::Image::CreateFrom1xBitmap(
+ BadgeIcon(*app_icon_bitmap, avatar_bitmap_2x, 2)));
+ }
// Finally, write the .ico file containing this new bitmap.
const base::FilePath icon_path =
profile_path.AppendASCII(profiles::internal::kProfileIconFileName);
- if (!IconUtil::CreateIconFileFromSkBitmap(badged_bitmap, large_badged_bitmap,
- icon_path))
+ if (!IconUtil::CreateIconFileFromImageFamily(badged_bitmaps, icon_path))
return base::FilePath();
return icon_path;
diff --git a/chrome/browser/ui/web_applications/web_app_ui.cc b/chrome/browser/ui/web_applications/web_app_ui.cc
index 418e26f..4788e33 100644
--- a/chrome/browser/ui/web_applications/web_app_ui.cc
+++ b/chrome/browser/ui/web_applications/web_app_ui.cc
@@ -40,6 +40,7 @@
#if defined(OS_WIN)
#include "base/win/shortcut.h"
#include "base/win/windows_version.h"
+#include "ui/gfx/icon_util.h"
#endif
using content::BrowserThread;
@@ -50,12 +51,18 @@ namespace {
#if defined(OS_MACOSX)
const int kDesiredSizes[] = {16, 32, 128, 256, 512};
+const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
#elif defined(OS_LINUX)
// Linux supports icons of any size. FreeDesktop Icon Theme Specification states
// that "Minimally you should install a 48x48 icon in the hicolor theme."
const int kDesiredSizes[] = {16, 32, 48, 128, 256, 512};
+const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
+#elif defined(OS_WIN)
+const int* kDesiredSizes = IconUtil::kIconDimensions;
+const size_t kNumDesiredSizes = IconUtil::kNumIconDimensions;
#else
const int kDesiredSizes[] = {32};
+const size_t kNumDesiredSizes = arraysize(kDesiredSizes);
#endif
#if defined(OS_WIN)
@@ -330,7 +337,7 @@ void OnImageLoaded(ShellIntegration::ShortcutInfo shortcut_info,
if (image.IsEmpty()) {
gfx::Image default_icon =
ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON);
- int size = kDesiredSizes[arraysize(kDesiredSizes) - 1];
+ int size = kDesiredSizes[kNumDesiredSizes - 1];
SkBitmap bmp = skia::ImageOperations::Resize(
*default_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST,
size, size);
@@ -430,7 +437,7 @@ void UpdateShortcutInfoAndIconForApp(
// TODO(mgiuca): Have ImageLoader build the ImageFamily directly
// (http://crbug.com/230184).
std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
- for (size_t i = 0; i < arraysize(kDesiredSizes); ++i) {
+ for (size_t i = 0; i < kNumDesiredSizes; ++i) {
int size = kDesiredSizes[i];
extensions::ExtensionResource resource =
extensions::IconsInfo::GetIconResource(
@@ -445,7 +452,7 @@ void UpdateShortcutInfoAndIconForApp(
}
if (info_list.empty()) {
- size_t i = arraysize(kDesiredSizes) - 1;
+ size_t i = kNumDesiredSizes - 1;
int size = kDesiredSizes[i];
// If there is no icon at the desired sizes, we will resize what we can get.
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index 98d9e2c..5c76336 100644
--- a/chrome/browser/web_applications/web_app_win.cc
+++ b/chrome/browser/web_applications/web_app_win.cc
@@ -12,6 +12,7 @@
#include "base/md5.h"
#include "base/path_service.h"
#include "base/stringprintf.h"
+#include "base/strings/string_piece.h"
#include "base/utf_string_conversions.h"
#include "base/win/shortcut.h"
#include "base/win/windows_version.h"
@@ -29,22 +30,31 @@ const base::FilePath::CharType kIconChecksumFileExt[] =
FILE_PATH_LITERAL(".ico.md5");
// Width and height of icons exported to .ico files.
-// TODO(mgiuca): Remove when icon_util has the capability to save all icon
-// sizes, not just a single particular size.
-const int kIconExportSize = 32;
-// Calculates image checksum using MD5.
-void GetImageCheckSum(const SkBitmap& image, base::MD5Digest* digest) {
+// Calculates checksum of an icon family using MD5.
+// The checksum is derived from all of the icons in the family.
+void GetImageCheckSum(const gfx::ImageFamily& image, base::MD5Digest* digest) {
DCHECK(digest);
+ base::MD5Context md5_context;
+ base::MD5Init(&md5_context);
- SkAutoLockPixels image_lock(image);
- MD5Sum(image.getPixels(), image.getSize(), digest);
+ for (gfx::ImageFamily::const_iterator it = image.begin(); it != image.end();
+ ++it) {
+ SkBitmap bitmap = it->AsBitmap();
+
+ SkAutoLockPixels image_lock(bitmap);
+ base::StringPiece image_data(
+ reinterpret_cast<const char*>(bitmap.getPixels()), bitmap.getSize());
+ base::MD5Update(&md5_context, image_data);
+ }
+
+ base::MD5Final(digest, &md5_context);
}
// Saves |image| as an |icon_file| with the checksum.
bool SaveIconWithCheckSum(const base::FilePath& icon_file,
- const SkBitmap& image) {
- if (!IconUtil::CreateIconFileFromSkBitmap(image, SkBitmap(), icon_file))
+ const gfx::ImageFamily& image) {
+ if (!IconUtil::CreateIconFileFromImageFamily(image, icon_file))
return false;
base::MD5Digest digest;
@@ -57,7 +67,8 @@ bool SaveIconWithCheckSum(const base::FilePath& icon_file,
}
// Returns true if |icon_file| is missing or different from |image|.
-bool ShouldUpdateIcon(const base::FilePath& icon_file, const SkBitmap& image) {
+bool ShouldUpdateIcon(const base::FilePath& icon_file,
+ const gfx::ImageFamily& image) {
base::FilePath checksum_file(
icon_file.ReplaceExtension(kIconChecksumFileExt));
@@ -129,12 +140,8 @@ namespace internals {
// is up to date or successfully updated.
bool CheckAndSaveIcon(const base::FilePath& icon_file,
const gfx::ImageFamily& image) {
- // TODO(mgiuca): Save an icon with all icon sizes, not just an icon at a
- // hard-coded fixed size. http://crbug.com/163864.
- const gfx::Image* icon = image.GetBest(kIconExportSize, kIconExportSize);
- SkBitmap bitmap = icon ? icon->AsBitmap() : SkBitmap();
- if (ShouldUpdateIcon(icon_file, bitmap)) {
- if (SaveIconWithCheckSum(icon_file, bitmap)) {
+ if (ShouldUpdateIcon(icon_file, image)) {
+ if (SaveIconWithCheckSum(icon_file, image)) {
// Refresh shell's icon cache. This call is quite disruptive as user would
// see explorer rebuilding the icon cache. It would be great that we find
// a better way to achieve this.