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_util.h" | 11 #include "base/string_util.h" |
11 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
12 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
(...skipping 23 matching lines...) Expand all Loading... |
43 // the default images indices. Returns the index of the image in |image_id| | 44 // the default images indices. Returns the index of the image in |image_id| |
44 // variable. | 45 // variable. |
45 bool IsDefaultImageString(const std::string& s, | 46 bool IsDefaultImageString(const std::string& s, |
46 const std::string& prefix, | 47 const std::string& prefix, |
47 int* image_id) { | 48 int* image_id) { |
48 DCHECK(image_id); | 49 DCHECK(image_id); |
49 if (!StartsWithASCII(s, prefix, true)) | 50 if (!StartsWithASCII(s, prefix, true)) |
50 return false; | 51 return false; |
51 | 52 |
52 int image_index = -1; | 53 int image_index = -1; |
53 if (base::StringToInt(s.begin() + prefix.length(), | 54 if (base::StringToInt(base::StringPiece(s.begin() + prefix.length(), |
54 s.end(), | 55 s.end()), |
55 &image_index)) { | 56 &image_index)) { |
56 if (image_index < 0 || image_index >= kDefaultImagesCount) | 57 if (image_index < 0 || image_index >= kDefaultImagesCount) |
57 return false; | 58 return false; |
58 *image_id = image_index; | 59 *image_id = image_index; |
59 return true; | 60 return true; |
60 } | 61 } |
61 | 62 |
62 return false; | 63 return false; |
63 } | 64 } |
64 } // namespace | 65 } // namespace |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 // The order and the values of these constants are important for histograms | 130 // The order and the values of these constants are important for histograms |
130 // of different Chrome OS versions to be merged smoothly. | 131 // of different Chrome OS versions to be merged smoothly. |
131 const int kHistogramImageFromCamera = kDefaultImagesCount; | 132 const int kHistogramImageFromCamera = kDefaultImagesCount; |
132 const int kHistogramImageFromFile = kDefaultImagesCount + 1; | 133 const int kHistogramImageFromFile = kDefaultImagesCount + 1; |
133 const int kHistogramImageOld = kDefaultImagesCount + 2; | 134 const int kHistogramImageOld = kDefaultImagesCount + 2; |
134 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; | 135 const int kHistogramImageFromProfile = kDefaultImagesCount + 3; |
135 const int kHistogramImagesCount = kDefaultImagesCount + 4; | 136 const int kHistogramImagesCount = kDefaultImagesCount + 4; |
136 | 137 |
137 } // namespace chromeos | 138 } // namespace chromeos |
OLD | NEW |