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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ | 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ |
6 #define CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ | 6 #define CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Avatar formatting. | 28 // Avatar formatting. |
29 extern const int kAvatarIconWidth; | 29 extern const int kAvatarIconWidth; |
30 extern const int kAvatarIconHeight; | 30 extern const int kAvatarIconHeight; |
31 extern const SkColor kAvatarTutorialBackgroundColor; | 31 extern const SkColor kAvatarTutorialBackgroundColor; |
32 extern const SkColor kAvatarTutorialContentTextColor; | 32 extern const SkColor kAvatarTutorialContentTextColor; |
33 extern const SkColor kAvatarBubbleAccountsBackgroundColor; | 33 extern const SkColor kAvatarBubbleAccountsBackgroundColor; |
34 extern const SkColor kAvatarBubbleGaiaBackgroundColor; | 34 extern const SkColor kAvatarBubbleGaiaBackgroundColor; |
35 extern const SkColor kUserManagerBackgroundColor; | 35 extern const SkColor kUserManagerBackgroundColor; |
36 | 36 |
| 37 // Returns a version of |image| of a specific size. Note that no checks are |
| 38 // done on the width/height so make sure they're reasonable values; in the |
| 39 // range of 16-256 is probably best. |
| 40 gfx::Image GetSizedAvatarIcon(const gfx::Image& image, |
| 41 bool is_rectangle, |
| 42 int width, int height); |
| 43 |
| 44 // Returns a version of |image| suitable for use in menus. |
| 45 gfx::Image GetAvatarIconForMenu(const gfx::Image& image, |
| 46 bool is_rectangle); |
| 47 |
| 48 // Returns a version of |image| suitable for use in WebUI. |
| 49 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, |
| 50 bool is_rectangle); |
| 51 |
| 52 // Returns a version of |image| suitable for use in title bars. The returned |
| 53 // image is scaled to fit |dst_width| and |dst_height|. |
| 54 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, |
| 55 bool is_rectangle, |
| 56 int dst_width, |
| 57 int dst_height); |
| 58 |
| 59 // Returns a bitmap with a couple of columns shaved off so it is more square, |
| 60 // so that when resized to a square aspect ratio it looks pretty. |
| 61 SkBitmap GetAvatarIconAsSquare(const SkBitmap& source_bitmap, int scale_factor); |
| 62 |
| 63 // Sets |image| to the avatar corresponding to the profile at |profile_path| and |
| 64 // sets |is_rectangle| to true unless |image| is a built-in profile avatar. For |
| 65 // built-in profile avatars, always return the non-high res version. |
| 66 void GetTransparentBackgroundProfileAvatar(const base::FilePath& profile_path, |
| 67 gfx::Image* image, |
| 68 bool* is_rectangle); |
| 69 |
37 // Gets the number of default avatar icons that exist. | 70 // Gets the number of default avatar icons that exist. |
38 size_t GetDefaultAvatarIconCount(); | 71 size_t GetDefaultAvatarIconCount(); |
39 | 72 |
| 73 // Gets the number of generic avatar icons that exist. |
| 74 size_t GetGenericAvatarIconCount(); |
| 75 |
40 // Gets the index for the (grey silhouette) avatar used as a placeholder. | 76 // Gets the index for the (grey silhouette) avatar used as a placeholder. |
41 int GetPlaceholderAvatarIndex(); | 77 int GetPlaceholderAvatarIndex(); |
42 | 78 |
43 // Gets the resource ID of the placeholder avatar icon. | 79 // Gets the resource ID of the placeholder avatar icon. |
44 int GetPlaceholderAvatarIconResourceID(); | 80 int GetPlaceholderAvatarIconResourceID(); |
45 | 81 |
46 // Gets the number of generic avatar icons that exist. | |
47 size_t GetGenericAvatarIconCount(); | |
48 | |
49 // Gets the resource ID of the default avatar icon at |index|. | 82 // Gets the resource ID of the default avatar icon at |index|. |
50 int GetDefaultAvatarIconResourceIDAtIndex(size_t index); | 83 int GetDefaultAvatarIconResourceIDAtIndex(size_t index); |
51 | 84 |
52 // Gets the resource filename of the default avatar icon at |index|. | 85 // Gets the resource filename of the default avatar icon at |index|. |
53 const char* GetDefaultAvatarIconFileNameAtIndex(size_t index); | 86 const char* GetDefaultAvatarIconFileNameAtIndex(size_t index); |
54 | 87 |
55 // Gets the file name of an avatar that has no high res version. | 88 // Gets the file name of an avatar that has no high res version. |
56 const char* GetNoHighResAvatarFileName(); | 89 const char* GetNoHighResAvatarFileName(); |
57 | 90 |
58 // Gets the full path of the high res avatar icon at |index|. | 91 // Gets the full path of the high res avatar icon at |index|. |
59 base::FilePath GetPathOfHighResAvatarAtIndex(size_t index); | 92 base::FilePath GetPathOfHighResAvatarAtIndex(size_t index); |
60 | 93 |
61 // Returns a URL for the default avatar icon with specified index. | 94 // Returns a URL for the default avatar icon with specified index. |
62 std::string GetDefaultAvatarIconUrl(size_t index); | 95 std::string GetDefaultAvatarIconUrl(size_t index); |
63 | 96 |
64 // Checks if |index| is a valid avatar icon index | 97 // Checks if |index| is a valid avatar icon index |
65 bool IsDefaultAvatarIconIndex(size_t index); | 98 bool IsDefaultAvatarIconIndex(size_t index); |
66 | 99 |
67 // Checks if the given URL points to one of the default avatar icons. If it | 100 // Checks if the given URL points to one of the default avatar icons. If it |
68 // is, returns true and its index through |icon_index|. If not, returns false. | 101 // is, returns true and its index through |icon_index|. If not, returns false. |
69 bool IsDefaultAvatarIconUrl(const std::string& icon_url, size_t *icon_index); | 102 bool IsDefaultAvatarIconUrl(const std::string& icon_url, size_t *icon_index); |
70 | 103 |
71 // Returns a version of |image| of a specific size. Note that no checks are | |
72 // done on the width/height so make sure they're reasonable values; in the | |
73 // range of 16-256 is probably best. | |
74 gfx::Image GetSizedAvatarIcon(const gfx::Image& image, | |
75 bool is_rectangle, | |
76 int width, int height); | |
77 | |
78 // Returns a version of |image| suitable for use in menus. | |
79 gfx::Image GetAvatarIconForMenu(const gfx::Image& image, | |
80 bool is_rectangle); | |
81 | |
82 // Returns a version of |image| suitable for use in WebUI. | |
83 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, | |
84 bool is_rectangle); | |
85 | |
86 // Returns a version of |image| suitable for use in title bars. The returned | |
87 // image is scaled to fit |dst_width| and |dst_height|. | |
88 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, | |
89 bool is_rectangle, | |
90 int dst_width, | |
91 int dst_height); | |
92 | |
93 // Returns a bitmap with a couple of columns shaved off so it is more square, | |
94 // so that when resized to a square aspect ratio it looks pretty. | |
95 SkBitmap GetAvatarIconAsSquare(const SkBitmap& source_bitmap, int scale_factor); | |
96 | |
97 } // namespace profiles | 104 } // namespace profiles |
98 | 105 |
99 #endif // CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ | 106 #endif // CHROME_BROWSER_PROFILES_PROFILE_AVATAR_ICON_UTIL_H_ |
OLD | NEW |