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

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: 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
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 it's web representation in a
hashimoto 2016/02/29 08:01:59 s/it's/its/?
satorux1 2016/02/29 08:11:41 Done.
19 // used for storing profile images and user wallpapers. 19 // web-compatible format such as JPEG. Could be used for storing profile
20 // images and user wallpapers.
20 class USER_MANAGER_EXPORT UserImage { 21 class USER_MANAGER_EXPORT UserImage {
21 public: 22 public:
23 // Used to store data bytes of web representation.
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> WebImage;
hashimoto 2016/02/29 08:01:59 I'm not sure if WebImage is better than RawImage.
satorux1 2016/02/29 08:11:41 It's not always the case. RawImage is generated fr
hashimoto 2016/02/29 10:03:19 Removing typedef doesn't sound like a good thing t
satorux1 2016/02/29 11:07:49 How about just Bytes? This might sound too generic
hashimoto 2016/03/01 05:59:10 Bytes as a type name sounds sufficiently boring to
satorux1 2016/03/01 07:37:04 Done!
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 web representation.
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 web representation.
31 UserImage(); 33 UserImage();
32 34
33 // Creates a new instance from a given still frame without any raw data. 35 // Creates a new instance from a given still frame without any web
36 // representation.
34 explicit UserImage(const gfx::ImageSkia& image); 37 explicit UserImage(const gfx::ImageSkia& image);
35 38
36 // Creates a new instance from a given still frame and raw representation. 39 // Creates a new instance from a given still frame and web representation.
37 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); 40 UserImage(const gfx::ImageSkia& image, const WebImage& web_image);
38 41
39 virtual ~UserImage(); 42 virtual ~UserImage();
40 43
41 const gfx::ImageSkia& image() const { return image_; } 44 const gfx::ImageSkia& image() const { return image_; }
42 45
43 // Optional raw representation of the still image. 46 // Optional web representation of the still image.
44 bool has_raw_image() const { return has_raw_image_; } 47 bool has_web_image() const { return has_web_image_; }
45 const RawImage& raw_image() const { return raw_image_; } 48 const WebImage& web_image() const { return web_image_; }
46 49
47 // Discards the stored raw image, freeing used memory. 50 // Discards the stored web image, freeing used memory.
48 void DiscardRawImage(); 51 void DiscardWebImage();
49 52
50 // URL from which this image was originally downloaded, if any. 53 // URL from which this image was originally downloaded, if any.
51 void set_url(const GURL& url) { url_ = url; } 54 void set_url(const GURL& url) { url_ = url; }
52 GURL url() const { return url_; } 55 GURL url() const { return url_; }
53 56
54 // Whether |raw_image| contains data in format that is considered safe to 57 // Whether |web_image| contains data in format that is considered safe to
55 // decode in sensitive environment (on Login screen). 58 // decode in sensitive environment (on Login screen).
56 bool is_safe_format() const { return is_safe_format_; } 59 bool is_safe_format() const { return is_safe_format_; }
57 void MarkAsSafe(); 60 void MarkAsSafe();
58 61
59 const base::FilePath& file_path() const { return file_path_; } 62 const base::FilePath& file_path() const { return file_path_; }
60 void set_file_path(const base::FilePath& file_path) { 63 void set_file_path(const base::FilePath& file_path) {
61 file_path_ = file_path; 64 file_path_ = file_path;
62 } 65 }
63 66
64 private: 67 private:
65 gfx::ImageSkia image_; 68 gfx::ImageSkia image_;
66 bool has_raw_image_; 69 bool has_web_image_;
67 RawImage raw_image_; 70 WebImage web_image_;
68 GURL url_; 71 GURL url_;
69 72
70 // If image was loaded from the local file, file path is stored here. 73 // If image was loaded from the local file, file path is stored here.
71 base::FilePath file_path_; 74 base::FilePath file_path_;
72 bool is_safe_format_; 75 bool is_safe_format_;
73 }; 76 };
74 77
75 } // namespace user_manager 78 } // namespace user_manager
76 79
77 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 80 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698