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/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 net::UnescapeRule::SPACES)); | 30 net::UnescapeRule::SPACES)); |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 namespace chromeos { | 35 namespace chromeos { |
36 namespace options { | 36 namespace options { |
37 | 37 |
38 // Static. | 38 // Static. |
39 base::RefCountedMemory* UserImageSource::GetUserImage( | 39 base::RefCountedMemory* UserImageSource::GetUserImage( |
40 const std::string& email, | 40 const std::string& email, |
stevenjb
2015/10/22 17:52:36
It looks like we only call this once, it should ta
Alexander Alekseev
2015/10/23 09:11:24
Done.
| |
41 ui::ScaleFactor scale_factor) { | 41 ui::ScaleFactor scale_factor) { |
42 const user_manager::User* user = | 42 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
43 user_manager::UserManager::Get()->FindUser(email); | 43 AccountId::FromUserEmail(email)); |
44 if (user) { | 44 if (user) { |
45 if (user->has_raw_image()) { | 45 if (user->has_raw_image()) { |
46 return new base::RefCountedBytes(user->raw_image()); | 46 return new base::RefCountedBytes(user->raw_image()); |
47 } else if (user->image_is_stub()) { | 47 } else if (user->image_is_stub()) { |
48 return ResourceBundle::GetSharedInstance(). | 48 return ResourceBundle::GetSharedInstance(). |
49 LoadDataResourceBytesForScale(IDR_PROFILE_PICTURE_LOADING, | 49 LoadDataResourceBytesForScale(IDR_PROFILE_PICTURE_LOADING, |
50 scale_factor); | 50 scale_factor); |
51 } else if (user->HasDefaultImage()) { | 51 } else if (user->HasDefaultImage()) { |
52 return ResourceBundle::GetSharedInstance(). | 52 return ResourceBundle::GetSharedInstance(). |
53 LoadDataResourceBytesForScale( | 53 LoadDataResourceBytesForScale( |
(...skipping 28 matching lines...) Expand all Loading... | |
82 } | 82 } |
83 | 83 |
84 std::string UserImageSource::GetMimeType(const std::string& path) const { | 84 std::string UserImageSource::GetMimeType(const std::string& path) const { |
85 // We need to explicitly return a mime type, otherwise if the user tries to | 85 // We need to explicitly return a mime type, otherwise if the user tries to |
86 // drag the image they get no extension. | 86 // drag the image they get no extension. |
87 return "image/png"; | 87 return "image/png"; |
88 } | 88 } |
89 | 89 |
90 } // namespace options | 90 } // namespace options |
91 } // namespace chromeos | 91 } // namespace chromeos |
OLD | NEW |