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

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

Issue 1747843002: Rename raw_image() to image_bytes() in UserImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 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
« no previous file with comments | « components/user_manager/user.cc ('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 "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "components/user_manager/user_manager_export.h" 12 #include "components/user_manager/user_manager_export.h"
13 #include "ui/gfx/image/image_skia.h" 13 #include "ui/gfx/image/image_skia.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace user_manager { 16 namespace user_manager {
17 17
18 // Wrapper class storing a still image and it's raw representation. Could be 18 // Wrapper class storing a still image and its bytes representation for
19 // used for storing profile images and user wallpapers. 19 // WebUI in a web-compatible format such as JPEG. Could be used for storing
20 // profile images and user wallpapers.
20 class USER_MANAGER_EXPORT UserImage { 21 class USER_MANAGER_EXPORT UserImage {
21 public: 22 public:
23 // Used to store bytes representation for WebUI.
22 // TODO(ivankr): replace with RefCountedMemory to prevent copying. 24 // TODO(ivankr): replace with RefCountedMemory to prevent copying.
23 typedef std::vector<unsigned char> RawImage; 25 typedef std::vector<unsigned char> Bytes;
24 26
25 // Creates a new instance from a given still frame and tries to encode raw 27 // Creates a new instance from a given still frame and tries to encode it
26 // representation for it. 28 // to bytes representation for WebUI.
27 // TODO(ivankr): remove eventually. 29 // TODO(ivankr): remove eventually.
28 static UserImage CreateAndEncode(const gfx::ImageSkia& image); 30 static UserImage CreateAndEncode(const gfx::ImageSkia& image);
29 31
30 // Create instance with an empty still frame and no raw data. 32 // Create instance with an empty still frame and no bytes
33 // representation for WebUI.
31 UserImage(); 34 UserImage();
32 35
33 // Creates a new instance from a given still frame without any raw data. 36 // Creates a new instance from a given still frame without any bytes
37 // representation for WebUI.
34 explicit UserImage(const gfx::ImageSkia& image); 38 explicit UserImage(const gfx::ImageSkia& image);
35 39
36 // Creates a new instance from a given still frame and raw representation. 40 // Creates a new instance from a given still frame and bytes
37 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); 41 // representation for WebUI.
42 UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes);
38 43
39 virtual ~UserImage(); 44 virtual ~UserImage();
40 45
41 const gfx::ImageSkia& image() const { return image_; } 46 const gfx::ImageSkia& image() const { return image_; }
42 47
43 // Optional raw representation of the still image. 48 // Optional bytes representation of the still image for WebUI.
44 bool has_raw_image() const { return has_raw_image_; } 49 bool has_image_bytes() const { return has_image_bytes_; }
45 const RawImage& raw_image() const { return raw_image_; } 50 const Bytes& image_bytes() const { return image_bytes_; }
46
47 // Discards the stored raw image, freeing used memory.
48 void DiscardRawImage();
49 51
50 // URL from which this image was originally downloaded, if any. 52 // URL from which this image was originally downloaded, if any.
51 void set_url(const GURL& url) { url_ = url; } 53 void set_url(const GURL& url) { url_ = url; }
52 GURL url() const { return url_; } 54 GURL url() const { return url_; }
53 55
54 // Whether |raw_image| contains data in format that is considered safe to 56 // Whether |image_bytes| contains data in format that is considered safe to
55 // decode in sensitive environment (on Login screen). 57 // decode in sensitive environment (on Login screen).
56 bool is_safe_format() const { return is_safe_format_; } 58 bool is_safe_format() const { return is_safe_format_; }
57 void MarkAsSafe(); 59 void MarkAsSafe();
58 60
59 const base::FilePath& file_path() const { return file_path_; } 61 const base::FilePath& file_path() const { return file_path_; }
60 void set_file_path(const base::FilePath& file_path) { 62 void set_file_path(const base::FilePath& file_path) {
61 file_path_ = file_path; 63 file_path_ = file_path;
62 } 64 }
63 65
64 private: 66 private:
65 gfx::ImageSkia image_; 67 gfx::ImageSkia image_;
66 bool has_raw_image_; 68 bool has_image_bytes_;
67 RawImage raw_image_; 69 Bytes image_bytes_;
68 GURL url_; 70 GURL url_;
69 71
70 // If image was loaded from the local file, file path is stored here. 72 // If image was loaded from the local file, file path is stored here.
71 base::FilePath file_path_; 73 base::FilePath file_path_;
72 bool is_safe_format_; 74 bool is_safe_format_;
73 }; 75 };
74 76
75 } // namespace user_manager 77 } // namespace user_manager
76 78
77 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 79 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
OLDNEW
« no previous file with comments | « components/user_manager/user.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