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

Unified Diff: components/user_manager/user_image/user_image.cc

Issue 411523005: Revert of Clean up. Experimental user avatars removed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/user_manager/user_image/user_image.h ('k') | media/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/user_manager/user_image/user_image.cc
diff --git a/components/user_manager/user_image/user_image.cc b/components/user_manager/user_image/user_image.cc
index 0a246a1f89bfb26158c4264be512136755186edc..67533a77a08a11e64defd01f544b4b7c3a4374f4 100644
--- a/components/user_manager/user_image/user_image.cc
+++ b/components/user_manager/user_image/user_image.cc
@@ -14,6 +14,17 @@
// Default quality for encoding user images.
const int kDefaultEncodingQuality = 90;
+
+bool IsAnimatedImage(const UserImage::RawImage& data) {
+ const char kGIFStamp[] = "GIF";
+ const size_t kGIFStampLength = sizeof(kGIFStamp) - 1;
+
+ if (data.size() >= kGIFStampLength &&
+ memcmp(&data[0], kGIFStamp, kGIFStampLength) == 0) {
+ return true;
+ }
+ return false;
+}
bool EncodeImageSkia(const gfx::ImageSkia& image,
std::vector<unsigned char>* output) {
@@ -47,12 +58,14 @@
UserImage::UserImage()
: has_raw_image_(false),
+ has_animated_image_(false),
is_safe_format_(false) {
}
UserImage::UserImage(const gfx::ImageSkia& image)
: image_(image),
has_raw_image_(false),
+ has_animated_image_(false),
is_safe_format_(false) {
}
@@ -60,9 +73,19 @@
const RawImage& raw_image)
: image_(image),
has_raw_image_(false),
+ has_animated_image_(false),
is_safe_format_(false) {
- has_raw_image_ = true;
- raw_image_ = raw_image;
+ if (IsAnimatedImage(raw_image)) {
+ has_animated_image_ = true;
+ animated_image_ = raw_image;
+ if (EncodeImageSkia(image_, &raw_image_)) {
+ has_raw_image_ = true;
+ MarkAsSafe();
+ }
+ } else {
+ has_raw_image_ = true;
+ raw_image_ = raw_image;
+ }
}
UserImage::~UserImage() {}
« no previous file with comments | « components/user_manager/user_image/user_image.h ('k') | media/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698