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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 NonProfileShortcutAction action) { | 643 NonProfileShortcutAction action) { |
644 ProfileInfoCache* cache = &profile_manager_->GetProfileInfoCache(); | 644 ProfileInfoCache* cache = &profile_manager_->GetProfileInfoCache(); |
645 size_t profile_index = cache->GetIndexOfProfileWithPath(profile_path); | 645 size_t profile_index = cache->GetIndexOfProfileWithPath(profile_path); |
646 if (profile_index == std::string::npos) | 646 if (profile_index == std::string::npos) |
647 return; | 647 return; |
648 bool remove_badging = cache->GetNumberOfProfiles() == 1; | 648 bool remove_badging = cache->GetNumberOfProfiles() == 1; |
649 | 649 |
650 string16 old_shortcut_appended_name = | 650 string16 old_shortcut_appended_name = |
651 cache->GetShortcutNameOfProfileAtIndex(profile_index); | 651 cache->GetShortcutNameOfProfileAtIndex(profile_index); |
652 | 652 |
| 653 // Exit early if the mode is to update existing profile shortcuts only and |
| 654 // none were ever created for this profile, per the shortcut name not being |
| 655 // set in the profile info cache. |
| 656 if (old_shortcut_appended_name.empty() && |
| 657 create_mode == UPDATE_EXISTING_ONLY && |
| 658 action == IGNORE_NON_PROFILE_SHORTCUTS) { |
| 659 return; |
| 660 } |
| 661 |
653 string16 new_shortcut_appended_name; | 662 string16 new_shortcut_appended_name; |
654 if (!remove_badging) | 663 if (!remove_badging) |
655 new_shortcut_appended_name = cache->GetNameOfProfileAtIndex(profile_index); | 664 new_shortcut_appended_name = cache->GetNameOfProfileAtIndex(profile_index); |
656 | 665 |
657 SkBitmap avatar_bitmap_copy_1x; | 666 SkBitmap avatar_bitmap_copy_1x; |
658 SkBitmap avatar_bitmap_copy_2x; | 667 SkBitmap avatar_bitmap_copy_2x; |
659 if (!remove_badging) { | 668 if (!remove_badging) { |
660 const size_t icon_index = | 669 const size_t icon_index = |
661 cache->GetAvatarIconIndexOfProfileAtIndex(profile_index); | 670 cache->GetAvatarIconIndexOfProfileAtIndex(profile_index); |
662 const int resource_id_1x = | 671 const int resource_id_1x = |
663 cache->GetDefaultAvatarIconResourceIDAtIndex(icon_index); | 672 cache->GetDefaultAvatarIconResourceIDAtIndex(icon_index); |
664 const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; | 673 const int resource_id_2x = kProfileAvatarIconResources2x[icon_index]; |
665 // Make a copy of the SkBitmaps to ensure that we can safely use the image | 674 // Make a copy of the SkBitmaps to ensure that we can safely use the image |
666 // data on the FILE thread. | 675 // data on the FILE thread. |
667 avatar_bitmap_copy_1x = GetImageResourceSkBitmapCopy(resource_id_1x); | 676 avatar_bitmap_copy_1x = GetImageResourceSkBitmapCopy(resource_id_1x); |
668 avatar_bitmap_copy_2x = GetImageResourceSkBitmapCopy(resource_id_2x); | 677 avatar_bitmap_copy_2x = GetImageResourceSkBitmapCopy(resource_id_2x); |
669 } | 678 } |
670 BrowserThread::PostTask( | 679 BrowserThread::PostTask( |
671 BrowserThread::FILE, FROM_HERE, | 680 BrowserThread::FILE, FROM_HERE, |
672 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, | 681 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, |
673 old_shortcut_appended_name, new_shortcut_appended_name, | 682 old_shortcut_appended_name, new_shortcut_appended_name, |
674 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, | 683 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, |
675 action)); | 684 action)); |
676 | 685 |
677 cache->SetShortcutNameOfProfileAtIndex(profile_index, | 686 cache->SetShortcutNameOfProfileAtIndex(profile_index, |
678 new_shortcut_appended_name); | 687 new_shortcut_appended_name); |
679 } | 688 } |
OLD | NEW |