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

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

Issue 974373002: [Profiles] Notify observers if a profile switches bw/ default and custom names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar better code Created 5 years, 9 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 | « no previous file | 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_info_cache.h" 5 #include "chrome/browser/profiles/profile_info_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 info->SetBoolean(kProfileIsEphemeral, value); 732 info->SetBoolean(kProfileIsEphemeral, value);
733 // This takes ownership of |info|. 733 // This takes ownership of |info|.
734 SetInfoForProfileAtIndex(index, info.release()); 734 SetInfoForProfileAtIndex(index, info.release());
735 } 735 }
736 736
737 void ProfileInfoCache::SetProfileIsUsingDefaultNameAtIndex( 737 void ProfileInfoCache::SetProfileIsUsingDefaultNameAtIndex(
738 size_t index, bool value) { 738 size_t index, bool value) {
739 if (value == ProfileIsUsingDefaultNameAtIndex(index)) 739 if (value == ProfileIsUsingDefaultNameAtIndex(index))
740 return; 740 return;
741 741
742 base::string16 old_display_name = GetNameOfProfileAtIndex(index);
743
742 scoped_ptr<base::DictionaryValue> info( 744 scoped_ptr<base::DictionaryValue> info(
743 GetInfoForProfileAtIndex(index)->DeepCopy()); 745 GetInfoForProfileAtIndex(index)->DeepCopy());
744 info->SetBoolean(kIsUsingDefaultNameKey, value); 746 info->SetBoolean(kIsUsingDefaultNameKey, value);
745 // This takes ownership of |info|. 747 // This takes ownership of |info|.
746 SetInfoForProfileAtIndex(index, info.release()); 748 SetInfoForProfileAtIndex(index, info.release());
749
750 base::string16 new_display_name = GetNameOfProfileAtIndex(index);
751 const base::FilePath profile_path = GetPathOfProfileAtIndex(index);
752
753 if (old_display_name != new_display_name) {
754 FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
755 observer_list_,
756 OnProfileNameChanged(profile_path, old_display_name));
757 }
747 } 758 }
748 759
749 void ProfileInfoCache::SetProfileIsUsingDefaultAvatarAtIndex( 760 void ProfileInfoCache::SetProfileIsUsingDefaultAvatarAtIndex(
750 size_t index, bool value) { 761 size_t index, bool value) {
751 if (value == ProfileIsUsingDefaultAvatarAtIndex(index)) 762 if (value == ProfileIsUsingDefaultAvatarAtIndex(index))
752 return; 763 return;
753 764
754 scoped_ptr<base::DictionaryValue> info( 765 scoped_ptr<base::DictionaryValue> info(
755 GetInfoForProfileAtIndex(index)->DeepCopy()); 766 GetInfoForProfileAtIndex(index)->DeepCopy());
756 info->SetBoolean(kIsUsingDefaultAvatarKey, value); 767 info->SetBoolean(kIsUsingDefaultAvatarKey, value);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 std::vector<base::FilePath>::const_iterator it; 1143 std::vector<base::FilePath>::const_iterator it;
1133 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { 1144 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) {
1134 size_t profile_index = GetIndexOfProfileWithPath(*it); 1145 size_t profile_index = GetIndexOfProfileWithPath(*it);
1135 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); 1146 SetProfileIsUsingDefaultNameAtIndex(profile_index, true);
1136 // This will assign a new "Person %d" type name and re-sort the cache. 1147 // This will assign a new "Person %d" type name and re-sort the cache.
1137 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( 1148 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile(
1138 GetAvatarIconIndexOfProfileAtIndex(profile_index))); 1149 GetAvatarIconIndexOfProfileAtIndex(profile_index)));
1139 } 1150 }
1140 #endif 1151 #endif
1141 } 1152 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698