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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/user_image_source.cc

Issue 1747843002: Rename raw_image() to image_bytes() in UserImage (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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/image_source.cc ('k') | components/user_manager/user.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/default_user_image/default_user_im ages.h" 10 #include "chrome/browser/chromeos/login/users/default_user_image/default_user_im ages.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 base::RefCountedMemory* GetUserImageInternal(const AccountId& account_id) { 46 base::RefCountedMemory* GetUserImageInternal(const AccountId& account_id) {
47 const user_manager::User* user = 47 const user_manager::User* user =
48 user_manager::UserManager::Get()->FindUser(account_id); 48 user_manager::UserManager::Get()->FindUser(account_id);
49 49
50 // Always use the 100% scaling. These source images are 256x256, and are 50 // Always use the 100% scaling. These source images are 256x256, and are
51 // downscaled to ~64x64 for use in WebUI pages. Therefore, they are big enough 51 // downscaled to ~64x64 for use in WebUI pages. Therefore, they are big enough
52 // for device scale factors up to 4. We do not use SCALE_FACTOR_NONE, as we 52 // for device scale factors up to 4. We do not use SCALE_FACTOR_NONE, as we
53 // specifically want 100% scale images to not transmit more data than needed. 53 // specifically want 100% scale images to not transmit more data than needed.
54 if (user) { 54 if (user) {
55 if (user->has_raw_image()) { 55 if (user->has_image_bytes()) {
56 return new base::RefCountedBytes(user->raw_image()); 56 return new base::RefCountedBytes(user->image_bytes());
57 } else if (user->image_is_stub()) { 57 } else if (user->image_is_stub()) {
58 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 58 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
59 IDR_PROFILE_PICTURE_LOADING, ui::SCALE_FACTOR_100P); 59 IDR_PROFILE_PICTURE_LOADING, ui::SCALE_FACTOR_100P);
60 } else if (user->HasDefaultImage()) { 60 } else if (user->HasDefaultImage()) {
61 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 61 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
62 chromeos::default_user_image::kDefaultImageResourceIDs 62 chromeos::default_user_image::kDefaultImageResourceIDs
63 [user->image_index()], 63 [user->image_index()],
64 ui::SCALE_FACTOR_100P); 64 ui::SCALE_FACTOR_100P);
65 } else { 65 } else {
66 NOTREACHED() << "User with custom image missing raw data"; 66 NOTREACHED() << "User with custom image missing data bytes";
67 } 67 }
68 } 68 }
69 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 69 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
70 IDR_LOGIN_DEFAULT_USER, ui::SCALE_FACTOR_100P); 70 IDR_LOGIN_DEFAULT_USER, ui::SCALE_FACTOR_100P);
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 namespace chromeos { 75 namespace chromeos {
76 namespace options { 76 namespace options {
(...skipping 26 matching lines...) Expand all
103 } 103 }
104 104
105 std::string UserImageSource::GetMimeType(const std::string& path) const { 105 std::string UserImageSource::GetMimeType(const std::string& path) const {
106 // We need to explicitly return a mime type, otherwise if the user tries to 106 // We need to explicitly return a mime type, otherwise if the user tries to
107 // drag the image they get no extension. 107 // drag the image they get no extension.
108 return "image/png"; 108 return "image/png";
109 } 109 }
110 110
111 } // namespace options 111 } // namespace options
112 } // namespace chromeos 112 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/image_source.cc ('k') | components/user_manager/user.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698