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