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

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: dschuyler@ review 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 | chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc » ('j') | 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(crbug.com/710660): return chrome://theme/IDR_PROFILE_AVATAR_*
210 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) { 210 // and update theme_source.cc to get high res avatar icons. This does less
211 constexpr int kAvatarIconSize = 40; 211 // work here, sends less over IPC, and is more stable with returned results.
212 gfx::Image icon = profiles::GetSizedAvatarIcon( 212 constexpr int kAvatarIconSize = 40;
213 entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize); 213 gfx::Image icon = profiles::GetSizedAvatarIcon(
214 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap()); 214 entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize);
215 } else { 215 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap());
216 icon_url = profiles::GetDefaultAvatarIconUrl(entry->GetAvatarIconIndex());
217 }
218 } 216 }
219 #endif // defined(OS_CHROMEOS) 217 #endif // defined(OS_CHROMEOS)
220 218
221 base::DictionaryValue* response = new base::DictionaryValue(); 219 base::DictionaryValue* response = new base::DictionaryValue();
222 response->SetString("name", name); 220 response->SetString("name", name);
223 response->SetString("iconUrl", icon_url); 221 response->SetString("iconUrl", icon_url);
224 return base::WrapUnique(response); 222 return base::WrapUnique(response);
225 } 223 }
226 224
227 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { 225 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const {
228 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); 226 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty();
229 } 227 }
230 228
231 } // namespace settings 229 } // namespace settings
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698