| 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 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" | 5 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" |
| 6 | 6 |
| 7 #include <shlobj.h> // For SHChangeNotify(). | 7 #include <shlobj.h> // For SHChangeNotify(). |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "grit/chrome_unscaled_resources.h" | 37 #include "grit/chrome_unscaled_resources.h" |
| 38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
| 39 #include "skia/ext/image_operations.h" | 39 #include "skia/ext/image_operations.h" |
| 40 #include "skia/ext/platform_canvas.h" | 40 #include "skia/ext/platform_canvas.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 43 #include "ui/gfx/icon_util.h" | 43 #include "ui/gfx/icon_util.h" |
| 44 #include "ui/gfx/image/image.h" | 44 #include "ui/gfx/image/image.h" |
| 45 #include "ui/gfx/image/image_family.h" | 45 #include "ui/gfx/image/image_family.h" |
| 46 #include "ui/gfx/rect.h" | 46 |
| 47 #include "ui/gfx/skia_util.h" | |
| 48 | 47 |
| 49 using content::BrowserThread; | 48 using content::BrowserThread; |
| 50 | 49 |
| 51 namespace { | 50 namespace { |
| 52 | 51 |
| 53 // Name of the badged icon file generated for a given profile. | 52 // Name of the badged icon file generated for a given profile. |
| 54 const char kProfileIconFileName[] = "Google Profile.ico"; | 53 const char kProfileIconFileName[] = "Google Profile.ico"; |
| 55 | 54 |
| 56 // Characters that are not allowed in Windows filenames. Taken from | 55 // Characters that are not allowed in Windows filenames. Taken from |
| 57 // http://msdn.microsoft.com/en-us/library/aa365247.aspx | 56 // http://msdn.microsoft.com/en-us/library/aa365247.aspx |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 IDR_PROFILE_AVATAR_2X_24, | 103 IDR_PROFILE_AVATAR_2X_24, |
| 105 IDR_PROFILE_AVATAR_2X_25, | 104 IDR_PROFILE_AVATAR_2X_25, |
| 106 IDR_PROFILE_AVATAR_2X_26, | 105 IDR_PROFILE_AVATAR_2X_26, |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and | 108 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and |
| 110 // returns the resulting SkBitmap. | 109 // returns the resulting SkBitmap. |
| 111 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap, | 110 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap, |
| 112 const SkBitmap& avatar_bitmap, | 111 const SkBitmap& avatar_bitmap, |
| 113 int scale_factor) { | 112 int scale_factor) { |
| 114 // All icons, whether cartoon, GAIA or placeholder, should be square. | 113 SkBitmap source_bitmap = profiles::GetAvatarIconAsSquare(avatar_bitmap, |
| 115 // TODO(mlerman) - uncomment the ASSERT once noms@ lands the square images. | 114 scale_factor); |
| 116 // DCHECK(avatar_bitmap.width() == avatar_bitmap.height()); | |
| 117 | |
| 118 int avatar_badge_size = kProfileAvatarBadgeSize; | 115 int avatar_badge_size = kProfileAvatarBadgeSize; |
| 119 if (app_icon_bitmap.width() != kShortcutIconSize) { | 116 if (app_icon_bitmap.width() != kShortcutIconSize) { |
| 120 avatar_badge_size = | 117 avatar_badge_size = |
| 121 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize; | 118 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize; |
| 122 } | 119 } |
| 123 SkBitmap sk_icon = skia::ImageOperations::Resize( | 120 SkBitmap sk_icon = skia::ImageOperations::Resize( |
| 124 avatar_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size, | 121 source_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size, |
| 125 avatar_bitmap.height() * avatar_badge_size / avatar_bitmap.width()); | 122 source_bitmap.height() * avatar_badge_size / source_bitmap.width()); |
| 126 | 123 |
| 127 // Overlay the avatar on the icon, anchoring it to the bottom-right of the | 124 // Overlay the avatar on the icon, anchoring it to the bottom-right of the |
| 128 // icon. | 125 // icon. |
| 129 SkBitmap badged_bitmap; | 126 SkBitmap badged_bitmap; |
| 130 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(), | 127 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(), |
| 131 app_icon_bitmap.height()); | 128 app_icon_bitmap.height()); |
| 132 SkCanvas offscreen_canvas(badged_bitmap); | 129 SkCanvas offscreen_canvas(badged_bitmap); |
| 133 offscreen_canvas.clear(SK_ColorTRANSPARENT); | 130 offscreen_canvas.clear(SK_ColorTRANSPARENT); |
| 134 | 131 |
| 135 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0); | 132 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0); |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 // Ensure the profile's icon file has been created. | 840 // Ensure the profile's icon file has been created. |
| 844 CreateOrUpdateProfileIcon(profile->GetPath()); | 841 CreateOrUpdateProfileIcon(profile->GetPath()); |
| 845 } | 842 } |
| 846 break; | 843 break; |
| 847 } | 844 } |
| 848 default: | 845 default: |
| 849 NOTREACHED(); | 846 NOTREACHED(); |
| 850 break; | 847 break; |
| 851 } | 848 } |
| 852 } | 849 } |
| OLD | NEW |