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

Side by Side Diff: components/user_manager/user_image/user_image.h

Issue 1748423005: Crop the user-specified profile image for WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments 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 its bytes representation for 18 // Wrapper class storing a still image and its bytes representation for
19 // WebUI in a web-compatible format such as JPEG. Could be used for storing 19 // WebUI in a web-compatible format such as JPEG. Could be used for storing
20 // profile images and user wallpapers. 20 // profile images and user wallpapers.
21 class USER_MANAGER_EXPORT UserImage { 21 class USER_MANAGER_EXPORT UserImage {
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
28 // on failure.
29 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap);
30
27 // 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
28 // to bytes representation for WebUI. 32 // to bytes representation for WebUI.
29 // TODO(ivankr): remove eventually. 33 // TODO(ivankr): remove eventually.
30 static UserImage CreateAndEncode(const gfx::ImageSkia& image); 34 static UserImage CreateAndEncode(const gfx::ImageSkia& image);
31 35
32 // Create instance with an empty still frame and no bytes 36 // Create instance with an empty still frame and no bytes
33 // representation for WebUI. 37 // representation for WebUI.
34 UserImage(); 38 UserImage();
35 39
36 // 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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 GURL url_; 74 GURL url_;
71 75
72 // If image was loaded from the local file, file path is stored here. 76 // If image was loaded from the local file, file path is stored here.
73 base::FilePath file_path_; 77 base::FilePath file_path_;
74 bool is_safe_format_; 78 bool is_safe_format_;
75 }; 79 };
76 80
77 } // namespace user_manager 81 } // namespace user_manager
78 82
79 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ 83 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698