OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 6 #include "chrome/browser/profiles/profile_info_cache.h" |
| 7 |
| 8 ProfileAttributesEntry::ProfileAttributesEntry() |
| 9 : profile_info_cache_(nullptr), |
| 10 profile_path_(base::FilePath()) {} |
| 11 |
| 12 void ProfileAttributesEntry::Initialize( |
| 13 ProfileInfoCache* cache, const base::FilePath& path) { |
| 14 DCHECK(!profile_info_cache_); |
| 15 DCHECK(cache); |
| 16 profile_info_cache_ = cache; |
| 17 DCHECK(profile_path_.empty()); |
| 18 DCHECK(!path.empty()); |
| 19 profile_path_ = path; |
| 20 } |
| 21 |
| 22 base::string16 ProfileAttributesEntry::GetName() const { |
| 23 return profile_info_cache_->GetNameOfProfileAtIndex(profile_index()); |
| 24 } |
| 25 |
| 26 base::string16 ProfileAttributesEntry::GetShortcutName() const { |
| 27 return profile_info_cache_->GetShortcutNameOfProfileAtIndex(profile_index()); |
| 28 } |
| 29 |
| 30 base::FilePath ProfileAttributesEntry::GetPath() const { |
| 31 return profile_info_cache_->GetPathOfProfileAtIndex(profile_index()); |
| 32 } |
| 33 |
| 34 base::Time ProfileAttributesEntry::GetActiveTime() const { |
| 35 return profile_info_cache_->GetProfileActiveTimeAtIndex(profile_index()); |
| 36 } |
| 37 |
| 38 base::string16 ProfileAttributesEntry::GetUserName() const { |
| 39 return profile_info_cache_->GetUserNameOfProfileAtIndex(profile_index()); |
| 40 } |
| 41 |
| 42 const gfx::Image& ProfileAttributesEntry::GetAvatarIcon() { |
| 43 return profile_info_cache_->GetAvatarIconOfProfileAtIndex(profile_index()); |
| 44 } |
| 45 |
| 46 std::string ProfileAttributesEntry::GetLocalAuthCredentials() const { |
| 47 return profile_info_cache_->GetLocalAuthCredentialsOfProfileAtIndex( |
| 48 profile_index()); |
| 49 } |
| 50 |
| 51 std::string ProfileAttributesEntry::GetPasswordChangeDetectionToken() const { |
| 52 return profile_info_cache_->GetPasswordChangeDetectionTokenAtIndex( |
| 53 profile_index()); |
| 54 } |
| 55 |
| 56 bool ProfileAttributesEntry::GetBackgroundStatus() const { |
| 57 return profile_info_cache_->GetBackgroundStatusOfProfileAtIndex( |
| 58 profile_index()); |
| 59 } |
| 60 |
| 61 base::string16 ProfileAttributesEntry::GetGAIAName() const { |
| 62 return profile_info_cache_->GetGAIANameOfProfileAtIndex(profile_index()); |
| 63 } |
| 64 |
| 65 base::string16 ProfileAttributesEntry::GetGAIAGivenName() const { |
| 66 return profile_info_cache_->GetGAIAGivenNameOfProfileAtIndex(profile_index()); |
| 67 } |
| 68 |
| 69 std::string ProfileAttributesEntry::GetGAIAId() const { |
| 70 return profile_info_cache_->GetGAIAIdOfProfileAtIndex(profile_index()); |
| 71 } |
| 72 |
| 73 const gfx::Image* ProfileAttributesEntry::GetGAIAPicture() const { |
| 74 return profile_info_cache_->GetGAIAPictureOfProfileAtIndex(profile_index()); |
| 75 } |
| 76 |
| 77 bool ProfileAttributesEntry::IsUsingGAIAPicture() const { |
| 78 return profile_info_cache_->IsUsingGAIAPictureOfProfileAtIndex( |
| 79 profile_index()); |
| 80 } |
| 81 |
| 82 bool ProfileAttributesEntry::IsSupervised() const { |
| 83 return profile_info_cache_->ProfileIsSupervisedAtIndex(profile_index()); |
| 84 } |
| 85 |
| 86 bool ProfileAttributesEntry::IsChild() const { |
| 87 return profile_info_cache_->ProfileIsChildAtIndex(profile_index()); |
| 88 } |
| 89 |
| 90 bool ProfileAttributesEntry::IsLegacySupervised() const { |
| 91 return profile_info_cache_->ProfileIsLegacySupervisedAtIndex(profile_index()); |
| 92 } |
| 93 |
| 94 bool ProfileAttributesEntry::IsOmitted() const { |
| 95 return profile_info_cache_->IsOmittedProfileAtIndex(profile_index()); |
| 96 } |
| 97 |
| 98 bool ProfileAttributesEntry::IsSigninRequired() const { |
| 99 return profile_info_cache_->ProfileIsSigninRequiredAtIndex(profile_index()); |
| 100 } |
| 101 |
| 102 std::string ProfileAttributesEntry::GetSupervisedUserId() const { |
| 103 return profile_info_cache_->GetSupervisedUserIdOfProfileAtIndex( |
| 104 profile_index()); |
| 105 } |
| 106 |
| 107 bool ProfileAttributesEntry::IsEphemeral() const { |
| 108 return profile_info_cache_->ProfileIsEphemeralAtIndex(profile_index()); |
| 109 } |
| 110 |
| 111 bool ProfileAttributesEntry::IsUsingDefaultName() const { |
| 112 return profile_info_cache_->ProfileIsUsingDefaultNameAtIndex(profile_index()); |
| 113 } |
| 114 |
| 115 bool ProfileAttributesEntry::IsAuthenticated() const { |
| 116 return profile_info_cache_->ProfileIsAuthenticatedAtIndex(profile_index()); |
| 117 } |
| 118 |
| 119 bool ProfileAttributesEntry::IsUsingDefaultAvatar() const { |
| 120 return profile_info_cache_->ProfileIsUsingDefaultAvatarAtIndex( |
| 121 profile_index()); |
| 122 } |
| 123 |
| 124 bool ProfileAttributesEntry::IsAuthError() const { |
| 125 return profile_info_cache_->ProfileIsAuthErrorAtIndex(profile_index()); |
| 126 } |
| 127 |
| 128 size_t ProfileAttributesEntry::GetAvatarIconIndex() const { |
| 129 return profile_info_cache_->GetAvatarIconIndexOfProfileAtIndex( |
| 130 profile_index()); |
| 131 } |
| 132 |
| 133 void ProfileAttributesEntry::SetName(const base::string16& name) { |
| 134 profile_info_cache_->SetNameOfProfileAtIndex(profile_index(), name); |
| 135 } |
| 136 |
| 137 void ProfileAttributesEntry::SetShortcutName(const base::string16& name) { |
| 138 profile_info_cache_->SetShortcutNameOfProfileAtIndex(profile_index(), name); |
| 139 } |
| 140 |
| 141 void ProfileAttributesEntry::SetIsOmitted(bool is_omitted) { |
| 142 profile_info_cache_->SetIsOmittedProfileAtIndex(profile_index(), is_omitted); |
| 143 } |
| 144 |
| 145 void ProfileAttributesEntry::SetSupervisedUserId(const std::string& id) { |
| 146 profile_info_cache_->SetSupervisedUserIdOfProfileAtIndex(profile_index(), id); |
| 147 } |
| 148 |
| 149 void ProfileAttributesEntry::SetLocalAuthCredentials(const std::string& auth) { |
| 150 profile_info_cache_->SetLocalAuthCredentialsOfProfileAtIndex( |
| 151 profile_index(), auth); |
| 152 } |
| 153 |
| 154 void ProfileAttributesEntry::SetPasswordChangeDetectionToken( |
| 155 const std::string& token) { |
| 156 profile_info_cache_->SetPasswordChangeDetectionTokenAtIndex( |
| 157 profile_index(), token); |
| 158 } |
| 159 |
| 160 void ProfileAttributesEntry::SetBackgroundStatus(bool running_background_apps) { |
| 161 profile_info_cache_->SetBackgroundStatusOfProfileAtIndex( |
| 162 profile_index(), running_background_apps); |
| 163 } |
| 164 |
| 165 void ProfileAttributesEntry::SetGAIAName(const base::string16& name) { |
| 166 profile_info_cache_->SetGAIANameOfProfileAtIndex(profile_index(), name); |
| 167 } |
| 168 |
| 169 void ProfileAttributesEntry::SetGAIAGivenName(const base::string16& name) { |
| 170 profile_info_cache_->SetGAIAGivenNameOfProfileAtIndex(profile_index(), name); |
| 171 } |
| 172 |
| 173 void ProfileAttributesEntry::SetGAIAPicture(const gfx::Image* image) { |
| 174 profile_info_cache_->SetGAIAPictureOfProfileAtIndex(profile_index(), image); |
| 175 } |
| 176 |
| 177 void ProfileAttributesEntry::SetIsUsingGAIAPicture(bool value) { |
| 178 profile_info_cache_->SetIsUsingGAIAPictureOfProfileAtIndex( |
| 179 profile_index(), value); |
| 180 } |
| 181 |
| 182 void ProfileAttributesEntry::SetIsSigninRequired(bool value) { |
| 183 profile_info_cache_->SetProfileSigninRequiredAtIndex(profile_index(), value); |
| 184 } |
| 185 |
| 186 void ProfileAttributesEntry::SetIsEphemeral(bool value) { |
| 187 profile_info_cache_->SetProfileIsEphemeralAtIndex(profile_index(), value); |
| 188 } |
| 189 |
| 190 void ProfileAttributesEntry::SetIsUsingDefaultName(bool value) { |
| 191 profile_info_cache_->SetProfileIsUsingDefaultNameAtIndex( |
| 192 profile_index(), value); |
| 193 } |
| 194 |
| 195 void ProfileAttributesEntry::SetIsUsingDefaultAvatar(bool value) { |
| 196 profile_info_cache_->SetProfileIsUsingDefaultAvatarAtIndex( |
| 197 profile_index(), value); |
| 198 } |
| 199 |
| 200 void ProfileAttributesEntry::SetIsAuthError(bool value) { |
| 201 profile_info_cache_->SetProfileIsAuthErrorAtIndex(profile_index(), value); |
| 202 } |
| 203 |
| 204 void ProfileAttributesEntry::SetAvatarIconIndex(size_t icon_index) { |
| 205 profile_info_cache_->SetAvatarIconOfProfileAtIndex( |
| 206 profile_index(), icon_index); |
| 207 } |
| 208 |
| 209 void ProfileAttributesEntry::SetAuthInfo( |
| 210 const std::string& gaia_id, const base::string16& user_name) { |
| 211 profile_info_cache_->SetAuthInfoOfProfileAtIndex( |
| 212 profile_index(), gaia_id, user_name); |
| 213 } |
| 214 |
| 215 size_t ProfileAttributesEntry::profile_index() const { |
| 216 size_t index = profile_info_cache_->GetIndexOfProfileWithPath(profile_path_); |
| 217 DCHECK(index < profile_info_cache_->GetNumberOfProfiles()); |
| 218 return index; |
| 219 } |
OLD | NEW |