chrome/browser/profiles/profile_shortcut_manager_win.cc
// Creates a desktop shortcut icon file (.ico) on the disk for a given profile,
// badging the browser distribution icon with the profile avatar.
// Returns a path to the shortcut icon file on disk, which is empty if this
// fails. Use index 0 when assigning the resulting file as the icon.
Creates a desktop shortcut icon file (.ico) on the disk for a given profile,
badging the browser distribution icon with the profile avatar.
Returns a path to the shortcut icon file on disk, which is empty if this
fails. Use index 0 when assigning the resulting file as the icon.
Creates a desktop shortcut icon file ( . ico ) on the disk for a given profile badging the browser distribution icon with the profile avatar . Returns a path to the shortcut icon file on disk which is empty if this fails . Use index 0 when assigning the resulting file as the icon .
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);
  if (!app_icon_bitmap.get())
    return FilePath();
  const SkBitmap* source_bitmap = NULL;
  SkBitmap squarer_bitmap;
  if ((avatar_bitmap.width() == profiles::kAvatarIconWidth) &&
      (avatar_bitmap.height() == profiles::kAvatarIconHeight)) {
    int x = 2;
    avatar_bitmap.extractSubset(&squarer_bitmap, SkIRect::MakeXYWH(x, 0,
        profiles::kAvatarIconWidth - x * 2, profiles::kAvatarIconHeight));
    source_bitmap = &squarer_bitmap;
  } else {
    source_bitmap = &avatar_bitmap;
  }
  SkBitmap sk_icon = skia::ImageOperations::Resize(
      *source_bitmap,
      skia::ImageOperations::RESIZE_LANCZOS3,
      kProfileAvatarShortcutBadgeWidth,
      kProfileAvatarShortcutBadgeHeight);
  scoped_ptr<SkCanvas> offscreen_canvas(
      skia::CreateBitmapCanvas(app_icon_bitmap->width(),
                               app_icon_bitmap->height(),
                               false));
  DCHECK(offscreen_canvas.get());
  offscreen_canvas->drawBitmap(*app_icon_bitmap, 0, 0);
  offscreen_canvas->drawBitmap(
      sk_icon,
      app_icon_bitmap->width() - kProfileAvatarShortcutBadgeWidth,
      app_icon_bitmap->height() - kProfileAvatarShortcutBadgeHeight);
  const SkBitmap& final_bitmap =
      offscreen_canvas->getDevice()->accessBitmap(false);
  const FilePath icon_path =
      profile_path.AppendASCII(profiles::internal::kProfileIconFileName);
  if (!IconUtil::CreateIconFileFromSkBitmap(final_bitmap, icon_path))
    return FilePath();
  return icon_path;
}
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 ) ; if ( ! app_icon_bitmap . get ( ) ) return FilePath ( ) ; const SkBitmap * source_bitmap = NULL ; SkBitmap squarer_bitmap ; if ( ( avatar_bitmap . width ( ) == profiles :: kAvatarIconWidth ) && ( avatar_bitmap . height ( ) == profiles :: kAvatarIconHeight ) ) { int x = 2 ; avatar_bitmap . extractSubset ( & squarer_bitmap , SkIRect :: MakeXYWH ( x , 0 , profiles :: kAvatarIconWidth - x * 2 , profiles :: kAvatarIconHeight ) ) ; source_bitmap = & squarer_bitmap ; } else { source_bitmap = & avatar_bitmap ; } SkBitmap sk_icon = skia :: ImageOperations :: Resize ( * source_bitmap , skia :: ImageOperations :: RESIZE_LANCZOS3 , kProfileAvatarShortcutBadgeWidth , kProfileAvatarShortcutBadgeHeight ) ; scoped_ptr < SkCanvas > offscreen_canvas ( skia :: CreateBitmapCanvas ( app_icon_bitmap -> width ( ) , app_icon_bitmap -> height ( ) , false ) ) ; DCHECK ( offscreen_canvas . get ( ) ) ; offscreen_canvas -> drawBitmap ( * app_icon_bitmap , 0 , 0 ) ; offscreen_canvas -> drawBitmap ( sk_icon , app_icon_bitmap -> width ( ) - kProfileAvatarShortcutBadgeWidth , app_icon_bitmap -> height ( ) - kProfileAvatarShortcutBadgeHeight ) ; const SkBitmap & final_bitmap = offscreen_canvas -> getDevice ( ) -> accessBitmap ( false ) ; const FilePath icon_path = profile_path . AppendASCII ( profiles :: internal :: kProfileIconFileName ) ; if ( ! IconUtil :: CreateIconFileFromSkBitmap ( final_bitmap , icon_path ) ) return FilePath ( ) ; return icon_path ; }
Creates a desktop shortcut icon file (.ico) on the disk for a given profile,
badging the browser distribution icon with the profile avatar.
Creates a desktop shortcut icon file ( . ico ) on the disk for a given profile badging the browser distribution icon with the profile avatar .
// TODO(rlp): Share this chunk of code with // avatar_menu_button::DrawTaskBarDecoration. // Shave a couple of columns so the bitmap is more square. So when // resized to a square aspect ratio it looks pretty. // Overlay the avatar on the icon, anchoring it to the bottom-right of the // icon. // Finally, write the .ico file containing this new bitmap.