Chromium Code Reviews| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 | 609 |
| 610 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 610 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 611 base::Bind(&DeleteDesktopShortcutsAndIconFile, | 611 base::Bind(&DeleteDesktopShortcutsAndIconFile, |
| 612 profile_path, | 612 profile_path, |
| 613 deleting_down_to_last_profile)); | 613 deleting_down_to_last_profile)); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void ProfileShortcutManagerWin::OnProfileNameChanged( | 616 void ProfileShortcutManagerWin::OnProfileNameChanged( |
| 617 const base::FilePath& profile_path, | 617 const base::FilePath& profile_path, |
| 618 const string16& old_profile_name) { | 618 const string16& old_profile_name) { |
| 619 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, | 619 // Don't update any shortcuts if none were ever created, as indicated by no |
| 620 IGNORE_NON_PROFILE_SHORTCUTS); | 620 // shortcut name being set in the profile info cache. |
| 621 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | |
| 622 const size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); | |
| 623 if (!cache.GetShortcutNameOfProfileAtIndex(profile_index).empty()) { | |
|
sail
2013/02/20 00:03:52
You already have UPDATE_EXISTING_ONLY and you pass
Alexei Svitkine (slow)
2013/02/20 00:21:16
See the call in the "else if" in OnProfileAdded().
| |
| 624 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, | |
| 625 IGNORE_NON_PROFILE_SHORTCUTS); | |
| 626 } | |
| 621 } | 627 } |
| 622 | 628 |
| 623 void ProfileShortcutManagerWin::OnProfileAvatarChanged( | 629 void ProfileShortcutManagerWin::OnProfileAvatarChanged( |
| 624 const base::FilePath& profile_path) { | 630 const base::FilePath& profile_path) { |
| 625 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, | 631 // Don't update any shortcuts if none were ever created, as indicated by no |
| 626 IGNORE_NON_PROFILE_SHORTCUTS); | 632 // shortcut name being set in the profile info cache. |
| 633 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | |
| 634 const size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); | |
| 635 if (!cache.GetShortcutNameOfProfileAtIndex(profile_index).empty()) { | |
| 636 CreateOrUpdateShortcutsForProfileAtPath(profile_path, UPDATE_EXISTING_ONLY, | |
| 637 IGNORE_NON_PROFILE_SHORTCUTS); | |
| 638 } | |
| 627 } | 639 } |
| 628 | 640 |
| 629 base::FilePath ProfileShortcutManagerWin::GetOtherProfilePath( | 641 base::FilePath ProfileShortcutManagerWin::GetOtherProfilePath( |
| 630 const base::FilePath& profile_path) { | 642 const base::FilePath& profile_path) { |
| 631 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | 643 const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); |
| 632 DCHECK_EQ(2U, cache.GetNumberOfProfiles()); | 644 DCHECK_EQ(2U, cache.GetNumberOfProfiles()); |
| 633 // Get the index of the current profile, in order to find the index of the | 645 // Get the index of the current profile, in order to find the index of the |
| 634 // other profile. | 646 // other profile. |
| 635 size_t current_profile_index = cache.GetIndexOfProfileWithPath(profile_path); | 647 size_t current_profile_index = cache.GetIndexOfProfileWithPath(profile_path); |
| 636 size_t other_profile_index = (current_profile_index == 0) ? 1 : 0; | 648 size_t other_profile_index = (current_profile_index == 0) ? 1 : 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 BrowserThread::PostTask( | 682 BrowserThread::PostTask( |
| 671 BrowserThread::FILE, FROM_HERE, | 683 BrowserThread::FILE, FROM_HERE, |
| 672 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, | 684 base::Bind(&CreateOrUpdateDesktopShortcutsForProfile, profile_path, |
| 673 old_shortcut_appended_name, new_shortcut_appended_name, | 685 old_shortcut_appended_name, new_shortcut_appended_name, |
| 674 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, | 686 avatar_bitmap_copy_1x, avatar_bitmap_copy_2x, create_mode, |
| 675 action)); | 687 action)); |
| 676 | 688 |
| 677 cache->SetShortcutNameOfProfileAtIndex(profile_index, | 689 cache->SetShortcutNameOfProfileAtIndex(profile_index, |
| 678 new_shortcut_appended_name); | 690 new_shortcut_appended_name); |
| 679 } | 691 } |
| OLD | NEW |