Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/profiles/profile_info_cache.cc

Issue 8921006: Standardize StringToInt{,64} interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated StringPiece constructor interface to use iterators. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
16 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/prefs/scoped_user_pref_update.h" 22 #include "chrome/browser/prefs/scoped_user_pref_update.h"
22 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/image/image.h" 32 #include "ui/gfx/image/image.h"
32 #include "ui/gfx/image/image_util.h" 33 #include "ui/gfx/image/image_util.h"
33 34
35 using base::StringPiece;
34 using content::BrowserThread; 36 using content::BrowserThread;
35 37
36 namespace { 38 namespace {
37 39
38 const char kNameKey[] = "name"; 40 const char kNameKey[] = "name";
39 const char kGAIANameKey[] = "gaia_name"; 41 const char kGAIANameKey[] = "gaia_name";
40 const char kUseGAIANameKey[] = "use_gaia_name"; 42 const char kUseGAIANameKey[] = "use_gaia_name";
41 const char kUserNameKey[] = "user_name"; 43 const char kUserNameKey[] = "user_name";
42 const char kAvatarIconKey[] = "avatar_icon"; 44 const char kAvatarIconKey[] = "avatar_icon";
43 const char kUseGAIAPictureKey[] = "use_gaia_picture"; 45 const char kUseGAIAPictureKey[] = "use_gaia_picture";
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 664 }
663 665
664 // static 666 // static
665 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url, 667 bool ProfileInfoCache::IsDefaultAvatarIconUrl(const std::string& url,
666 size_t* icon_index) { 668 size_t* icon_index) {
667 DCHECK(icon_index); 669 DCHECK(icon_index);
668 if (url.find(kDefaultUrlPrefix) != 0) 670 if (url.find(kDefaultUrlPrefix) != 0)
669 return false; 671 return false;
670 672
671 int int_value = -1; 673 int int_value = -1;
672 if (base::StringToInt(url.begin() + strlen(kDefaultUrlPrefix), 674 if (base::StringToInt(StringPiece(url.begin() + strlen(kDefaultUrlPrefix),
673 url.end(), 675 url.end()),
674 &int_value)) { 676 &int_value)) {
675 if (int_value < 0 || 677 if (int_value < 0 ||
676 int_value >= static_cast<int>(kDefaultAvatarIconsCount)) 678 int_value >= static_cast<int>(kDefaultAvatarIconsCount))
677 return false; 679 return false;
678 *icon_index = int_value; 680 *icon_index = int_value;
679 return true; 681 return true;
680 } 682 }
681 683
682 return false; 684 return false;
683 } 685 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 info->GetString(kNameKey, &name); 763 info->GetString(kNameKey, &name);
762 names.push_back(name); 764 names.push_back(name);
763 } 765 }
764 return names; 766 return names;
765 } 767 }
766 768
767 // static 769 // static
768 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { 770 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) {
769 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); 771 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache);
770 } 772 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698