OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/user_image.h" |
| 6 |
| 7 namespace chromeos { |
| 8 |
| 9 namespace { |
| 10 |
| 11 bool IsAnimatedImage(const UserImage::RawImage& data) { |
| 12 const char kGIFStamp[] = "GIF"; |
| 13 const size_t kGIFStampLength = sizeof(kGIFStamp) - 1; |
| 14 |
| 15 if (data.size() >= kGIFStampLength && |
| 16 memcmp(&data[0], kGIFStamp, kGIFStampLength) == 0) { |
| 17 return true; |
| 18 } |
| 19 return false; |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
| 24 UserImage::UserImage(const gfx::ImageSkia& image) |
| 25 : image_(image), |
| 26 has_raw_image_(false), |
| 27 has_animated_image_(false) { |
| 28 } |
| 29 |
| 30 UserImage::UserImage(const gfx::ImageSkia& image, |
| 31 const RawImage& raw_image) |
| 32 : image_(image), |
| 33 has_raw_image_(true), |
| 34 has_animated_image_(IsAnimatedImage(raw_image)), |
| 35 raw_image_(raw_image) { |
| 36 } |
| 37 |
| 38 UserImage::~UserImage() {} |
| 39 |
| 40 void UserImage::SetImage(const gfx::ImageSkia& image) { |
| 41 image_ = image; |
| 42 has_raw_image_ = false; |
| 43 has_animated_image_ = false; |
| 44 // Clear |raw_image_|. |
| 45 RawImage().swap(raw_image_); |
| 46 } |
| 47 |
| 48 } // namespace chromeos |
OLD | NEW |