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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_piece.h" | |
17 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
18 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 18 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
23 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 674 } |
676 | 675 |
677 // static | 676 // static |
678 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, | 677 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, |
679 size_t* icon_index) { | 678 size_t* icon_index) { |
680 DCHECK(icon_index); | 679 DCHECK(icon_index); |
681 if (url.find(kDefaultUrlPrefix) != 0) | 680 if (url.find(kDefaultUrlPrefix) != 0) |
682 return false; | 681 return false; |
683 | 682 |
684 int int_value = -1; | 683 int int_value = -1; |
685 if (base::StringToInt(base::StringPiece(url.begin() + | 684 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), |
686 strlen(kDefaultUrlPrefix), | 685 url.end(), |
687 url.end()), | |
688 &int_value)) { | 686 &int_value)) { |
689 if (int_value < 0 || | 687 if (int_value < 0 || |
690 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) | 688 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) |
691 return false; | 689 return false; |
692 *icon_index = int_value; | 690 *icon_index = int_value; |
693 return true; | 691 return true; |
694 } | 692 } |
695 | 693 |
696 return false; | 694 return false; |
697 } | 695 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 info->GetString(kNameKey, &name); | 773 info->GetString(kNameKey, &name); |
776 names.push_back(name); | 774 names.push_back(name); |
777 } | 775 } |
778 return names; | 776 return names; |
779 } | 777 } |
780 | 778 |
781 // static | 779 // static |
782 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { | 780 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { |
783 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); | 781 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); |
784 } | 782 } |
OLD | NEW |