| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 const int kShortcutIconSize = 48; | 52 const int kShortcutIconSize = 48; |
| 53 | 53 |
| 54 // Creates a desktop shortcut icon file (.ico) on the disk for a given profile, | 54 // Creates a desktop shortcut icon file (.ico) on the disk for a given profile, |
| 55 // badging the browser distribution icon with the profile avatar. | 55 // badging the browser distribution icon with the profile avatar. |
| 56 // Returns a path to the shortcut icon file on disk, which is empty if this | 56 // Returns a path to the shortcut icon file on disk, which is empty if this |
| 57 // fails. Use index 0 when assigning the resulting file as the icon. | 57 // fails. Use index 0 when assigning the resulting file as the icon. |
| 58 FilePath CreateChromeDesktopShortcutIconForProfile( | 58 FilePath CreateChromeDesktopShortcutIconForProfile( |
| 59 const FilePath& profile_path, | 59 const FilePath& profile_path, |
| 60 const SkBitmap& avatar_bitmap) { | 60 const SkBitmap& avatar_bitmap) { |
| 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 62 HICON app_icon_handle = GetAppIconForSize(kShortcutIconSize); | 62 scoped_ptr<SkBitmap> app_icon_bitmap(GetAppIconForSize(kShortcutIconSize)); |
| 63 scoped_ptr<SkBitmap> app_icon_bitmap( | |
| 64 IconUtil::CreateSkBitmapFromHICON(app_icon_handle)); | |
| 65 DestroyIcon(app_icon_handle); | |
| 66 if (!app_icon_bitmap.get()) | 63 if (!app_icon_bitmap.get()) |
| 67 return FilePath(); | 64 return FilePath(); |
| 68 | 65 |
| 69 // TODO(rlp): Share this chunk of code with | 66 // TODO(rlp): Share this chunk of code with |
| 70 // avatar_menu_button::DrawTaskBarDecoration. | 67 // avatar_menu_button::DrawTaskBarDecoration. |
| 71 const SkBitmap* source_bitmap = NULL; | 68 const SkBitmap* source_bitmap = NULL; |
| 72 SkBitmap squarer_bitmap; | 69 SkBitmap squarer_bitmap; |
| 73 if ((avatar_bitmap.width() == profiles::kAvatarIconWidth) && | 70 if ((avatar_bitmap.width() == profiles::kAvatarIconWidth) && |
| 74 (avatar_bitmap.height() == profiles::kAvatarIconHeight)) { | 71 (avatar_bitmap.height() == profiles::kAvatarIconHeight)) { |
| 75 // Shave a couple of columns so the bitmap is more square. So when | 72 // Shave a couple of columns so the bitmap is more square. So when |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 579 } |
| 583 BrowserThread::PostTask( | 580 BrowserThread::PostTask( |
| 584 BrowserThread::FILE, FROM_HERE, | 581 BrowserThread::FILE, FROM_HERE, |
| 585 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, | 582 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, |
| 586 profile_path, new_shortcut_appended_name, | 583 profile_path, new_shortcut_appended_name, |
| 587 profile_avatar_bitmap_copy, create_mode, action)); | 584 profile_avatar_bitmap_copy, create_mode, action)); |
| 588 | 585 |
| 589 cache->SetShortcutNameOfProfileAtIndex(profile_index, | 586 cache->SetShortcutNameOfProfileAtIndex(profile_index, |
| 590 new_shortcut_appended_name); | 587 new_shortcut_appended_name); |
| 591 } | 588 } |
| OLD | NEW |