| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 std::unique_ptr<base::DictionaryValue> | 187 std::unique_ptr<base::DictionaryValue> |
| 188 ProfileInfoHandler::GetAccountNameAndIcon() const { | 188 ProfileInfoHandler::GetAccountNameAndIcon() const { |
| 189 std::string name; | 189 std::string name; |
| 190 std::string icon_url; | 190 std::string icon_url; |
| 191 | 191 |
| 192 #if defined(OS_CHROMEOS) | 192 #if defined(OS_CHROMEOS) |
| 193 const user_manager::User* user = | 193 const user_manager::User* user = |
| 194 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 194 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 195 DCHECK(user); | 195 DCHECK(user); |
| 196 name = base::UTF16ToUTF8(user->GetDisplayName()); | 196 name = base::UTF16ToUTF8(user->GetDisplayName()); |
| 197 std::string user_email = profile_->GetProfileUserName(); | |
| 198 if (user_email.empty()) { | |
| 199 // User is not associated with a gaia account. | |
| 200 user_email = user->GetAccountId().GetUserEmail(); | |
| 201 } | |
| 202 | 197 |
| 203 // Get image as data URL instead of using chrome://userimage source to avoid | 198 // Get image as data URL instead of using chrome://userimage source to avoid |
| 204 // issues with caching. | 199 // issues with caching. |
| 205 const AccountId account_id(AccountId::FromUserEmail(user_email)); | |
| 206 scoped_refptr<base::RefCountedMemory> image = | 200 scoped_refptr<base::RefCountedMemory> image = |
| 207 chromeos::options::UserImageSource::GetUserImage(account_id); | 201 chromeos::options::UserImageSource::GetUserImage(user->GetAccountId()); |
| 208 icon_url = webui::GetPngDataUrl(image->front(), image->size()); | 202 icon_url = webui::GetPngDataUrl(image->front(), image->size()); |
| 209 #else // !defined(OS_CHROMEOS) | 203 #else // !defined(OS_CHROMEOS) |
| 210 ProfileAttributesEntry* entry; | 204 ProfileAttributesEntry* entry; |
| 211 if (g_browser_process->profile_manager() | 205 if (g_browser_process->profile_manager() |
| 212 ->GetProfileAttributesStorage() | 206 ->GetProfileAttributesStorage() |
| 213 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { | 207 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { |
| 214 name = base::UTF16ToUTF8(entry->GetName()); | 208 name = base::UTF16ToUTF8(entry->GetName()); |
| 215 | 209 |
| 216 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) { | 210 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) { |
| 217 constexpr int kAvatarIconSize = 40; | 211 constexpr int kAvatarIconSize = 40; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 228 response->SetString("name", name); | 222 response->SetString("name", name); |
| 229 response->SetString("iconUrl", icon_url); | 223 response->SetString("iconUrl", icon_url); |
| 230 return base::WrapUnique(response); | 224 return base::WrapUnique(response); |
| 231 } | 225 } |
| 232 | 226 |
| 233 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { | 227 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { |
| 234 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 228 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 235 } | 229 } |
| 236 | 230 |
| 237 } // namespace settings | 231 } // namespace settings |
| OLD | NEW |