| 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 <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "components/user_manager/user_manager_export.h" | 13 #include "components/user_manager/user_manager_export.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace user_manager { | 17 namespace user_manager { |
| 18 | 18 |
| 19 // Wrapper class storing a still image and its bytes representation for | 19 // Wrapper class storing a still image and its bytes representation for |
| 20 // WebUI in a web-compatible format such as JPEG. Could be used for storing | 20 // WebUI in a web-compatible format such as JPEG. Could be used for storing |
| 21 // profile images and user wallpapers. | 21 // profile images and user wallpapers. |
| 22 class USER_MANAGER_EXPORT UserImage { | 22 class USER_MANAGER_EXPORT UserImage { |
| 23 public: | 23 public: |
| 24 // Used to store bytes representation for WebUI. | 24 // Used to store bytes representation for WebUI. |
| 25 // TODO(ivankr): replace with RefCountedMemory to prevent copying. | 25 // TODO(ivankr): replace with RefCountedMemory to prevent copying. |
| 26 typedef std::vector<unsigned char> Bytes; | 26 typedef std::vector<unsigned char> Bytes; |
| 27 | 27 |
| 28 // Encodes the given bitmap to bytes representation for WebUI. Returns null | 28 // Encodes the given bitmap to bytes representation for WebUI. Returns null |
| 29 // on failure. | 29 // on failure. |
| 30 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap); | 30 static std::unique_ptr<Bytes> Encode(const SkBitmap& bitmap); |
| 31 | 31 |
| 32 // Creates a new instance from a given still frame and tries to encode it | 32 // Creates a new instance from a given still frame and tries to encode it |
| 33 // to bytes representation for WebUI. Always returns a non-null result. | 33 // to bytes representation for WebUI. Always returns a non-null result. |
| 34 // TODO(ivankr): remove eventually. | 34 // TODO(ivankr): remove eventually. |
| 35 static scoped_ptr<UserImage> CreateAndEncode(const gfx::ImageSkia& image); | 35 static std::unique_ptr<UserImage> CreateAndEncode( |
| 36 const gfx::ImageSkia& image); |
| 36 | 37 |
| 37 // Create instance with an empty still frame and no bytes | 38 // Create instance with an empty still frame and no bytes |
| 38 // representation for WebUI. | 39 // representation for WebUI. |
| 39 UserImage(); | 40 UserImage(); |
| 40 | 41 |
| 41 // Creates a new instance from a given still frame without any bytes | 42 // Creates a new instance from a given still frame without any bytes |
| 42 // representation for WebUI. | 43 // representation for WebUI. |
| 43 explicit UserImage(const gfx::ImageSkia& image); | 44 explicit UserImage(const gfx::ImageSkia& image); |
| 44 | 45 |
| 45 // Creates a new instance from a given still frame and bytes | 46 // Creates a new instance from a given still frame and bytes |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // If image was loaded from the local file, file path is stored here. | 79 // If image was loaded from the local file, file path is stored here. |
| 79 base::FilePath file_path_; | 80 base::FilePath file_path_; |
| 80 bool is_safe_format_; | 81 bool is_safe_format_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(UserImage); | 83 DISALLOW_COPY_AND_ASSIGN(UserImage); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace user_manager | 86 } // namespace user_manager |
| 86 | 87 |
| 87 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ | 88 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ |
| OLD | NEW |