Chromium Code Reviews| 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_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | |
| 13 | 14 |
|
whywhat
2011/11/11 15:40:42
include SkBitmap.h?
Ivan Korotkov
2011/11/11 16:08:00
Done.
| |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 const char kDefaultPathPrefix[] = "default:"; | 19 const char kDefaultPathPrefix[] = "default:"; |
| 19 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; | 20 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER_"; |
| 20 const char kFirstDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; | 21 const char kFirstDefaultUrl[] = "chrome://theme/IDR_LOGIN_DEFAULT_USER"; |
| 21 | 22 |
| 22 const char* kOldDefaultImageNames[] = { | 23 const char* kOldDefaultImageNames[] = { |
| 23 "default:gray", | 24 "default:gray", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool IsDefaultImageUrl(const std::string url, int* image_id) { | 89 bool IsDefaultImageUrl(const std::string url, int* image_id) { |
| 89 if (url == kFirstDefaultUrl) { | 90 if (url == kFirstDefaultUrl) { |
| 90 *image_id = 0; | 91 *image_id = 0; |
| 91 return true; | 92 return true; |
| 92 } | 93 } |
| 93 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); | 94 return IsDefaultImageString(url, kDefaultUrlPrefix, image_id); |
| 94 } | 95 } |
| 95 | 96 |
| 97 const SkBitmap& GetDefaultImage(int index) { | |
|
whywhat
2011/11/11 15:40:42
God bless us if we keep this reference in UserMana
Ivan Korotkov
2011/11/11 16:08:00
Blessed are we.
| |
| 98 DCHECK(index >= 0 && index < kDefaultImagesCount); | |
| 99 return *ResourceBundle::GetSharedInstance(). | |
| 100 GetBitmapNamed(kDefaultImageResources[index]); | |
| 101 } | |
| 102 | |
| 96 // Resource IDs of default user images. | 103 // Resource IDs of default user images. |
| 97 const int kDefaultImageResources[] = { | 104 const int kDefaultImageResources[] = { |
| 98 IDR_LOGIN_DEFAULT_USER, | 105 IDR_LOGIN_DEFAULT_USER, |
| 99 IDR_LOGIN_DEFAULT_USER_1, | 106 IDR_LOGIN_DEFAULT_USER_1, |
| 100 IDR_LOGIN_DEFAULT_USER_2, | 107 IDR_LOGIN_DEFAULT_USER_2, |
| 101 IDR_LOGIN_DEFAULT_USER_3, | 108 IDR_LOGIN_DEFAULT_USER_3, |
| 102 IDR_LOGIN_DEFAULT_USER_4, | 109 IDR_LOGIN_DEFAULT_USER_4, |
| 103 IDR_LOGIN_DEFAULT_USER_5, | 110 IDR_LOGIN_DEFAULT_USER_5, |
| 104 IDR_LOGIN_DEFAULT_USER_6, | 111 IDR_LOGIN_DEFAULT_USER_6, |
| 105 IDR_LOGIN_DEFAULT_USER_7, | 112 IDR_LOGIN_DEFAULT_USER_7, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 120 | 127 |
| 121 // The order and the values of these constants are important for histograms | 128 // The order and the values of these constants are important for histograms |
| 122 // of different Chrome OS versions to be merged smoothly. | 129 // of different Chrome OS versions to be merged smoothly. |
| 123 const int kHistogramImageFromCamera = kDefaultImagesCount; | 130 const int kHistogramImageFromCamera = kDefaultImagesCount; |
| 124 const int kHistogramImageFromFile = kDefaultImagesCount + 1; | 131 const int kHistogramImageFromFile = kDefaultImagesCount + 1; |
| 125 const int kHistogramImageOld = kDefaultImagesCount + 2; | 132 const int kHistogramImageOld = kDefaultImagesCount + 2; |
| 126 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; | 133 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; |
| 127 const int kHistogramImagesCount = kDefaultImagesCount + 4; | 134 const int kHistogramImagesCount = kDefaultImagesCount + 4; |
| 128 | 135 |
| 129 } // namespace chromeos | 136 } // namespace chromeos |
| OLD | NEW |