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

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

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

Powered by Google App Engine
This is Rietveld 408576698