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