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/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 return user_data_dir_; | 644 return user_data_dir_; |
645 } | 645 } |
646 | 646 |
647 // static | 647 // static |
648 size_t ProfileInfoCache::GetDefaultAvatarIconCount() { | 648 size_t ProfileInfoCache::GetDefaultAvatarIconCount() { |
649 return kDefaultAvatarIconsCount; | 649 return kDefaultAvatarIconsCount; |
650 } | 650 } |
651 | 651 |
652 // static | 652 // static |
653 int ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(size_t index) { | 653 int ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(size_t index) { |
654 DCHECK_LT(index, GetDefaultAvatarIconCount()); | 654 DCHECK(IsDefaultAvatarIconIndex(index)); |
655 return kDefaultAvatarIconResources[index]; | 655 return kDefaultAvatarIconResources[index]; |
656 } | 656 } |
657 | 657 |
658 // static | 658 // static |
659 std::string ProfileInfoCache::GetDefaultAvatarIconUrl(size_t index) { | 659 std::string ProfileInfoCache::GetDefaultAvatarIconUrl(size_t index) { |
660 DCHECK_LT(index, kDefaultAvatarIconsCount); | 660 DCHECK(IsDefaultAvatarIconIndex(index)); |
661 return StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index); | 661 return StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index); |
662 } | 662 } |
663 | 663 |
664 // static | 664 // static |
| 665 bool ProfileInfoCache::IsDefaultAvatarIconIndex(size_t index) { |
| 666 return index < kDefaultAvatarIconsCount; |
| 667 } |
| 668 |
| 669 // static |
665 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, | 670 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, |
666 size_t* icon_index) { | 671 size_t* icon_index) { |
667 DCHECK(icon_index); | 672 DCHECK(icon_index); |
668 if (url.find(kDefaultUrlPrefix) != 0) | 673 if (url.find(kDefaultUrlPrefix) != 0) |
669 return false; | 674 return false; |
670 | 675 |
671 int int_value = -1; | 676 int int_value = -1; |
672 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), | 677 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), |
673 url.end(), | 678 url.end(), |
674 &int_value)) { | 679 &int_value)) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 info->GetString(kNameKey, &name); | 766 info->GetString(kNameKey, &name); |
762 names.push_back(name); | 767 names.push_back(name); |
763 } | 768 } |
764 return names; | 769 return names; |
765 } | 770 } |
766 | 771 |
767 // static | 772 // static |
768 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 773 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
769 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 774 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
770 } | 775 } |
OLD | NEW |