| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/settings/profile_info_handler.h" | 5 #include "chrome/browser/ui/webui/settings/profile_info_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 base::Value(kProfileManagesSupervisedUsersChangedEventName), | 181 base::Value(kProfileManagesSupervisedUsersChangedEventName), |
| 182 base::Value(IsProfileManagingSupervisedUsers())); | 182 base::Value(IsProfileManagingSupervisedUsers())); |
| 183 } | 183 } |
| 184 | 184 |
| 185 std::unique_ptr<base::DictionaryValue> | 185 std::unique_ptr<base::DictionaryValue> |
| 186 ProfileInfoHandler::GetAccountNameAndIcon() const { | 186 ProfileInfoHandler::GetAccountNameAndIcon() const { |
| 187 std::string name; | 187 std::string name; |
| 188 std::string icon_url; | 188 std::string icon_url; |
| 189 | 189 |
| 190 #if defined(OS_CHROMEOS) | 190 #if defined(OS_CHROMEOS) |
| 191 name = profile_->GetProfileUserName(); | 191 const user_manager::User* user = |
| 192 std::string user_email; | 192 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 193 if (name.empty()) { | 193 DCHECK(user); |
| 194 // User is not associated with a gaia account, use the display name. | 194 name = base::UTF16ToUTF8(user->GetDisplayName()); |
| 195 const user_manager::User* user = | 195 std::string user_email = profile_->GetProfileUserName(); |
| 196 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 196 if (user_email.empty()) { |
| 197 // Note: We don't show the User section in Guest mode. | 197 // User is not associated with a gaia account. |
| 198 DCHECK(user && (user->GetType() != user_manager::USER_TYPE_GUEST)); | |
| 199 name = base::UTF16ToUTF8(user->GetDisplayName()); | |
| 200 user_email = user->GetAccountId().GetUserEmail(); | 198 user_email = user->GetAccountId().GetUserEmail(); |
| 201 } else { | |
| 202 name = gaia::SanitizeEmail(gaia::CanonicalizeEmail(name)); | |
| 203 user_email = name; | |
| 204 } | 199 } |
| 205 | 200 |
| 206 // Get image as data URL instead of using chrome://userimage source to avoid | 201 // Get image as data URL instead of using chrome://userimage source to avoid |
| 207 // issues with caching. | 202 // issues with caching. |
| 208 const AccountId account_id(AccountId::FromUserEmail(user_email)); | 203 const AccountId account_id(AccountId::FromUserEmail(user_email)); |
| 209 scoped_refptr<base::RefCountedMemory> image = | 204 scoped_refptr<base::RefCountedMemory> image = |
| 210 chromeos::options::UserImageSource::GetUserImage(account_id); | 205 chromeos::options::UserImageSource::GetUserImage(account_id); |
| 211 icon_url = webui::GetPngDataUrl(image->front(), image->size()); | 206 icon_url = webui::GetPngDataUrl(image->front(), image->size()); |
| 212 #else // !defined(OS_CHROMEOS) | 207 #else // !defined(OS_CHROMEOS) |
| 213 ProfileAttributesEntry* entry; | 208 ProfileAttributesEntry* entry; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 230 response->SetString("name", name); | 225 response->SetString("name", name); |
| 231 response->SetString("iconUrl", icon_url); | 226 response->SetString("iconUrl", icon_url); |
| 232 return base::WrapUnique(response); | 227 return base::WrapUnique(response); |
| 233 } | 228 } |
| 234 | 229 |
| 235 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { | 230 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { |
| 236 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 231 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 237 } | 232 } |
| 238 | 233 |
| 239 } // namespace settings | 234 } // namespace settings |
| OLD | NEW |