| OLD | NEW |
| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 // Used to store bytes representation for WebUI. | 23 // Used to store bytes representation for WebUI. |
| 24 // TODO(ivankr): replace with RefCountedMemory to prevent copying. | 24 // TODO(ivankr): replace with RefCountedMemory to prevent copying. |
| 25 typedef std::vector<unsigned char> Bytes; | 25 typedef std::vector<unsigned char> Bytes; |
| 26 | 26 |
| 27 // Encodes the given bitmap to bytes representation for WebUI. Returns null | 27 // Encodes the given bitmap to bytes representation for WebUI. Returns null |
| 28 // on failure. | 28 // on failure. |
| 29 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap); | 29 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap); |
| 30 | 30 |
| 31 // Creates a new instance from a given still frame and tries to encode it | 31 // Creates a new instance from a given still frame and tries to encode it |
| 32 // to bytes representation for WebUI. | 32 // to bytes representation for WebUI. Always returns a non-null result. |
| 33 // TODO(ivankr): remove eventually. | 33 // TODO(ivankr): remove eventually. |
| 34 static UserImage CreateAndEncode(const gfx::ImageSkia& image); | 34 static scoped_ptr<UserImage> CreateAndEncode(const gfx::ImageSkia& image); |
| 35 | 35 |
| 36 // Create instance with an empty still frame and no bytes | 36 // Create instance with an empty still frame and no bytes |
| 37 // representation for WebUI. | 37 // representation for WebUI. |
| 38 UserImage(); | 38 UserImage(); |
| 39 | 39 |
| 40 // Creates a new instance from a given still frame without any bytes | 40 // Creates a new instance from a given still frame without any bytes |
| 41 // representation for WebUI. | 41 // representation for WebUI. |
| 42 explicit UserImage(const gfx::ImageSkia& image); | 42 explicit UserImage(const gfx::ImageSkia& image); |
| 43 | 43 |
| 44 // Creates a new instance from a given still frame and bytes | 44 // Creates a new instance from a given still frame and bytes |
| 45 // representation for WebUI. | 45 // representation for WebUI. |
| 46 // TODO(crbug.com/593251): Remove the data copy via |image_bytes|. |
| 46 UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes); | 47 UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes); |
| 47 | 48 |
| 48 virtual ~UserImage(); | 49 virtual ~UserImage(); |
| 49 | 50 |
| 50 const gfx::ImageSkia& image() const { return image_; } | 51 const gfx::ImageSkia& image() const { return image_; } |
| 51 | 52 |
| 52 // Optional bytes representation of the still image for WebUI. | 53 // Optional bytes representation of the still image for WebUI. |
| 53 bool has_image_bytes() const { return has_image_bytes_; } | 54 bool has_image_bytes() const { return has_image_bytes_; } |
| 54 const Bytes& image_bytes() const { return image_bytes_; } | 55 const Bytes& image_bytes() const { return image_bytes_; } |
| 55 | 56 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 gfx::ImageSkia image_; | 72 gfx::ImageSkia image_; |
| 72 bool has_image_bytes_; | 73 bool has_image_bytes_; |
| 73 Bytes image_bytes_; | 74 Bytes image_bytes_; |
| 74 GURL url_; | 75 GURL url_; |
| 75 | 76 |
| 76 // 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. |
| 77 base::FilePath file_path_; | 78 base::FilePath file_path_; |
| 78 bool is_safe_format_; | 79 bool is_safe_format_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(UserImage); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace user_manager | 84 } // namespace user_manager |
| 82 | 85 |
| 83 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ | 86 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ |
| OLD | NEW |