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_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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 std::vector<base::FilePath>::const_iterator it; | 1231 std::vector<base::FilePath>::const_iterator it; |
1232 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { | 1232 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { |
1233 size_t profile_index = GetIndexOfProfileWithPath(*it); | 1233 size_t profile_index = GetIndexOfProfileWithPath(*it); |
1234 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); | 1234 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); |
1235 // This will assign a new "Person %d" type name and re-sort the cache. | 1235 // This will assign a new "Person %d" type name and re-sort the cache. |
1236 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( | 1236 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( |
1237 GetAvatarIconIndexOfProfileAtIndex(profile_index))); | 1237 GetAvatarIconIndexOfProfileAtIndex(profile_index))); |
1238 } | 1238 } |
1239 #endif | 1239 #endif |
1240 } | 1240 } |
1241 | |
1242 // ProfileMetadataStorage implementation | |
Mike Lerman
2015/07/02 18:01:30
I think you can remove this comment.
anthonyvd
2015/07/07 21:05:32
Done.
| |
1243 void ProfileInfoCache::AddProfile( | |
1244 const base::FilePath& profile_path, | |
1245 const base::string16& name, | |
1246 const std::string& gaia_id, | |
1247 const base::string16& user_name, | |
1248 size_t icon_index, | |
1249 const std::string& supervised_user_id) { | |
1250 AddProfileToCache( | |
1251 profile_path, name, gaia_id, user_name, icon_index, supervised_user_id); | |
1252 } | |
1253 | |
1254 void ProfileInfoCache::DeleteProfile(const base::FilePath& profile_path) { | |
1255 DeleteProfileFromCache(profile_path); | |
1256 } | |
1257 | |
1258 std::vector<ProfileAttributesEntry> | |
1259 ProfileInfoCache::GetAllProfilesAttributes() { | |
1260 std::vector<ProfileAttributesEntry> ret; | |
1261 for (size_t i = 0; i < GetNumberOfProfiles(); ++i) { | |
1262 ProfileAttributesEntry entry(this, i); | |
1263 ret.push_back(entry); | |
1264 } | |
1265 return ret; | |
1266 } | |
1267 | |
1268 bool ProfileInfoCache::GetProfileAttributesWithPath( | |
1269 const base::FilePath& path, ProfileAttributesEntry* entry) { | |
1270 if (GetNumberOfProfiles() == 0) { | |
1271 return false; | |
1272 } | |
1273 | |
1274 size_t index = GetIndexOfProfileWithPath(path); | |
1275 if (index == std::string::npos) { | |
1276 return false; | |
1277 } | |
1278 | |
1279 *entry = ProfileAttributesEntry(this, index); | |
Mike Lerman
2015/07/02 18:01:30
you're explicitly making use of operator=(). You s
Mike Lerman
2015/07/02 18:01:30
This is fragile because the index of a Profile can
anthonyvd
2015/07/07 21:05:32
Having the storage own the entries makes DISALLOW_
anthonyvd
2015/07/07 21:05:32
You're absolutely right, done.
In the future thou
| |
1280 return true; | |
1281 } | |
OLD | NEW |