OLD | NEW |
---|---|
1 // Copyright (c) 2011 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/theme_resources.h" | 14 #include "grit/theme_resources.h" |
14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/base/l10n/l10n_util.h" | |
15 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
16 | 18 |
17 namespace chromeos { | 19 namespace chromeos { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 const char kDefaultPathPrefix[] = "default:"; | 23 const char kDefaultPathPrefix[] = "default:"; |
22 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; | 24 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; |
23 const char kFirstDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; | 25 const char kFirstDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; |
24 | 26 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 } | 97 } |
96 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); | 98 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); |
97 } | 99 } |
98 | 100 |
99 const gfx::ImageSkia& GetDefaultImage(int index) { | 101 const gfx::ImageSkia& GetDefaultImage(int index) { |
100 DCHECK(index >= 0 && index < kDefaultImagesCount); | 102 DCHECK(index >= 0 && index < kDefaultImagesCount); |
101 return *ResourceBundle::GetSharedInstance(). | 103 return *ResourceBundle::GetSharedInstance(). |
102 GetImageSkiaNamed(kDefaultImageResources[index]); | 104 GetImageSkiaNamed(kDefaultImageResources[index]); |
103 } | 105 } |
104 | 106 |
107 // IDs of default user image descriptions. | |
Ivan Korotkov
2012/08/03 01:00:23
// String IDs...
dmazzoni
2012/08/03 22:59:01
Done.
| |
108 const int kDefaultImageDescriptions[] = { | |
109 IDS_LOGIN_DEFAULT_USER, | |
110 IDS_LOGIN_DEFAULT_USER_1, | |
111 IDS_LOGIN_DEFAULT_USER_2, | |
112 IDS_LOGIN_DEFAULT_USER_3, | |
113 IDS_LOGIN_DEFAULT_USER_4, | |
114 IDS_LOGIN_DEFAULT_USER_5, | |
115 IDS_LOGIN_DEFAULT_USER_6, | |
116 IDS_LOGIN_DEFAULT_USER_7, | |
117 IDS_LOGIN_DEFAULT_USER_8, | |
118 IDS_LOGIN_DEFAULT_USER_9, | |
119 IDS_LOGIN_DEFAULT_USER_10, | |
120 IDS_LOGIN_DEFAULT_USER_11, | |
121 IDS_LOGIN_DEFAULT_USER_12, | |
122 IDS_LOGIN_DEFAULT_USER_13, | |
123 IDS_LOGIN_DEFAULT_USER_14, | |
124 IDS_LOGIN_DEFAULT_USER_15, | |
125 IDS_LOGIN_DEFAULT_USER_16, | |
126 IDS_LOGIN_DEFAULT_USER_17, | |
127 IDS_LOGIN_DEFAULT_USER_18, | |
128 }; | |
129 | |
130 std::string GetDefaultImageDescription(int index) { | |
Ivan Korotkov
2012/08/03 01:00:23
Should be string16 and GetStringUTF16.
I actually
dmazzoni
2012/08/03 22:59:01
Hmmm, I think it's better to have the constants in
| |
131 DCHECK(index >= 0 && index < kDefaultImagesCount); | |
132 return l10n_util::GetStringUTF8(kDefaultImageDescriptions[index]); | |
133 } | |
134 | |
105 // Resource IDs of default user images. | 135 // Resource IDs of default user images. |
106 const int kDefaultImageResources[] = { | 136 const int kDefaultImageResources[] = { |
107 IDR_LOGIN_DEFAULT_USER, | 137 IDR_LOGIN_DEFAULT_USER, |
108 IDR_LOGIN_DEFAULT_USER_1, | 138 IDR_LOGIN_DEFAULT_USER_1, |
109 IDR_LOGIN_DEFAULT_USER_2, | 139 IDR_LOGIN_DEFAULT_USER_2, |
110 IDR_LOGIN_DEFAULT_USER_3, | 140 IDR_LOGIN_DEFAULT_USER_3, |
111 IDR_LOGIN_DEFAULT_USER_4, | 141 IDR_LOGIN_DEFAULT_USER_4, |
112 IDR_LOGIN_DEFAULT_USER_5, | 142 IDR_LOGIN_DEFAULT_USER_5, |
113 IDR_LOGIN_DEFAULT_USER_6, | 143 IDR_LOGIN_DEFAULT_USER_6, |
114 IDR_LOGIN_DEFAULT_USER_7, | 144 IDR_LOGIN_DEFAULT_USER_7, |
(...skipping 14 matching lines...) Expand all Loading... | |
129 | 159 |
130 // The order and the values of these constants are important for histograms | 160 // The order and the values of these constants are important for histograms |
131 // of different Chrome OS versions to be merged smoothly. | 161 // of different Chrome OS versions to be merged smoothly. |
132 const int kHistogramImageFromCamera = kDefaultImagesCount; | 162 const int kHistogramImageFromCamera = kDefaultImagesCount; |
133 const int kHistogramImageFromFile = kDefaultImagesCount + 1; | 163 const int kHistogramImageFromFile = kDefaultImagesCount + 1; |
134 const int kHistogramImageOld = kDefaultImagesCount + 2; | 164 const int kHistogramImageOld = kDefaultImagesCount + 2; |
135 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; | 165 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; |
136 const int kHistogramImagesCount = kDefaultImagesCount + 4; | 166 const int kHistogramImagesCount = kDefaultImagesCount + 4; |
137 | 167 |
138 } // namespace chromeos | 168 } // namespace chromeos |
OLD | NEW |