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

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

Issue 2769493002: [MD settings] Scale avatar icon. (Closed)
Patch Set: aternate Created 3 years, 9 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 20 matching lines...) Expand all
31 namespace settings { 31 namespace settings {
32 32
33 // static 33 // static
34 const char ProfileInfoHandler::kProfileInfoChangedEventName[] = 34 const char ProfileInfoHandler::kProfileInfoChangedEventName[] =
35 "profile-info-changed"; 35 "profile-info-changed";
36 const char 36 const char
37 ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName[] = 37 ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName[] =
38 "profile-manages-supervised-users-changed"; 38 "profile-manages-supervised-users-changed";
39 const char ProfileInfoHandler::kProfileStatsCountReadyEventName[] = 39 const char ProfileInfoHandler::kProfileStatsCountReadyEventName[] =
40 "profile-stats-count-ready"; 40 "profile-stats-count-ready";
41 const int kAvatarIconSize = 40;
tommycli 2017/03/22 00:00:22 For this particular variable it may need to be a s
dschuyler 2017/03/22 18:16:06 I've instead moved it near the only place it is us
41 42
42 ProfileInfoHandler::ProfileInfoHandler(Profile* profile) 43 ProfileInfoHandler::ProfileInfoHandler(Profile* profile)
43 : profile_(profile), 44 : profile_(profile),
44 #if defined(OS_CHROMEOS) 45 #if defined(OS_CHROMEOS)
45 user_manager_observer_(this), 46 user_manager_observer_(this),
46 #endif 47 #endif
47 profile_observer_(this), 48 profile_observer_(this),
48 callback_weak_ptr_factory_(this) { 49 callback_weak_ptr_factory_(this) {
49 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
50 // Set up the chrome://userimage/ source. 51 // Set up the chrome://userimage/ source.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 chromeos::options::UserImageSource::GetUserImage(account_id); 208 chromeos::options::UserImageSource::GetUserImage(account_id);
208 icon_url = webui::GetPngDataUrl(image->front(), image->size()); 209 icon_url = webui::GetPngDataUrl(image->front(), image->size());
209 #else // !defined(OS_CHROMEOS) 210 #else // !defined(OS_CHROMEOS)
210 ProfileAttributesEntry* entry; 211 ProfileAttributesEntry* entry;
211 if (g_browser_process->profile_manager() 212 if (g_browser_process->profile_manager()
212 ->GetProfileAttributesStorage() 213 ->GetProfileAttributesStorage()
213 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { 214 .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
214 name = base::UTF16ToUTF8(entry->GetName()); 215 name = base::UTF16ToUTF8(entry->GetName());
215 216
216 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) { 217 if (entry->IsUsingGAIAPicture() && entry->GetGAIAPicture()) {
217 gfx::Image icon = 218 gfx::Image icon = profiles::GetSizedAvatarIcon(
218 profiles::GetAvatarIconForWebUI(entry->GetAvatarIcon(), true); 219 entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize);
219 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap()); 220 icon_url = webui::GetBitmapDataUrl(icon.AsBitmap());
220 } else { 221 } else {
221 icon_url = profiles::GetDefaultAvatarIconUrl(entry->GetAvatarIconIndex()); 222 icon_url = profiles::GetDefaultAvatarIconUrl(entry->GetAvatarIconIndex());
222 } 223 }
223 } 224 }
224 #endif // defined(OS_CHROMEOS) 225 #endif // defined(OS_CHROMEOS)
225 226
226 base::DictionaryValue* response = new base::DictionaryValue(); 227 base::DictionaryValue* response = new base::DictionaryValue();
227 response->SetString("name", name); 228 response->SetString("name", name);
228 response->SetString("iconUrl", icon_url); 229 response->SetString("iconUrl", icon_url);
229 return base::WrapUnique(response); 230 return base::WrapUnique(response);
230 } 231 }
231 232
232 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { 233 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const {
233 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); 234 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty();
234 } 235 }
235 236
236 } // namespace settings 237 } // 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