OLD | NEW |
---|---|
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 Loading... | |
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); | |
186 const SkColor kAvatarBubbleButtonHighlightColor = | |
187 SkColorSetRGB(0xea, 0xea, 0xea); | |
Elliot Glaysher
2014/04/16 21:24:48
Be careful here; bubble background varies between
| |
184 | 188 |
185 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_"; | 189 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_"; |
186 const char kGAIAPictureFileName[] = "Google Profile Picture.png"; | 190 const char kGAIAPictureFileName[] = "Google Profile Picture.png"; |
187 const char kHighResAvatarFolderName[] = "Avatars"; | 191 const char kHighResAvatarFolderName[] = "Avatars"; |
188 | 192 |
189 const int kDefaultAvatarIconResources[] = { | 193 const int kDefaultAvatarIconResources[] = { |
190 IDR_PROFILE_AVATAR_0, | 194 IDR_PROFILE_AVATAR_0, |
191 IDR_PROFILE_AVATAR_1, | 195 IDR_PROFILE_AVATAR_1, |
192 IDR_PROFILE_AVATAR_2, | 196 IDR_PROFILE_AVATAR_2, |
193 IDR_PROFILE_AVATAR_3, | 197 IDR_PROFILE_AVATAR_3, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 "avatar_margarita.png", | 248 "avatar_margarita.png", |
245 "avatar_note.png", | 249 "avatar_note.png", |
246 "avatar_sun_cloud.png", | 250 "avatar_sun_cloud.png", |
247 }; | 251 }; |
248 | 252 |
249 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources); | 253 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources); |
250 | 254 |
251 // The first 8 icons are generic. | 255 // The first 8 icons are generic. |
252 const size_t kGenericAvatarIconsCount = 8; | 256 const size_t kGenericAvatarIconsCount = 8; |
253 | 257 |
254 gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image, | 258 gfx::Image GetSizedAvatarIcon(const gfx::Image& image, |
255 bool is_rectangle, | 259 bool is_rectangle, |
256 int width, int height) { | 260 int width, int height) { |
257 if (!is_rectangle) | 261 if (!is_rectangle) |
258 return image; | 262 return image; |
259 | 263 |
260 gfx::Size size(width, height); | 264 gfx::Size size(width, height); |
261 | 265 |
262 // Source for a centered, sized icon with a border. | 266 // Source for a centered, sized icon with a border. |
263 scoped_ptr<gfx::ImageSkiaSource> source( | 267 scoped_ptr<gfx::ImageSkiaSource> source( |
264 new AvatarImageSource( | 268 new AvatarImageSource( |
265 *image.ToImageSkia(), | 269 *image.ToImageSkia(), |
266 size, | 270 size, |
267 std::min(width, height), | 271 std::min(width, height), |
268 AvatarImageSource::POSITION_CENTER, | 272 AvatarImageSource::POSITION_CENTER, |
269 AvatarImageSource::BORDER_NORMAL)); | 273 AvatarImageSource::BORDER_NONE)); |
270 | 274 |
271 return gfx::Image(gfx::ImageSkia(source.release(), size)); | 275 return gfx::Image(gfx::ImageSkia(source.release(), size)); |
272 } | 276 } |
273 | 277 |
274 gfx::Image GetAvatarIconForMenu(const gfx::Image& image, | 278 gfx::Image GetAvatarIconForMenu(const gfx::Image& image, |
275 bool is_rectangle) { | 279 bool is_rectangle) { |
276 return GetSizedAvatarIconWithBorder( | 280 return GetSizedAvatarIcon( |
277 image, is_rectangle, kAvatarIconWidth, kAvatarIconHeight); | 281 image, is_rectangle, kAvatarIconWidth, kAvatarIconHeight); |
278 } | 282 } |
279 | 283 |
280 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, | 284 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, |
281 bool is_rectangle) { | 285 bool is_rectangle) { |
282 if (!is_rectangle) | 286 return GetSizedAvatarIcon(image, is_rectangle, |
283 return image; | 287 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 } | 288 } |
298 | 289 |
299 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, | 290 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, |
300 bool is_rectangle, | 291 bool is_rectangle, |
301 int dst_width, | 292 int dst_width, |
302 int dst_height) { | 293 int dst_height) { |
303 if (!is_rectangle) | 294 if (!is_rectangle) |
304 return image; | 295 return image; |
305 | 296 |
306 int size = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), | 297 int size = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) | 353 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) |
363 return false; | 354 return false; |
364 *icon_index = int_value; | 355 *icon_index = int_value; |
365 return true; | 356 return true; |
366 } | 357 } |
367 | 358 |
368 return false; | 359 return false; |
369 } | 360 } |
370 | 361 |
371 } // namespace profiles | 362 } // namespace profiles |
OLD | NEW |