Chromium Code Reviews| Index: chrome/browser/chromeos/profiles/profile_helper.cc |
| diff --git a/chrome/browser/chromeos/profiles/profile_helper.cc b/chrome/browser/chromeos/profiles/profile_helper.cc |
| index 155084ef1dd5f58c9bb98c48c47e59a3adc97c51..e47d96ad0ea06d8e8b2d0d9ebece864c157bb97d 100644 |
| --- a/chrome/browser/chromeos/profiles/profile_helper.cc |
| +++ b/chrome/browser/chromeos/profiles/profile_helper.cc |
| @@ -177,7 +177,7 @@ bool ProfileHelper::IsOwnerProfile(Profile* profile) { |
| return user->email() == chromeos::UserManager::Get()->GetOwnerEmail(); |
| } |
| -//static |
| +// static |
| bool ProfileHelper::IsPrimaryProfile(Profile* profile) { |
| if (!profile) |
| return false; |
| @@ -245,8 +245,32 @@ Profile* ProfileHelper::GetProfileByUser(const user_manager::User* user) { |
| Profile* profile = NULL; |
| if (user->is_profile_created()) |
|
Thiemo Nagel
2014/08/11 14:39:54
Nit: I think it would be more readable to turn the
dzhioev (left Google)
2014/08/12 14:56:28
Done.
|
| profile = ProfileHelper::GetProfileByUserIdHash(user->username_hash()); |
| - else |
| + |
| + // GetActiveUserProfile() or GetProfileByUserIdHash() returns a new instance |
| + // of ProfileImpl(), but actually its OffTheRecordProfile() should be used. |
| + if (profile && UserManager::Get()->IsLoggedInAsGuest()) |
| + profile = profile->GetOffTheRecordProfile(); |
| + return profile; |
|
Nikita (slow)
2014/08/11 12:29:24
nit: Insert empty line before return.
dzhioev (left Google)
2014/08/12 14:56:28
Done.
|
| +} |
| + |
| +Profile* ProfileHelper::GetProfileByUserUnsafe(const user_manager::User* user) { |
| + // This map is non-empty only in tests. |
| + if (!user_to_profile_for_testing_.empty()) { |
| + std::map<const user_manager::User*, Profile*>::const_iterator it = |
| + user_to_profile_for_testing_.find(user); |
| + return it == user_to_profile_for_testing_.end() ? NULL : it->second; |
| + } |
| + |
| + Profile* profile = NULL; |
| + if (user->is_profile_created()) { |
| + profile = ProfileHelper::GetProfileByUserIdHash(user->username_hash()); |
| + } else { |
| + LOG(WARNING) << "ProfileHelper::GetProfileByUserUnsafe is called when " |
|
Nikita (slow)
2014/08/11 12:29:24
I don't think it's a good idea to commit this WARN
Thiemo Nagel
2014/08/11 14:39:54
How about DLOG() instead of LOG()?
dzhioev (left Google)
2014/08/12 14:56:28
Now this message shoots only once on adding user i
|
| + "|user|'s profile is not created. It probably means that " |
| + "something is wrong with a calling code. Please report in " |
| + "http://crbug.com/361528 if you see this message."; |
| profile = ProfileManager::GetActiveUserProfile(); |
| + } |
| // GetActiveUserProfile() or GetProfileByUserIdHash() returns a new instance |
| // of ProfileImpl(), but actually its OffTheRecordProfile() should be used. |