OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/theme_resources.h" | 13 #include "grit/theme_resources.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kDefaultPathPrefix[] = "default:"; | 21 const char kDefaultPathPrefix[] = "default:"; |
22 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; | 22 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; |
23 const char kFirstDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; | 23 const char kZeroDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; |
24 | 24 |
25 const char* kOldDefaultImageNames[] = { | 25 const char* kOldDefaultImageNames[] = { |
26 "default:gray", | 26 "default:gray", |
27 "default:green", | 27 "default:green", |
28 "default:blue", | 28 "default:blue", |
29 "default:yellow", | 29 "default:yellow", |
30 "default:red", | 30 "default:red", |
31 }; | 31 }; |
32 | 32 |
33 // Returns a string consisting of the prefix specified and the index of the | 33 // Returns a string consisting of the prefix specified and the index of the |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (path == kOldDefaultImageNames[i]) { | 77 if (path == kOldDefaultImageNames[i]) { |
78 *image_id = static_cast<int>(i); | 78 *image_id = static_cast<int>(i); |
79 return true; | 79 return true; |
80 } | 80 } |
81 } | 81 } |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 std::string GetDefaultImageUrl(int index) { | 85 std::string GetDefaultImageUrl(int index) { |
86 if (index == 0) | 86 if (index == 0) |
87 return kFirstDefaultUrl; | 87 return kZeroDefaultUrl; |
88 return GetDefaultImageString(index, kDefaultUrlPrefix); | 88 return GetDefaultImageString(index, kDefaultUrlPrefix); |
89 } | 89 } |
90 | 90 |
91 bool IsDefaultImageUrl(const std::string url, int* image_id) { | 91 bool IsDefaultImageUrl(const std::string url, int* image_id) { |
92 if (url == kFirstDefaultUrl) { | 92 if (url == kZeroDefaultUrl) { |
93 *image_id = 0; | 93 *image_id = 0; |
94 return true; | 94 return true; |
95 } | 95 } |
96 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); | 96 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); |
97 } | 97 } |
98 | 98 |
99 const gfx::ImageSkia& GetDefaultImage(int index) { | 99 const gfx::ImageSkia& GetDefaultImage(int index) { |
100 DCHECK(index >= 0 && index < kDefaultImagesCount); | 100 DCHECK(index >= 0 && index < kDefaultImagesCount); |
101 return *ResourceBundle::GetSharedInstance(). | 101 return *ResourceBundle::GetSharedInstance(). |
102 GetImageSkiaNamed(kDefaultImageResources[index]); | 102 GetImageSkiaNamed(kDefaultImageResources[index]); |
(...skipping 17 matching lines...) Expand all Loading... |
120 IDR_LOGIN_DEFAULT_USER_13, | 120 IDR_LOGIN_DEFAULT_USER_13, |
121 IDR_LOGIN_DEFAULT_USER_14, | 121 IDR_LOGIN_DEFAULT_USER_14, |
122 IDR_LOGIN_DEFAULT_USER_15, | 122 IDR_LOGIN_DEFAULT_USER_15, |
123 IDR_LOGIN_DEFAULT_USER_16, | 123 IDR_LOGIN_DEFAULT_USER_16, |
124 IDR_LOGIN_DEFAULT_USER_17, | 124 IDR_LOGIN_DEFAULT_USER_17, |
125 IDR_LOGIN_DEFAULT_USER_18, | 125 IDR_LOGIN_DEFAULT_USER_18, |
126 }; | 126 }; |
127 | 127 |
128 const int kDefaultImagesCount = arraysize(kDefaultImageResources); | 128 const int kDefaultImagesCount = arraysize(kDefaultImageResources); |
129 | 129 |
| 130 const int kFirstDefaultImageIndex = 0; |
| 131 |
130 // The order and the values of these constants are important for histograms | 132 // The order and the values of these constants are important for histograms |
131 // of different Chrome OS versions to be merged smoothly. | 133 // of different Chrome OS versions to be merged smoothly. |
132 const int kHistogramImageFromCamera = kDefaultImagesCount; | 134 const int kHistogramImageFromCamera = 19; |
133 const int kHistogramImageFromFile = kDefaultImagesCount + 1; | 135 const int kHistogramImageFromFile = 20; |
134 const int kHistogramImageOld = kDefaultImagesCount + 2; | 136 const int kHistogramImageOld = 21; |
135 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; | 137 const int kHistogramImageFromProfile = 22; |
136 const int kHistogramImagesCount = kDefaultImagesCount + 4; | 138 const int kHistogramVideoFromCamera = 23; |
| 139 const int kHistogramVideoFromFile = 24; |
| 140 const int kHistogramImagesCount = kDefaultImagesCount + 6; |
| 141 |
| 142 int GetDefaultImageHistogramValue(int index) { |
| 143 DCHECK(index >= 0 && index < kDefaultImagesCount); |
| 144 // Create a gap in histogram values for |
| 145 // [kHistogramImageFromCamera..kHistogramImageFromProfile] block to fit. |
| 146 if (index < kHistogramImageFromCamera) |
| 147 return index; |
| 148 return index + 6; |
| 149 } |
137 | 150 |
138 } // namespace chromeos | 151 } // namespace chromeos |
OLD | NEW |