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.
5 #ifndef COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
6 #define COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
11 #include "components/user_manager/user_manager_export.h"
12 #include "ui/gfx/image/image_skia.h"
15 namespace user_manager
{
17 // Wrapper class storing a still image and it's raw representation. Could be
18 // used for storing profile images and user wallpapers.
19 class USER_MANAGER_EXPORT UserImage
{
21 // TODO(ivankr): replace with RefCountedMemory to prevent copying.
22 typedef std::vector
<unsigned char> RawImage
;
24 // Creates a new instance from a given still frame and tries to encode raw
25 // representation for it.
26 // TODO(ivankr): remove eventually.
27 static UserImage
CreateAndEncode(const gfx::ImageSkia
& image
);
29 // Create instance with an empty still frame and no raw data.
32 // Creates a new instance from a given still frame without any raw data.
33 explicit UserImage(const gfx::ImageSkia
& image
);
35 // Creates a new instance from a given still frame and raw representation.
36 UserImage(const gfx::ImageSkia
& image
, const RawImage
& raw_image
);
40 const gfx::ImageSkia
& image() const { return image_
; }
42 // Optional raw representation of the still image.
43 bool has_raw_image() const { return has_raw_image_
; }
44 const RawImage
& raw_image() const { return raw_image_
; }
46 // Discards the stored raw image, freeing used memory.
47 void DiscardRawImage();
49 // URL from which this image was originally downloaded, if any.
50 void set_url(const GURL
& url
) { url_
= url
; }
51 GURL
url() const { return url_
; }
53 // Whether |raw_image| contains data in format that is considered safe to
54 // decode in sensitive environment (on Login screen).
55 bool is_safe_format() const { return is_safe_format_
; }
58 const std::string
& file_path() const { return file_path_
; }
59 void set_file_path(const std::string
& file_path
) { file_path_
= file_path
; }
62 gfx::ImageSkia image_
;
67 // If image was loaded from the local file, file path is stored here.
68 std::string file_path_
;
72 } // namespace user_manager
74 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_