Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / user_image.h
blobb1e39336a38f1aa2222a571486c619714f5918d3
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_
8 #include <vector>
10 #include "ui/gfx/image/image_skia.h"
11 #include "url/gurl.h"
13 namespace chromeos {
15 // Wrapper class storing a still image and it's raw representation. Could be
16 // used for storing profile images (including animated profile images) and user
17 // wallpapers.
18 class UserImage {
19 public:
20 // TODO(ivankr): replace with RefCountedMemory to prevent copying.
21 typedef std::vector<unsigned char> RawImage;
23 // Creates a new instance from a given still frame and tries to encode raw
24 // representation for it.
25 // TODO(ivankr): remove eventually.
26 static UserImage CreateAndEncode(const gfx::ImageSkia& image);
28 // Create instance with an empty still frame and no raw data.
29 UserImage();
31 // Creates a new instance from a given still frame without any raw data.
32 explicit UserImage(const gfx::ImageSkia& image);
34 // Creates a new instance from a given still frame and raw representation.
35 // |raw_image| can be animated, in which case animated_image() will return the
36 // original |raw_image| and raw_image() will return the encoded representation
37 // of |image|.
38 UserImage(const gfx::ImageSkia& image, const RawImage& raw_image);
40 virtual ~UserImage();
42 const gfx::ImageSkia& image() const { return image_; }
44 // Optional raw representation of the still image.
45 bool has_raw_image() const { return has_raw_image_; }
46 const RawImage& raw_image() const { return raw_image_; }
48 // Discards the stored raw image, freeing used memory.
49 void DiscardRawImage();
51 // Optional raw representation of the animated image.
52 bool has_animated_image() const { return has_animated_image_; }
53 const RawImage& animated_image() const { return animated_image_; }
55 // URL from which this image was originally downloaded, if any.
56 void set_url(const GURL& url) { url_ = url; }
57 GURL url() const { return url_; }
59 // Whether |raw_image| contains data in format that is considered safe to
60 // decode in sensitive environment (on Login screen).
61 bool is_safe_format() const { return is_safe_format_; }
62 void MarkAsSafe();
64 private:
65 gfx::ImageSkia image_;
66 bool has_raw_image_;
67 RawImage raw_image_;
68 bool has_animated_image_;
69 RawImage animated_image_;
70 GURL url_;
71 bool is_safe_format_;
74 } // namespace chromeos
76 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_H_