OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/profile_avatar_icon_util.h" | 5 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "skia/ext/image_operations.h" | 23 #include "skia/ext/image_operations.h" |
23 #include "third_party/skia/include/core/SkPaint.h" | 24 #include "third_party/skia/include/core/SkPaint.h" |
24 #include "third_party/skia/include/core/SkPath.h" | 25 #include "third_party/skia/include/core/SkPath.h" |
25 #include "third_party/skia/include/core/SkScalar.h" | 26 #include "third_party/skia/include/core/SkScalar.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 CHECK_NE(index, kPlaceholderAvatarIndex); | 481 CHECK_NE(index, kPlaceholderAvatarIndex); |
481 return GetDefaultAvatarIconResourceInfo(index)->label_id; | 482 return GetDefaultAvatarIconResourceInfo(index)->label_id; |
482 } | 483 } |
483 | 484 |
484 bool IsDefaultAvatarIconIndex(size_t index) { | 485 bool IsDefaultAvatarIconIndex(size_t index) { |
485 return index < kDefaultAvatarIconsCount; | 486 return index < kDefaultAvatarIconsCount; |
486 } | 487 } |
487 | 488 |
488 bool IsDefaultAvatarIconUrl(const std::string& url, size_t* icon_index) { | 489 bool IsDefaultAvatarIconUrl(const std::string& url, size_t* icon_index) { |
489 DCHECK(icon_index); | 490 DCHECK(icon_index); |
490 if (url.find(kDefaultUrlPrefix) != 0) | 491 if (!base::StartsWith(url, kDefaultUrlPrefix, base::CompareCase::SENSITIVE)) |
491 return false; | 492 return false; |
492 | 493 |
493 int int_value = -1; | 494 int int_value = -1; |
494 if (base::StringToInt(base::StringPiece(url.begin() + | 495 if (base::StringToInt(base::StringPiece(url.begin() + |
495 strlen(kDefaultUrlPrefix), | 496 strlen(kDefaultUrlPrefix), |
496 url.end()), | 497 url.end()), |
497 &int_value)) { | 498 &int_value)) { |
498 if (int_value < 0 || | 499 if (int_value < 0 || |
499 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) | 500 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) |
500 return false; | 501 return false; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 avatar_info->SetString( | 564 avatar_info->SetString( |
564 "label", l10n_util::GetStringUTF16( | 565 "label", l10n_util::GetStringUTF16( |
565 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); | 566 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); |
566 | 567 |
567 avatars->Append(std::move(avatar_info)); | 568 avatars->Append(std::move(avatar_info)); |
568 } | 569 } |
569 return avatars; | 570 return avatars; |
570 } | 571 } |
571 | 572 |
572 } // namespace profiles | 573 } // namespace profiles |
OLD | NEW |