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

Side by Side Diff: chrome/browser/profiles/profile_shortcut_manager_win.cc

Issue 14137032: Create profile .ico file on profile creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/profiles/profile_shortcut_manager_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 offscreen_canvas->getDevice()->accessBitmap(false); 132 offscreen_canvas->getDevice()->accessBitmap(false);
133 SkBitmap badged_bitmap_copy; 133 SkBitmap badged_bitmap_copy;
134 badged_bitmap.deepCopyTo(&badged_bitmap_copy, badged_bitmap.getConfig()); 134 badged_bitmap.deepCopyTo(&badged_bitmap_copy, badged_bitmap.getConfig());
135 return badged_bitmap_copy; 135 return badged_bitmap_copy;
136 } 136 }
137 137
138 // Creates a desktop shortcut icon file (.ico) on the disk for a given profile, 138 // Creates a desktop shortcut icon file (.ico) on the disk for a given profile,
139 // badging the browser distribution icon with the profile avatar. 139 // badging the browser distribution icon with the profile avatar.
140 // Returns a path to the shortcut icon file on disk, which is empty if this 140 // Returns a path to the shortcut icon file on disk, which is empty if this
141 // fails. Use index 0 when assigning the resulting file as the icon. 141 // fails. Use index 0 when assigning the resulting file as the icon.
142 base::FilePath CreateChromeDesktopShortcutIconForProfile( 142 void CreateOrUpdateShortcutIconForProfile(
143 const base::FilePath& profile_path, 143 const base::FilePath& profile_path,
144 const SkBitmap& avatar_bitmap_1x, 144 const SkBitmap& avatar_bitmap_1x,
145 const SkBitmap& avatar_bitmap_2x) { 145 const SkBitmap& avatar_bitmap_2x) {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
147 scoped_ptr<SkBitmap> app_icon_bitmap(GetAppIconForSize(kShortcutIconSize)); 147 scoped_ptr<SkBitmap> app_icon_bitmap(GetAppIconForSize(kShortcutIconSize));
148 if (!app_icon_bitmap.get()) 148 if (!app_icon_bitmap.get())
149 return base::FilePath(); 149 return;
150 150
151 const SkBitmap badged_bitmap = BadgeIcon(*app_icon_bitmap, 151 const SkBitmap badged_bitmap = BadgeIcon(*app_icon_bitmap,
152 avatar_bitmap_1x, 1); 152 avatar_bitmap_1x, 1);
153 153
154 SkBitmap large_badged_bitmap; 154 SkBitmap large_badged_bitmap;
155 app_icon_bitmap = GetAppIconForSize(IconUtil::kLargeIconSize); 155 app_icon_bitmap = GetAppIconForSize(IconUtil::kLargeIconSize);
156 if (app_icon_bitmap.get()) 156 if (app_icon_bitmap.get())
157 large_badged_bitmap = BadgeIcon(*app_icon_bitmap, avatar_bitmap_2x, 2); 157 large_badged_bitmap = BadgeIcon(*app_icon_bitmap, avatar_bitmap_2x, 2);
158 158
159 // Finally, write the .ico file containing this new bitmap. 159 // Finally, write the .ico file containing this new bitmap.
160 const base::FilePath icon_path = 160 const base::FilePath icon_path =
161 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); 161 profile_path.AppendASCII(profiles::internal::kProfileIconFileName);
162 if (!IconUtil::CreateIconFileFromSkBitmap(badged_bitmap, large_badged_bitmap, 162 if (!IconUtil::CreateIconFileFromSkBitmap(badged_bitmap, large_badged_bitmap,
163 icon_path)) 163 icon_path))
164 return base::FilePath(); 164 LOG(ERROR) << "Failed to create icon at " << icon_path.value();
Alexei Svitkine (slow) 2013/04/26 21:16:23 Just make it a NOTREACHED()? Also, please add {}'
calamity 2013/04/30 06:45:41 Done.
165
166 return icon_path;
167 } 165 }
168 166
169 // Gets the user and system directories for desktop shortcuts. Parameters may 167 // Gets the user and system directories for desktop shortcuts. Parameters may
170 // be NULL if a directory type is not needed. Returns true on success. 168 // be NULL if a directory type is not needed. Returns true on success.
171 bool GetDesktopShortcutsDirectories( 169 bool GetDesktopShortcutsDirectories(
172 base::FilePath* user_shortcuts_directory, 170 base::FilePath* user_shortcuts_directory,
173 base::FilePath* system_shortcuts_directory) { 171 base::FilePath* system_shortcuts_directory) {
174 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); 172 BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
175 if (user_shortcuts_directory && 173 if (user_shortcuts_directory &&
176 !ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, 174 !ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 304 }
307 305
308 // Updates all desktop shortcuts for the given profile to have the specified 306 // Updates all desktop shortcuts for the given profile to have the specified
309 // parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is 307 // parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is
310 // created if no existing ones were found. Whether non-profile shortcuts should 308 // created if no existing ones were found. Whether non-profile shortcuts should
311 // be updated is specified by |action|. Must be called on the FILE thread. 309 // be updated is specified by |action|. Must be called on the FILE thread.
312 void CreateOrUpdateDesktopShortcutsForProfile( 310 void CreateOrUpdateDesktopShortcutsForProfile(
313 const base::FilePath& profile_path, 311 const base::FilePath& profile_path,
314 const string16& old_profile_name, 312 const string16& old_profile_name,
315 const string16& profile_name, 313 const string16& profile_name,
316 const SkBitmap& avatar_image_1x,
317 const SkBitmap& avatar_image_2x,
318 ProfileShortcutManagerWin::CreateOrUpdateMode create_mode, 314 ProfileShortcutManagerWin::CreateOrUpdateMode create_mode,
319 ProfileShortcutManagerWin::NonProfileShortcutAction action) { 315 ProfileShortcutManagerWin::NonProfileShortcutAction action) {
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
321 317
322 base::FilePath chrome_exe; 318 base::FilePath chrome_exe;
323 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { 319 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
324 NOTREACHED(); 320 NOTREACHED();
325 return; 321 return;
326 } 322 }
327 323
(...skipping 17 matching lines...) Expand all
345 installer::Product product(distribution); 341 installer::Product product(distribution);
346 product.AddDefaultShortcutProperties(chrome_exe, &properties); 342 product.AddDefaultShortcutProperties(chrome_exe, &properties);
347 343
348 const string16 command_line = 344 const string16 command_line =
349 profiles::internal::CreateProfileShortcutFlags(profile_path); 345 profiles::internal::CreateProfileShortcutFlags(profile_path);
350 346
351 // Only set the profile-specific properties when |profile_name| is non empty. 347 // Only set the profile-specific properties when |profile_name| is non empty.
352 // If it is empty, it means the shortcut being created should be a regular, 348 // If it is empty, it means the shortcut being created should be a regular,
353 // non-profile Chrome shortcut. 349 // non-profile Chrome shortcut.
354 if (!profile_name.empty()) { 350 if (!profile_name.empty()) {
355 const base::FilePath shortcut_icon = 351 base::FilePath shortcut_icon =
356 CreateChromeDesktopShortcutIconForProfile(profile_path, 352 profile_path.AppendASCII(profiles::internal::kProfileIconFileName);
357 avatar_image_1x, 353 if (file_util::PathExists(shortcut_icon))
Alexei Svitkine (slow) 2013/04/26 21:16:23 When would this be the case? Wouldn't we want to
calamity 2013/04/30 06:45:41 Rolled the 2 functions back together and created t
358 avatar_image_2x);
359 if (!shortcut_icon.empty())
360 properties.set_icon(shortcut_icon, 0); 354 properties.set_icon(shortcut_icon, 0);
361 properties.set_arguments(command_line); 355 properties.set_arguments(command_line);
362 } else { 356 } else {
363 // Set the arguments explicitly to the empty string to ensure that 357 // Set the arguments explicitly to the empty string to ensure that
364 // |ShellUtil::CreateOrUpdateShortcut| updates that part of the shortcut. 358 // |ShellUtil::CreateOrUpdateShortcut| updates that part of the shortcut.
365 properties.set_arguments(string16()); 359 properties.set_arguments(string16());
366 } 360 }
367 361
368 ShellUtil::ShortcutOperation operation = 362 ShellUtil::ShortcutOperation operation =
369 ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING; 363 ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // Use file_util::Delete() instead of ShellUtil::RemoveShortcut(), as the 427 // Use file_util::Delete() instead of ShellUtil::RemoveShortcut(), as the
434 // latter causes non-profile taskbar shortcuts to be unpinned. 428 // latter causes non-profile taskbar shortcuts to be unpinned.
435 file_util::Delete(shortcuts[i], false); 429 file_util::Delete(shortcuts[i], false);
436 // Notify the shell that the shortcut was deleted to ensure desktop refresh. 430 // Notify the shell that the shortcut was deleted to ensure desktop refresh.
437 SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, shortcuts[i].value().c_str(), 431 SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, shortcuts[i].value().c_str(),
438 NULL); 432 NULL);
439 } 433 }
440 434
441 const base::FilePath icon_path = 435 const base::FilePath icon_path =
442 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); 436 profile_path.AppendASCII(profiles::internal::kProfileIconFileName);
443 file_util::Delete(icon_path, false); 437 file_util::Delete(icon_path, false);
Alexei Svitkine (slow) 2013/04/26 21:16:23 I think you need to remove this line, else when so
calamity 2013/04/30 06:45:41 Done. The change I've made to the tests assert th
444 438
445 // If |ensure_shortcuts_remain| is true and deleting this profile caused the 439 // If |ensure_shortcuts_remain| is true and deleting this profile caused the
446 // last shortcuts to be removed, re-create a regular non-profile shortcut. 440 // last shortcuts to be removed, re-create a regular non-profile shortcut.
447 const bool had_shortcuts = !shortcuts.empty(); 441 const bool had_shortcuts = !shortcuts.empty();
448 if (ensure_shortcuts_remain && had_shortcuts && 442 if (ensure_shortcuts_remain && had_shortcuts &&
449 !ChromeDesktopShortcutsExist(chrome_exe)) { 443 !ChromeDesktopShortcutsExist(chrome_exe)) {
450 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); 444 BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
451 // Ensure that the distribution supports creating shortcuts. If it doesn't, 445 // Ensure that the distribution supports creating shortcuts. If it doesn't,
452 // the following code may result in NOTREACHED() being hit. 446 // the following code may result in NOTREACHED() being hit.
453 DCHECK(distribution->CanCreateDesktopShortcuts()); 447 DCHECK(distribution->CanCreateDesktopShortcuts());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 void ProfileShortcutManagerWin::HasProfileShortcuts( 583 void ProfileShortcutManagerWin::HasProfileShortcuts(
590 const base::FilePath& profile_path, 584 const base::FilePath& profile_path,
591 const base::Callback<void(bool)>& callback) { 585 const base::Callback<void(bool)>& callback) {
592 BrowserThread::PostTaskAndReplyWithResult( 586 BrowserThread::PostTaskAndReplyWithResult(
593 BrowserThread::FILE, FROM_HERE, 587 BrowserThread::FILE, FROM_HERE,
594 base::Bind(&HasAnyProfileShortcuts, profile_path), callback); 588 base::Bind(&HasAnyProfileShortcuts, profile_path), callback);
595 } 589 }
596 590
597 void ProfileShortcutManagerWin::OnProfileAdded( 591 void ProfileShortcutManagerWin::OnProfileAdded(
598 const base::FilePath& profile_path) { 592 const base::FilePath& profile_path) {
593 CreateOrUpdateShortcutIconForProfileAtPath(profile_path);
599 const size_t profile_count = 594 const size_t profile_count =
600 profile_manager_->GetProfileInfoCache().GetNumberOfProfiles(); 595 profile_manager_->GetProfileInfoCache().GetNumberOfProfiles();
601 if (profile_count == 1) { 596 if (profile_count == 1) {
602 CreateOrUpdateShortcutsForProfileAtPath(profile_path, 597 CreateOrUpdateShortcutsForProfileAtPath(profile_path,
603 CREATE_WHEN_NONE_FOUND, 598 CREATE_WHEN_NONE_FOUND,
604 UPDATE_NON_PROFILE_SHORTCUTS); 599 UPDATE_NON_PROFILE_SHORTCUTS);
605 } else if (profile_count == 2) { 600 } else if (profile_count == 2) {
606 CreateOrUpdateShortcutsForProfileAtPath(GetOtherProfilePath(profile_path), 601 CreateOrUpdateShortcutsForProfileAtPath(GetOtherProfilePath(profile_path),
607 UPDATE_EXISTING_ONLY, 602 UPDATE_EXISTING_ONLY,
608 UPDATE_NON_PROFILE_SHORTCUTS); 603 UPDATE_NON_PROFILE_SHORTCUTS);
609 } 604 }
610 } 605 }
611 606
612 void ProfileShortcutManagerWin::OnProfileWillBeRemoved( 607 void ProfileShortcutManagerWin::OnProfileWillBeRemoved(
613 const base::FilePath& profile_path) { 608 const base::FilePath& profile_path) {
614 } 609 }
615 610
616 void ProfileShortcutManagerWin::OnProfileWasRemoved( 611 void ProfileShortcutManagerWin::OnProfileWasRemoved(
617 const base::FilePath& profile_path, 612 const base::FilePath& profile_path,
618 const string16& profile_name) { 613 const string16& profile_name) {
619 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 614 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
620 // If there is only one profile remaining, remove the badging information 615 // If there is only one profile remaining, remove the badging information
621 // from an existing shortcut. 616 // from an existing shortcut.
622 const bool deleting_down_to_last_profile = (cache.GetNumberOfProfiles() == 1); 617 const bool deleting_down_to_last_profile = (cache.GetNumberOfProfiles() == 1);
623 if (deleting_down_to_last_profile) { 618 if (deleting_down_to_last_profile) {
624 CreateOrUpdateShortcutsForProfileAtPath(cache.GetPathOfProfileAtIndex(0), 619 base::FilePath profile_path = cache.GetPathOfProfileAtIndex(0);
620 CreateOrUpdateShortcutIconForProfileAtPath(profile_path);
Alexei Svitkine (slow) 2013/04/26 21:16:23 Add a comment mentioning that this is needed to "u
calamity 2013/04/30 06:45:41 Done. I actually want to make an unbadged icon tha
Alexei Svitkine (slow) 2013/05/01 15:27:30 I think it's fine to create an un-badged icon for
621 CreateOrUpdateShortcutsForProfileAtPath(profile_path,
625 UPDATE_EXISTING_ONLY, 622 UPDATE_EXISTING_ONLY,
626 IGNORE_NON_PROFILE_SHORTCUTS); 623 IGNORE_NON_PROFILE_SHORTCUTS);
627 } 624 }
628 625
629 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 626 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
630 base::Bind(&DeleteDesktopShortcutsAndIconFile, 627 base::Bind(&DeleteDesktopShortcutsAndIconFile,
631 profile_path, 628 profile_path,
632 deleting_down_to_last_profile)); 629 deleting_down_to_last_profile));
633 } 630 }
634 631
635 void ProfileShortcutManagerWin::OnProfileNameChanged( 632 void ProfileShortcutManagerWin::OnProfileNameChanged(
636 const base::FilePath& profile_path, 633 const base::FilePath& profile_path,
637 const string16& old_profile_name) { 634 const string16& old_profile_name) {
638 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, 635 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY,
639 IGNORE_NON_PROFILE_SHORTCUTS); 636 IGNORE_NON_PROFILE_SHORTCUTS);
640 } 637 }
641 638
642 void ProfileShortcutManagerWin::OnProfileAvatarChanged( 639 void ProfileShortcutManagerWin::OnProfileAvatarChanged(
643 const base::FilePath& profile_path) { 640 const base::FilePath& profile_path) {
641 CreateOrUpdateShortcutIconForProfileAtPath(profile_path);
644 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, 642 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY,
Alexei Svitkine (slow) 2013/04/26 21:16:23 Is this call necessary if we're already calling Cr
calamity 2013/04/30 06:45:41 Not updating the shortcut seems to be fine.
645 IGNORE_NON_PROFILE_SHORTCUTS); 643 IGNORE_NON_PROFILE_SHORTCUTS);
646 } 644 }
647 645
648 base::FilePath ProfileShortcutManagerWin::GetOtherProfilePath( 646 base::FilePath ProfileShortcutManagerWin::GetOtherProfilePath(
649 const base::FilePath& profile_path) { 647 const base::FilePath& profile_path) {
650 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 648 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
651 DCHECK_EQ(2U, cache.GetNumberOfProfiles()); 649 DCHECK_EQ(2U, cache.GetNumberOfProfiles());
652 // Get the index of the current profile, in order to find the index of the 650 // Get the index of the current profile, in order to find the index of the
653 // other profile. 651 // other profile.
654 size_t current_profile_index = cache.GetIndexOfProfileWithPath(profile_path); 652 size_t current_profile_index = cache.GetIndexOfProfileWithPath(profile_path);
655 size_t other_profile_index = (current_profile_index == 0) ? 1 : 0; 653 size_t other_profile_index = (current_profile_index == 0) ? 1 : 0;
656 return cache.GetPathOfProfileAtIndex(other_profile_index); 654 return cache.GetPathOfProfileAtIndex(other_profile_index);
657 } 655 }
658 656
659 void ProfileShortcutManagerWin::CreateOrUpdateShortcutsForProfileAtPath( 657 void ProfileShortcutManagerWin::CreateOrUpdateShortcutsForProfileAtPath(
660 const base::FilePath& profile_path, 658 const base::FilePath& profile_path,
661 CreateOrUpdateMode create_mode, 659 CreateOrUpdateMode create_mode,
662 NonProfileShortcutAction action) { 660 NonProfileShortcutAction action) {
663 ProfileInfoCache* cache = &profile_manager_->GetProfileInfoCache(); 661 ProfileInfoCache* cache = &profile_manager_->GetProfileInfoCache();
664 size_t profile_index = cache->GetIndexOfProfileWithPath(profile_path); 662 size_t profile_index = cache->GetIndexOfProfileWithPath(profile_path);
665 if (profile_index == std::string::npos) 663 if (profile_index == std::string::npos)
666 return; 664 return;
667 bool remove_badging = cache->GetNumberOfProfiles() == 1; 665 bool is_last_profile = cache->GetNumberOfProfiles() == 1;
668 666
669 string16 old_shortcut_appended_name = 667 string16 old_shortcut_appended_name =
670 cache->GetShortcutNameOfProfileAtIndex(profile_index); 668 cache->GetShortcutNameOfProfileAtIndex(profile_index);
671 669
672 // Exit early if the mode is to update existing profile shortcuts only and 670 // Exit early if the mode is to update existing profile shortcuts only and
673 // none were ever created for this profile, per the shortcut name not being 671 // none were ever created for this profile, per the shortcut name not being
674 // set in the profile info cache. 672 // set in the profile info cache.
675 if (old_shortcut_appended_name.empty() && 673 if (old_shortcut_appended_name.empty() &&
676 create_mode == UPDATE_EXISTING_ONLY && 674 create_mode == UPDATE_EXISTING_ONLY &&
677 action == IGNORE_NON_PROFILE_SHORTCUTS) { 675 action == IGNORE_NON_PROFILE_SHORTCUTS) {
678 return; 676 return;
679 } 677 }
680 678
681 string16 new_shortcut_appended_name; 679 string16 new_shortcut_appended_name;
682 if (!remove_badging) 680 if (!is_last_profile)
683 new_shortcut_appended_name = cache->GetNameOfProfileAtIndex(profile_index); 681 new_shortcut_appended_name = cache->GetNameOfProfileAtIndex(profile_index);
684 682
683 BrowserThread::PostTask(
684 BrowserThread::FILE, FROM_HERE,
685 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path,
686 old_shortcut_appended_name, new_shortcut_appended_name,
687 create_mode, action));
688
689 cache->SetShortcutNameOfProfileAtIndex(profile_index,
690 new_shortcut_appended_name);
691 }
692
693 void ProfileShortcutManagerWin::CreateOrUpdateShortcutIconForProfileAtPath(
694 const base::FilePath& profile_path) {
695 ProfileInfoCache* cache = &profile_manager_->GetProfileInfoCache();
696 size_t profile_index = cache->GetIndexOfProfileWithPath(profile_path);
697 if (profile_index == std::string::npos)
698 return;
699 bool remove_badging = cache->GetNumberOfProfiles() == 1;
700
685 SkBitmap avatar_bitmap_copy_1x; 701 SkBitmap avatar_bitmap_copy_1x;
686 SkBitmap avatar_bitmap_copy_2x; 702 SkBitmap avatar_bitmap_copy_2x;
687 if (!remove_badging) { 703 if (!remove_badging) {
688 const size_t icon_index = 704 const size_t icon_index =
689 cache->GetAvatarIconIndexOfProfileAtIndex(profile_index); 705 cache->GetAvatarIconIndexOfProfileAtIndex(profile_index);
690 const int resource_id_1x = 706 const int resource_id_1x =
691 cache->GetDefaultAvatarIconResourceIDAtIndex(icon_index); 707 cache->GetDefaultAvatarIconResourceIDAtIndex(icon_index);
692 const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; 708 const int resource_id_2x = kProfileAvatarIconResources2x[icon_index];
693 // Make a copy of the SkBitmaps to ensure that we can safely use the image 709 // Make a copy of the SkBitmaps to ensure that we can safely use the image
694 // data on the FILE thread. 710 // data on the FILE thread.
695 avatar_bitmap_copy_1x = GetImageResourceSkBitmapCopy(resource_id_1x); 711 avatar_bitmap_copy_1x = GetImageResourceSkBitmapCopy(resource_id_1x);
696 avatar_bitmap_copy_2x = GetImageResourceSkBitmapCopy(resource_id_2x); 712 avatar_bitmap_copy_2x = GetImageResourceSkBitmapCopy(resource_id_2x);
697 } 713 }
698 BrowserThread::PostTask( 714 BrowserThread::PostTask(
699 BrowserThread::FILE, FROM_HERE, 715 BrowserThread::FILE, FROM_HERE,
700 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, 716 base::Bind(&CreateOrUpdateShortcutIconForProfile, profile_path,
701 old_shortcut_appended_name, new_shortcut_appended_name, 717 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x));
702 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode,
703 action));
704
705 cache->SetShortcutNameOfProfileAtIndex(profile_index,
706 new_shortcut_appended_name);
707 } 718 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_shortcut_manager_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698