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

Side by Side Diff: components/user_manager/user_image/user_image.h

Issue 395133002: Clean up. Experimental user avatars removed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Libvpx update. Created 6 years, 4 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
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_image/user_image.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 5 #ifndef COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
6 #define COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 6 #define COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "components/user_manager/user_manager_export.h" 11 #include "components/user_manager/user_manager_export.h"
12 #include "ui/gfx/image/image_skia.h" 12 #include "ui/gfx/image/image_skia.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace user_manager { 15 namespace user_manager {
16 16
17 // Wrapper class storing a still image and it's raw representation. Could be 17 // Wrapper class storing a still image and it's raw representation. Could be
18 // used for storing profile images (including animated profile images) and user 18 // used for storing profile images and user wallpapers.
19 // wallpapers.
20 class USER_MANAGER_EXPORT UserImage { 19 class USER_MANAGER_EXPORT UserImage {
21 public: 20 public:
22 // TODO(ivankr): replace with RefCountedMemory to prevent copying. 21 // TODO(ivankr): replace with RefCountedMemory to prevent copying.
23 typedef std::vector<unsigned char> RawImage; 22 typedef std::vector<unsigned char> RawImage;
24 23
25 // Creates a new instance from a given still frame and tries to encode raw 24 // Creates a new instance from a given still frame and tries to encode raw
26 // representation for it. 25 // representation for it.
27 // TODO(ivankr): remove eventually. 26 // TODO(ivankr): remove eventually.
28 static UserImage CreateAndEncode(const gfx::ImageSkia& image); 27 static UserImage CreateAndEncode(const gfx::ImageSkia& image);
29 28
30 // Create instance with an empty still frame and no raw data. 29 // Create instance with an empty still frame and no raw data.
31 UserImage(); 30 UserImage();
32 31
33 // Creates a new instance from a given still frame without any raw data. 32 // Creates a new instance from a given still frame without any raw data.
34 explicit UserImage(const gfx::ImageSkia& image); 33 explicit UserImage(const gfx::ImageSkia& image);
35 34
36 // Creates a new instance from a given still frame and raw representation. 35 // Creates a new instance from a given still frame and raw representation.
37 // |raw_image| can be animated, in which case animated_image() will return the
38 // original |raw_image| and raw_image() will return the encoded representation
39 // of |image|.
40 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); 36 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image);
41 37
42 virtual ~UserImage(); 38 virtual ~UserImage();
43 39
44 const gfx::ImageSkia& image() const { return image_; } 40 const gfx::ImageSkia& image() const { return image_; }
45 41
46 // Optional raw representation of the still image. 42 // Optional raw representation of the still image.
47 bool has_raw_image() const { return has_raw_image_; } 43 bool has_raw_image() const { return has_raw_image_; }
48 const RawImage& raw_image() const { return raw_image_; } 44 const RawImage& raw_image() const { return raw_image_; }
49 45
50 // Discards the stored raw image, freeing used memory. 46 // Discards the stored raw image, freeing used memory.
51 void DiscardRawImage(); 47 void DiscardRawImage();
52 48
53 // Optional raw representation of the animated image.
54 bool has_animated_image() const { return has_animated_image_; }
55 const RawImage& animated_image() const { return animated_image_; }
56
57 // URL from which this image was originally downloaded, if any. 49 // URL from which this image was originally downloaded, if any.
58 void set_url(const GURL& url) { url_ = url; } 50 void set_url(const GURL& url) { url_ = url; }
59 GURL url() const { return url_; } 51 GURL url() const { return url_; }
60 52
61 // Whether |raw_image| contains data in format that is considered safe to 53 // Whether |raw_image| contains data in format that is considered safe to
62 // decode in sensitive environment (on Login screen). 54 // decode in sensitive environment (on Login screen).
63 bool is_safe_format() const { return is_safe_format_; } 55 bool is_safe_format() const { return is_safe_format_; }
64 void MarkAsSafe(); 56 void MarkAsSafe();
65 57
66 const std::string& file_path() const { return file_path_; } 58 const std::string& file_path() const { return file_path_; }
67 void set_file_path(const std::string& file_path) { file_path_ = file_path; } 59 void set_file_path(const std::string& file_path) { file_path_ = file_path; }
68 60
69 private: 61 private:
70 gfx::ImageSkia image_; 62 gfx::ImageSkia image_;
71 bool has_raw_image_; 63 bool has_raw_image_;
72 RawImage raw_image_; 64 RawImage raw_image_;
73 bool has_animated_image_;
74 RawImage animated_image_;
75 GURL url_; 65 GURL url_;
76 66
77 // If image was loaded from the local file, file path is stored here. 67 // If image was loaded from the local file, file path is stored here.
78 std::string file_path_; 68 std::string file_path_;
79 bool is_safe_format_; 69 bool is_safe_format_;
80 }; 70 };
81 71
82 } // namespace user_manager 72 } // namespace user_manager
83 73
84 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 74 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
OLDNEW
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_image/user_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698