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/chromeos/login/default_user_images.h" | 5 #include "chrome/browser/chromeos/login/default_user_images.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kDefaultPathPrefix[] = "default:"; | 23 const char kDefaultPathPrefix[] = "default:"; |
23 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; | 24 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; |
24 const char kZeroDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; | 25 const char kZeroDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; |
25 | 26 |
26 const char* kOldDefaultImageNames[] = { | 27 const char* kOldDefaultImageNames[] = { |
27 "default:gray", | 28 "default:gray", |
28 "default:green", | 29 "default:green", |
29 "default:blue", | 30 "default:blue", |
30 "default:yellow", | 31 "default:yellow", |
31 "default:red", | 32 "default:red", |
32 }; | 33 }; |
33 | 34 |
| 35 // IDs of default user image descriptions. |
| 36 const int kDefaultImageDescriptions[] = { |
| 37 0, // No description for deprecated user image 0. |
| 38 0, // No description for deprecated user image 1. |
| 39 0, // No description for deprecated user image 2. |
| 40 0, // No description for deprecated user image 3. |
| 41 0, // No description for deprecated user image 4. |
| 42 0, // No description for deprecated user image 5. |
| 43 0, // No description for deprecated user image 6. |
| 44 0, // No description for deprecated user image 7. |
| 45 0, // No description for deprecated user image 8. |
| 46 0, // No description for deprecated user image 9. |
| 47 0, // No description for deprecated user image 10. |
| 48 0, // No description for deprecated user image 11. |
| 49 0, // No description for deprecated user image 12. |
| 50 0, // No description for deprecated user image 13. |
| 51 0, // No description for deprecated user image 14. |
| 52 0, // No description for deprecated user image 15. |
| 53 0, // No description for deprecated user image 16. |
| 54 0, // No description for deprecated user image 17. |
| 55 0, // No description for deprecated user image 18. |
| 56 IDS_LOGIN_DEFAULT_USER_DESC_19, |
| 57 IDS_LOGIN_DEFAULT_USER_DESC_20, |
| 58 IDS_LOGIN_DEFAULT_USER_DESC_21, |
| 59 IDS_LOGIN_DEFAULT_USER_DESC_22, |
| 60 IDS_LOGIN_DEFAULT_USER_DESC_23, |
| 61 IDS_LOGIN_DEFAULT_USER_DESC_24, |
| 62 IDS_LOGIN_DEFAULT_USER_DESC_25, |
| 63 IDS_LOGIN_DEFAULT_USER_DESC_26, |
| 64 IDS_LOGIN_DEFAULT_USER_DESC_27, |
| 65 IDS_LOGIN_DEFAULT_USER_DESC_28, |
| 66 IDS_LOGIN_DEFAULT_USER_DESC_29, |
| 67 IDS_LOGIN_DEFAULT_USER_DESC_30, |
| 68 IDS_LOGIN_DEFAULT_USER_DESC_31, |
| 69 IDS_LOGIN_DEFAULT_USER_DESC_32, |
| 70 }; |
| 71 |
34 // Returns a string consisting of the prefix specified and the index of the | 72 // Returns a string consisting of the prefix specified and the index of the |
35 // image if its valid. | 73 // image if its valid. |
36 std::string GetDefaultImageString(int index, const std::string& prefix) { | 74 std::string GetDefaultImageString(int index, const std::string& prefix) { |
37 if (index < 0 || index >= kDefaultImagesCount) { | 75 if (index < 0 || index >= kDefaultImagesCount) { |
38 NOTREACHED(); | 76 NOTREACHED(); |
39 return std::string(); | 77 return std::string(); |
40 } | 78 } |
41 return StringPrintf("%s%d", prefix.c_str(), index); | 79 return StringPrintf("%s%d", prefix.c_str(), index); |
42 } | 80 } |
43 | 81 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 134 } |
97 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); | 135 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); |
98 } | 136 } |
99 | 137 |
100 const gfx::ImageSkia& GetDefaultImage(int index) { | 138 const gfx::ImageSkia& GetDefaultImage(int index) { |
101 DCHECK(index >= 0 && index < kDefaultImagesCount); | 139 DCHECK(index >= 0 && index < kDefaultImagesCount); |
102 return *ResourceBundle::GetSharedInstance(). | 140 return *ResourceBundle::GetSharedInstance(). |
103 GetImageSkiaNamed(kDefaultImageResourceIDs[index]); | 141 GetImageSkiaNamed(kDefaultImageResourceIDs[index]); |
104 } | 142 } |
105 | 143 |
| 144 string16 GetDefaultImageDescription(int index) { |
| 145 DCHECK(index >= 0 && index < kDefaultImagesCount); |
| 146 int string_id = kDefaultImageDescriptions[index]; |
| 147 if (string_id) |
| 148 return l10n_util::GetStringUTF16(string_id); |
| 149 else |
| 150 return string16(); |
| 151 } |
| 152 |
| 153 // Resource IDs of default user images. |
106 const int kDefaultImageResourceIDs[] = { | 154 const int kDefaultImageResourceIDs[] = { |
107 IDR_LOGIN_DEFAULT_USER, | 155 IDR_LOGIN_DEFAULT_USER, |
108 IDR_LOGIN_DEFAULT_USER_1, | 156 IDR_LOGIN_DEFAULT_USER_1, |
109 IDR_LOGIN_DEFAULT_USER_2, | 157 IDR_LOGIN_DEFAULT_USER_2, |
110 IDR_LOGIN_DEFAULT_USER_3, | 158 IDR_LOGIN_DEFAULT_USER_3, |
111 IDR_LOGIN_DEFAULT_USER_4, | 159 IDR_LOGIN_DEFAULT_USER_4, |
112 IDR_LOGIN_DEFAULT_USER_5, | 160 IDR_LOGIN_DEFAULT_USER_5, |
113 IDR_LOGIN_DEFAULT_USER_6, | 161 IDR_LOGIN_DEFAULT_USER_6, |
114 IDR_LOGIN_DEFAULT_USER_7, | 162 IDR_LOGIN_DEFAULT_USER_7, |
115 IDR_LOGIN_DEFAULT_USER_8, | 163 IDR_LOGIN_DEFAULT_USER_8, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 int GetDefaultImageHistogramValue(int index) { | 276 int GetDefaultImageHistogramValue(int index) { |
229 DCHECK(index >= 0 && index < kDefaultImagesCount); | 277 DCHECK(index >= 0 && index < kDefaultImagesCount); |
230 // Create a gap in histogram values for | 278 // Create a gap in histogram values for |
231 // [kHistogramImageFromCamera..kHistogramImageFromProfile] block to fit. | 279 // [kHistogramImageFromCamera..kHistogramImageFromProfile] block to fit. |
232 if (index < kHistogramImageFromCamera) | 280 if (index < kHistogramImageFromCamera) |
233 return index; | 281 return index; |
234 return index + 6; | 282 return index + 6; |
235 } | 283 } |
236 | 284 |
237 } // namespace chromeos | 285 } // namespace chromeos |
OLD | NEW |