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

Side by Side Diff: chrome/browser/profiles/profile_avatar_icon_util.cc

Issue 235833002: [Mac] Redesign the avatar bubble UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittest broken by rebase Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/profile_avatar_icon_util.h" 5 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 } // namespace 175 } // namespace
176 176
177 namespace profiles { 177 namespace profiles {
178 178
179 const int kAvatarIconWidth = 38; 179 const int kAvatarIconWidth = 38;
180 const int kAvatarIconHeight = 31; 180 const int kAvatarIconHeight = 31;
181 const int kAvatarIconPadding = 2; 181 const int kAvatarIconPadding = 2;
182 const SkColor kAvatarTutorialBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xf4); 182 const SkColor kAvatarTutorialBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xf4);
183 const SkColor kAvatarTutorialContentTextColor = SkColorSetRGB(0xc6, 0xda, 0xfc); 183 const SkColor kAvatarTutorialContentTextColor = SkColorSetRGB(0xc6, 0xda, 0xfc);
184 const SkColor kAvatarBubbleAccountsBackgroundColor =
185 SkColorSetRGB(0xf3, 0xf3, 0xf3);
184 186
185 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_"; 187 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_";
186 const char kGAIAPictureFileName[] = "Google Profile Picture.png"; 188 const char kGAIAPictureFileName[] = "Google Profile Picture.png";
187 const char kHighResAvatarFolderName[] = "Avatars"; 189 const char kHighResAvatarFolderName[] = "Avatars";
188 190
189 const int kDefaultAvatarIconResources[] = { 191 const int kDefaultAvatarIconResources[] = {
190 IDR_PROFILE_AVATAR_0, 192 IDR_PROFILE_AVATAR_0,
191 IDR_PROFILE_AVATAR_1, 193 IDR_PROFILE_AVATAR_1,
192 IDR_PROFILE_AVATAR_2, 194 IDR_PROFILE_AVATAR_2,
193 IDR_PROFILE_AVATAR_3, 195 IDR_PROFILE_AVATAR_3,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 "avatar_margarita.png", 246 "avatar_margarita.png",
245 "avatar_note.png", 247 "avatar_note.png",
246 "avatar_sun_cloud.png", 248 "avatar_sun_cloud.png",
247 }; 249 };
248 250
249 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources); 251 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources);
250 252
251 // The first 8 icons are generic. 253 // The first 8 icons are generic.
252 const size_t kGenericAvatarIconsCount = 8; 254 const size_t kGenericAvatarIconsCount = 8;
253 255
254 gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image, 256 gfx::Image GetSizedAvatarIcon(const gfx::Image& image,
255 bool is_rectangle, 257 bool is_rectangle,
256 int width, int height) { 258 int width, int height) {
257 if (!is_rectangle) 259 if (!is_rectangle)
258 return image; 260 return image;
259 261
260 gfx::Size size(width, height); 262 gfx::Size size(width, height);
261 263
262 // Source for a centered, sized icon with a border. 264 // Source for a centered, sized icon with a border.
263 scoped_ptr<gfx::ImageSkiaSource> source( 265 scoped_ptr<gfx::ImageSkiaSource> source(
264 new AvatarImageSource( 266 new AvatarImageSource(
265 *image.ToImageSkia(), 267 *image.ToImageSkia(),
266 size, 268 size,
267 std::min(width, height), 269 std::min(width, height),
268 AvatarImageSource::POSITION_CENTER, 270 AvatarImageSource::POSITION_CENTER,
269 AvatarImageSource::BORDER_NORMAL)); 271 AvatarImageSource::BORDER_NONE));
270 272
271 return gfx::Image(gfx::ImageSkia(source.release(), size)); 273 return gfx::Image(gfx::ImageSkia(source.release(), size));
272 } 274 }
273 275
274 gfx::Image GetAvatarIconForMenu(const gfx::Image& image, 276 gfx::Image GetAvatarIconForMenu(const gfx::Image& image,
275 bool is_rectangle) { 277 bool is_rectangle) {
276 return GetSizedAvatarIconWithBorder( 278 return GetSizedAvatarIcon(
277 image, is_rectangle, kAvatarIconWidth, kAvatarIconHeight); 279 image, is_rectangle, kAvatarIconWidth, kAvatarIconHeight);
278 } 280 }
279 281
280 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, 282 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image,
281 bool is_rectangle) { 283 bool is_rectangle) {
282 if (!is_rectangle) 284 return GetSizedAvatarIcon(image, is_rectangle,
283 return image; 285 kAvatarIconWidth, kAvatarIconHeight);
284
285 gfx::Size size(kAvatarIconWidth, kAvatarIconHeight);
286
287 // Source for a centered, sized icon.
288 scoped_ptr<gfx::ImageSkiaSource> source(
289 new AvatarImageSource(
290 *image.ToImageSkia(),
291 size,
292 std::min(kAvatarIconWidth, kAvatarIconHeight),
293 AvatarImageSource::POSITION_CENTER,
294 AvatarImageSource::BORDER_NONE));
295
296 return gfx::Image(gfx::ImageSkia(source.release(), size));
297 } 286 }
298 287
299 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, 288 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
300 bool is_rectangle, 289 bool is_rectangle,
301 int dst_width, 290 int dst_width,
302 int dst_height) { 291 int dst_height) {
303 if (!is_rectangle) 292 if (!is_rectangle)
304 return image; 293 return image;
305 294
306 int size = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), 295 int size = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) 351 int_value >= static_cast<int>(kDefaultAvatarIconsCount))
363 return false; 352 return false;
364 *icon_index = int_value; 353 *icon_index = int_value;
365 return true; 354 return true;
366 } 355 }
367 356
368 return false; 357 return false;
369 } 358 }
370 359
371 } // namespace profiles 360 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.h ('k') | chrome/browser/profiles/profile_avatar_icon_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698