| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "chrome/browser/chromeos/login/users/user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 namespace chromeos { | 51 namespace chromeos { |
| 52 namespace options { | 52 namespace options { |
| 53 | 53 |
| 54 base::RefCountedMemory* UserImageSource::GetUserImage( | 54 base::RefCountedMemory* UserImageSource::GetUserImage( |
| 55 const std::string& email, | 55 const std::string& email, |
| 56 bool is_image_animated, | 56 bool is_image_animated, |
| 57 ui::ScaleFactor scale_factor) const { | 57 ui::ScaleFactor scale_factor) const { |
| 58 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(email); | 58 const user_manager::User* user = |
| 59 chromeos::UserManager::Get()->FindUser(email); |
| 59 if (user) { | 60 if (user) { |
| 60 if (user->has_animated_image() && is_image_animated) { | 61 if (user->has_animated_image() && is_image_animated) { |
| 61 return new base::RefCountedBytes(user->animated_image()); | 62 return new base::RefCountedBytes(user->animated_image()); |
| 62 } else if (user->has_raw_image()) { | 63 } else if (user->has_raw_image()) { |
| 63 return new base::RefCountedBytes(user->raw_image()); | 64 return new base::RefCountedBytes(user->raw_image()); |
| 64 } else if (user->image_is_stub()) { | 65 } else if (user->image_is_stub()) { |
| 65 return ResourceBundle::GetSharedInstance(). | 66 return ResourceBundle::GetSharedInstance(). |
| 66 LoadDataResourceBytesForScale(IDR_PROFILE_PICTURE_LOADING, | 67 LoadDataResourceBytesForScale(IDR_PROFILE_PICTURE_LOADING, |
| 67 scale_factor); | 68 scale_factor); |
| 68 } else if (user->HasDefaultImage()) { | 69 } else if (user->HasDefaultImage()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::string UserImageSource::GetMimeType(const std::string& path) const { | 103 std::string UserImageSource::GetMimeType(const std::string& path) const { |
| 103 // We need to explicitly return a mime type, otherwise if the user tries to | 104 // We need to explicitly return a mime type, otherwise if the user tries to |
| 104 // drag the image they get no extension. | 105 // drag the image they get no extension. |
| 105 std::string email; | 106 std::string email; |
| 106 bool is_image_animated = false; | 107 bool is_image_animated = false; |
| 107 | 108 |
| 108 GURL url(chrome::kChromeUIUserImageURL + path); | 109 GURL url(chrome::kChromeUIUserImageURL + path); |
| 109 ParseRequest(url, &email, &is_image_animated); | 110 ParseRequest(url, &email, &is_image_animated); |
| 110 | 111 |
| 111 if (is_image_animated) { | 112 if (is_image_animated) { |
| 112 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(email); | 113 const user_manager::User* user = |
| 114 chromeos::UserManager::Get()->FindUser(email); |
| 113 if (user && user->has_animated_image()) | 115 if (user && user->has_animated_image()) |
| 114 return "image/gif"; | 116 return "image/gif"; |
| 115 } | 117 } |
| 116 return "image/png"; | 118 return "image/png"; |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace options | 121 } // namespace options |
| 120 } // namespace chromeos | 122 } // namespace chromeos |
| OLD | NEW |