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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return user_data_dir_; | 611 return user_data_dir_; |
612 } | 612 } |
613 | 613 |
614 // static | 614 // static |
615 size_t ProfileInfoCache::GetDefaultAvatarIconCount() { | 615 size_t ProfileInfoCache::GetDefaultAvatarIconCount() { |
616 return kDefaultAvatarIconsCount; | 616 return kDefaultAvatarIconsCount; |
617 } | 617 } |
618 | 618 |
619 // static | 619 // static |
620 int ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(size_t index) { | 620 int ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(size_t index) { |
621 DCHECK(IsDefaultAvatarIconIndex(index)); | 621 DCHECK_LT(index, GetDefaultAvatarIconCount()); |
622 return kDefaultAvatarIconResources[index]; | 622 return kDefaultAvatarIconResources[index]; |
623 } | 623 } |
624 | 624 |
625 // static | 625 // static |
626 std::string ProfileInfoCache::GetDefaultAvatarIconUrl(size_t index) { | 626 std::string ProfileInfoCache::GetDefaultAvatarIconUrl(size_t index) { |
627 DCHECK(IsDefaultAvatarIconIndex(index)); | 627 DCHECK_LT(index, kDefaultAvatarIconsCount); |
628 return StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index); | 628 return StringPrintf("%s%" PRIuS, kDefaultUrlPrefix, index); |
629 } | 629 } |
630 | 630 |
631 // static | 631 // static |
632 bool ProfileInfoCache::IsDefaultAvatarIconIndex(size_t index) { | |
633 return index < kDefaultAvatarIconsCount; | |
634 } | |
635 | |
636 // static | |
637 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, | 632 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, |
638 size_t* icon_index) { | 633 size_t* icon_index) { |
639 DCHECK(icon_index); | 634 DCHECK(icon_index); |
640 if (url.find(kDefaultUrlPrefix) != 0) | 635 if (url.find(kDefaultUrlPrefix) != 0) |
641 return false; | 636 return false; |
642 | 637 |
643 int int_value = -1; | 638 int int_value = -1; |
644 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), | 639 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), |
645 url.end(), | 640 url.end(), |
646 &int_value)) { | 641 &int_value)) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 info->GetString(kNameKey, &name); | 728 info->GetString(kNameKey, &name); |
734 names.push_back(name); | 729 names.push_back(name); |
735 } | 730 } |
736 return names; | 731 return names; |
737 } | 732 } |
738 | 733 |
739 // static | 734 // static |
740 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 735 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
741 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 736 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
742 } | 737 } |
OLD | NEW |