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

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

Issue 898003002: [Cleanup] Const-correct the profile() method for the EasyUnlockService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 793376810cfd5d01f107167c88aa14a176c8dd34..9f78be2c6245fd382d14063d8b40b9e4c2368a73 100644
--- a/chrome/browser/chromeos/profiles/profile_helper.cc
+++ b/chrome/browser/chromeos/profiles/profile_helper.cc
@@ -109,7 +109,7 @@ Profile* ProfileHelper::GetSigninProfile() {
}
// static
-std::string ProfileHelper::GetUserIdHashFromProfile(Profile* profile) {
+std::string ProfileHelper::GetUserIdHashFromProfile(const Profile* profile) {
if (!profile)
return std::string();
@@ -140,7 +140,7 @@ base::FilePath ProfileHelper::GetUserProfileDir(
}
// static
-bool ProfileHelper::IsSigninProfile(Profile* profile) {
+bool ProfileHelper::IsSigninProfile(const Profile* profile) {
return profile->GetPath().BaseName().value() == chrome::kInitialProfile;
}
@@ -148,7 +148,8 @@ bool ProfileHelper::IsSigninProfile(Profile* profile) {
bool ProfileHelper::IsOwnerProfile(Profile* profile) {
if (!profile)
return false;
- user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
+ const user_manager::User* user =
+ ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return false;
@@ -156,10 +157,11 @@ bool ProfileHelper::IsOwnerProfile(Profile* profile) {
}
// static
-bool ProfileHelper::IsPrimaryProfile(Profile* profile) {
+bool ProfileHelper::IsPrimaryProfile(const Profile* profile) {
if (!profile)
return false;
- user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
+ const user_manager::User* user =
+ ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return false;
return user == user_manager::UserManager::Get()->GetPrimaryUser();
@@ -260,12 +262,12 @@ Profile* ProfileHelper::GetProfileByUserUnsafe(const user_manager::User* user) {
return profile;
}
-user_manager::User* ProfileHelper::GetUserByProfile(Profile* profile) {
+const user_manager::User* ProfileHelper::GetUserByProfile(
+ const Profile* profile) const {
// This map is non-empty only in tests.
if (enable_profile_to_user_testing || !user_list_for_testing_.empty()) {
if (always_return_primary_user_for_testing)
- return const_cast<user_manager::User*>(
- user_manager::UserManager::Get()->GetPrimaryUser());
+ return user_manager::UserManager::Get()->GetPrimaryUser();
const std::string& user_name = profile->GetProfileUserName();
for (user_manager::UserList::const_iterator it =
@@ -277,8 +279,7 @@ user_manager::User* ProfileHelper::GetUserByProfile(Profile* profile) {
}
// In case of test setup we should always default to primary user.
- return const_cast<user_manager::User*>(
- user_manager::UserManager::Get()->GetPrimaryUser());
+ return user_manager::UserManager::Get()->GetPrimaryUser();
}
DCHECK(!content::BrowserThread::IsThreadInitialized(
@@ -314,10 +315,15 @@ user_manager::User* ProfileHelper::GetUserByProfile(Profile* profile) {
return active_user &&
ProfileHelper::GetProfilePathByUserIdHash(
active_user->username_hash()) == profile->GetPath()
- ? const_cast<user_manager::User*>(active_user)
+ ? active_user
: NULL;
}
+user_manager::User* ProfileHelper::GetUserByProfile(Profile* profile) const {
+ return const_cast<user_manager::User*>(
+ GetUserByProfile(static_cast<const Profile*>(profile)));
+}
+
////////////////////////////////////////////////////////////////////////////////
// ProfileHelper, BrowsingDataRemover::Observer implementation:
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.h ('k') | chrome/browser/policy/profile_policy_connector_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698