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

Unified Diff: chrome/browser/chromeos/profiles/profile_helper.cc

Issue 445353004: GetProfileByUser deprecated and renamed to GetProfileByUserUnsafe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.h ('k') | chrome/browser/extensions/extension_assets_manager_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698