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

Side by Side Diff: chrome/browser/chromeos/login/user_image.h

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

Powered by Google App Engine
This is Rietveld 408576698