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_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 info = iter->second.get(); | 413 info = iter->second.get(); |
414 } else { | 414 } else { |
415 // Initiate asynchronous creation process. | 415 // Initiate asynchronous creation process. |
416 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false); | 416 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false); |
417 ProfileInfoCache& cache = GetProfileInfoCache(); | 417 ProfileInfoCache& cache = GetProfileInfoCache(); |
418 // Get the icon index from the user's icon url | 418 // Get the icon index from the user's icon url |
419 size_t icon_index; | 419 size_t icon_index; |
420 std::string icon_url_std = base::UTF16ToASCII(icon_url); | 420 std::string icon_url_std = base::UTF16ToASCII(icon_url); |
421 if (profiles::IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) { | 421 if (profiles::IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) { |
422 // add profile to cache with user selected name and avatar | 422 // add profile to cache with user selected name and avatar |
423 cache.AddProfileToCache(profile_path, name, base::string16(), icon_index, | 423 cache.AddProfileToCache(profile_path, name, std::string(), |
424 supervised_user_id); | 424 base::string16(), icon_index, supervised_user_id); |
425 } | 425 } |
426 | 426 |
427 if (!supervised_user_id.empty()) { | 427 if (!supervised_user_id.empty()) { |
428 content::RecordAction( | 428 content::RecordAction( |
429 UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); | 429 UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); |
430 } | 430 } |
431 | 431 |
432 ProfileMetrics::UpdateReportedProfilesStatistics(this); | 432 ProfileMetrics::UpdateReportedProfilesStatistics(this); |
433 } | 433 } |
434 | 434 |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 NonMaliciousDownloadCount() == 0); | 1196 NonMaliciousDownloadCount() == 0); |
1197 BrowserList::CloseAllBrowsersWithProfile(profile); | 1197 BrowserList::CloseAllBrowsersWithProfile(profile); |
1198 | 1198 |
1199 // Disable sync for doomed profile. | 1199 // Disable sync for doomed profile. |
1200 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( | 1200 if (ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
1201 profile)) { | 1201 profile)) { |
1202 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 1202 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
1203 profile)->DisableForUser(); | 1203 profile)->DisableForUser(); |
1204 } | 1204 } |
1205 | 1205 |
1206 bool profile_is_signed_in = !cache.GetUserNameOfProfileAtIndex( | 1206 ProfileMetrics::LogProfileDelete(cache.ProfileIsAuthenticatedAtIndex( |
1207 cache.GetIndexOfProfileWithPath(profile_dir)).empty(); | 1207 cache.GetIndexOfProfileWithPath(profile_dir))); |
1208 ProfileMetrics::LogProfileDelete(profile_is_signed_in); | |
1209 // Some platforms store passwords in keychains. They should be removed. | 1208 // Some platforms store passwords in keychains. They should be removed. |
1210 scoped_refptr<password_manager::PasswordStore> password_store = | 1209 scoped_refptr<password_manager::PasswordStore> password_store = |
1211 PasswordStoreFactory::GetForProfile( | 1210 PasswordStoreFactory::GetForProfile( |
1212 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); | 1211 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); |
1213 if (password_store.get()) { | 1212 if (password_store.get()) { |
1214 password_store->RemoveLoginsCreatedBetween(base::Time(), | 1213 password_store->RemoveLoginsCreatedBetween(base::Time(), |
1215 base::Time::Max()); | 1214 base::Time::Max()); |
1216 } | 1215 } |
1217 | 1216 |
1218 // The Profile Data doesn't get wiped until Chrome closes. Since we promised | 1217 // The Profile Data doesn't get wiped until Chrome closes. Since we promised |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 void ProfileManager::AddProfileToCache(Profile* profile) { | 1249 void ProfileManager::AddProfileToCache(Profile* profile) { |
1251 TRACE_EVENT0("browser", "ProfileManager::AddProfileToCache"); | 1250 TRACE_EVENT0("browser", "ProfileManager::AddProfileToCache"); |
1252 if (profile->IsGuestSession() || profile->IsSystemProfile()) | 1251 if (profile->IsGuestSession() || profile->IsSystemProfile()) |
1253 return; | 1252 return; |
1254 ProfileInfoCache& cache = GetProfileInfoCache(); | 1253 ProfileInfoCache& cache = GetProfileInfoCache(); |
1255 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 1254 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
1256 return; | 1255 return; |
1257 | 1256 |
1258 SigninManagerBase* signin_manager = | 1257 SigninManagerBase* signin_manager = |
1259 SigninManagerFactory::GetForProfile(profile); | 1258 SigninManagerFactory::GetForProfile(profile); |
1260 base::string16 username = base::UTF8ToUTF16( | 1259 AccountTrackerService* account_tracker = |
1261 signin_manager->GetAuthenticatedUsername()); | 1260 AccountTrackerServiceFactory::GetForProfile(profile); |
| 1261 AccountTrackerService::AccountInfo account_info = |
| 1262 account_tracker->GetAccountInfo( |
| 1263 signin_manager->GetAuthenticatedAccountId()); |
| 1264 base::string16 username = base::UTF8ToUTF16(account_info.email); |
1262 | 1265 |
1263 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 1266 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
1264 if (profile_index != std::string::npos) { | 1267 if (profile_index != std::string::npos) { |
1265 // The ProfileInfoCache's username must match the Signin Manager's username. | 1268 // The ProfileInfoCache's info must match the Signin Manager. |
1266 cache.SetUserNameOfProfileAtIndex(profile_index, username); | 1269 cache.SetAuthInfoOfProfileAtIndex(profile_index, account_info.gaia, |
| 1270 username); |
1267 return; | 1271 return; |
1268 } | 1272 } |
1269 | 1273 |
1270 // Profile name and avatar are set by InitProfileUserPrefs and stored in the | 1274 // Profile name and avatar are set by InitProfileUserPrefs and stored in the |
1271 // profile. Use those values to setup the cache entry. | 1275 // profile. Use those values to setup the cache entry. |
1272 base::string16 profile_name = | 1276 base::string16 profile_name = |
1273 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); | 1277 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); |
1274 | 1278 |
1275 size_t icon_index = profile->GetPrefs()->GetInteger( | 1279 size_t icon_index = profile->GetPrefs()->GetInteger( |
1276 prefs::kProfileAvatarIndex); | 1280 prefs::kProfileAvatarIndex); |
1277 | 1281 |
1278 std::string supervised_user_id = | 1282 std::string supervised_user_id = |
1279 profile->GetPrefs()->GetString(prefs::kSupervisedUserId); | 1283 profile->GetPrefs()->GetString(prefs::kSupervisedUserId); |
1280 | 1284 |
1281 cache.AddProfileToCache(profile->GetPath(), | 1285 cache.AddProfileToCache(profile->GetPath(), |
1282 profile_name, | 1286 profile_name, |
| 1287 account_info.gaia, |
1283 username, | 1288 username, |
1284 icon_index, | 1289 icon_index, |
1285 supervised_user_id); | 1290 supervised_user_id); |
1286 | 1291 |
1287 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { | 1292 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { |
1288 cache.SetProfileIsEphemeralAtIndex( | 1293 cache.SetProfileIsEphemeralAtIndex( |
1289 cache.GetIndexOfProfileWithPath(profile->GetPath()), true); | 1294 cache.GetIndexOfProfileWithPath(profile->GetPath()), true); |
1290 } | 1295 } |
1291 } | 1296 } |
1292 | 1297 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 } | 1427 } |
1423 | 1428 |
1424 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1429 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1425 if (!original_callback.is_null()) | 1430 if (!original_callback.is_null()) |
1426 original_callback.Run(loaded_profile, status); | 1431 original_callback.Run(loaded_profile, status); |
1427 } | 1432 } |
1428 | 1433 |
1429 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1434 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1430 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1435 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1431 } | 1436 } |
OLD | NEW |