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

Unified Diff: chrome/browser/web_applications/web_app_win.cc

Issue 12881003: ShortcutInfo::favicon is now a gfx::ImageFamily instead of gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use a constant instead of magic number. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/web_applications/web_app_win.cc
diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc
index a547545aebd1cf5a5b015c9bf46f6d4a126fb163..faadc9a7d7e14978219b8e8c36b95a018c96e394 100644
--- a/chrome/browser/web_applications/web_app_win.cc
+++ b/chrome/browser/web_applications/web_app_win.cc
@@ -20,12 +20,19 @@
#include "chrome/installer/util/browser_distribution.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/icon_util.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_family.h"
namespace {
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) {
DCHECK(digest);
@@ -173,9 +180,15 @@ namespace internals {
// Saves |image| to |icon_file| if the file is outdated and refresh shell's
// icon cache to ensure correct icon is displayed. Returns true if icon_file
// is up to date or successfully updated.
-bool CheckAndSaveIcon(const base::FilePath& icon_file, const SkBitmap& image) {
- if (ShouldUpdateIcon(icon_file, image)) {
- if (SaveIconWithCheckSum(icon_file, image)) {
+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.Get(kIconExportSize, kIconExportSize);
+ SkBitmap bitmap = (icon && !icon->IsEmpty()) ? *icon->ToSkBitmap() :
+ SkBitmap();
Robert Sesek 2013/04/04 18:39:02 AsSkBitmap()
Matt Giuca 2013/04/05 06:30:13 Done.
+ if (ShouldUpdateIcon(icon_file, bitmap)) {
+ if (SaveIconWithCheckSum(icon_file, bitmap)) {
// 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.
@@ -236,8 +249,7 @@ bool CreatePlatformShortcuts(
// Creates an ico file to use with shortcut.
base::FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension(
FILE_PATH_LITERAL(".ico"));
- if (!web_app::internals::CheckAndSaveIcon(icon_file,
- *shortcut_info.favicon.ToSkBitmap())) {
+ if (!web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon)) {
return false;
}
@@ -319,8 +331,7 @@ void UpdatePlatformShortcuts(
base::FilePath icon_file = web_app_path.Append(file_name).ReplaceExtension(
FILE_PATH_LITERAL(".ico"));
if (file_util::PathExists(icon_file)) {
- web_app::internals::CheckAndSaveIcon(icon_file,
- *shortcut_info.favicon.ToSkBitmap());
+ web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon);
}
}

Powered by Google App Engine
This is Rietveld 408576698