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

Side by Side Diff: chrome/browser/ui/webui/settings/profile_info_handler.cc

Issue 2807373003: MD Settings: get the avatar icon the same way the user switcher does (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // issues with caching. 199 // issues with caching.
200 scoped_refptr<base::RefCountedMemory> image = 200 scoped_refptr<base::RefCountedMemory> image =
201 chromeos::options::UserImageSource::GetUserImage(user->GetAccountId()); 201 chromeos::options::UserImageSource::GetUserImage(user->GetAccountId());
202 icon_url = webui::GetPngDataUrl(image->front(), image->size()); 202 icon_url = webui::GetPngDataUrl(image->front(), image->size());
203 #else // !defined(OS_CHROMEOS) 203 #else // !defined(OS_CHROMEOS)
204 ProfileAttributesEntry* entry; 204 ProfileAttributesEntry* entry;
205 if (g_browser_process->profile_manager() 205 if (g_browser_process->profile_manager()
206 ->GetProfileAttributesStorage() 206 ->GetProfileAttributesStorage()
207 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { 207 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
208 name = base::UTF16ToUTF8(entry->GetName()); 208 name = base::UTF16ToUTF8(entry->GetName());
209 209 // TODO(dbeam): special case chrome://theme/IDR_PROFILE_AVATAR_* in
210 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) { 210 // theme_source.cc.
dschuyler 2017/04/11 22:58:54 Could we say something about why, like: to avoid u
Dan Beam 2017/04/11 23:02:30 Done.
211 constexpr int kAvatarIconSize = 40; 211 constexpr int kAvatarIconSize = 40;
212 gfx::Image icon = profiles::GetSizedAvatarIcon( 212 gfx::Image icon = profiles::GetSizedAvatarIcon(
213 entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize); 213 entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize);
214 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap()); 214 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap());
215 } else {
216 icon_url = profiles::GetDefaultAvatarIconUrl(entry->GetAvatarIconIndex());
217 }
218 } 215 }
219 #endif // defined(OS_CHROMEOS) 216 #endif // defined(OS_CHROMEOS)
220 217
221 base::DictionaryValue* response = new base::DictionaryValue(); 218 base::DictionaryValue* response = new base::DictionaryValue();
222 response->SetString("name", name); 219 response->SetString("name", name);
223 response->SetString("iconUrl", icon_url); 220 response->SetString("iconUrl", icon_url);
224 return base::WrapUnique(response); 221 return base::WrapUnique(response);
225 } 222 }
226 223
227 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { 224 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const {
228 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); 225 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty();
229 } 226 }
230 227
231 } // namespace settings 228 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698