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

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

Issue 7562015: Revert 95288 - Multi-Profiles: New Icon drop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/views/avatar_menu.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 IDR_PROFILE_AVATAR_10, 42 IDR_PROFILE_AVATAR_10,
43 IDR_PROFILE_AVATAR_11, 43 IDR_PROFILE_AVATAR_11,
44 IDR_PROFILE_AVATAR_12, 44 IDR_PROFILE_AVATAR_12,
45 IDR_PROFILE_AVATAR_13, 45 IDR_PROFILE_AVATAR_13,
46 IDR_PROFILE_AVATAR_14, 46 IDR_PROFILE_AVATAR_14,
47 IDR_PROFILE_AVATAR_15, 47 IDR_PROFILE_AVATAR_15,
48 IDR_PROFILE_AVATAR_16, 48 IDR_PROFILE_AVATAR_16,
49 IDR_PROFILE_AVATAR_17, 49 IDR_PROFILE_AVATAR_17,
50 IDR_PROFILE_AVATAR_18, 50 IDR_PROFILE_AVATAR_18,
51 IDR_PROFILE_AVATAR_19, 51 IDR_PROFILE_AVATAR_19,
52 IDR_PROFILE_AVATAR_20,
53 IDR_PROFILE_AVATAR_21,
54 IDR_PROFILE_AVATAR_22,
55 IDR_PROFILE_AVATAR_23,
56 IDR_PROFILE_AVATAR_24,
57 IDR_PROFILE_AVATAR_25,
58 }; 52 };
59 53
60 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources); 54 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources);
61 55
62 // Returns true if the resource ID belongs to a generic avatar icon.
63 bool IsAvatarIconGeneric(int icon_id) {
64 return icon_id == IDR_PROFILE_AVATAR_0 ||
65 icon_id == IDR_PROFILE_AVATAR_1 ||
66 icon_id == IDR_PROFILE_AVATAR_2 ||
67 icon_id == IDR_PROFILE_AVATAR_3 ||
68 icon_id == IDR_PROFILE_AVATAR_4 ||
69 icon_id == IDR_PROFILE_AVATAR_5 ||
70 icon_id == IDR_PROFILE_AVATAR_6 ||
71 icon_id == IDR_PROFILE_AVATAR_7;
72 }
73
74 } // namespace 56 } // namespace
75 57
76 ProfileInfoCache::ProfileInfoCache(PrefService* prefs, 58 ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
77 const FilePath& user_data_dir) 59 const FilePath& user_data_dir)
78 : prefs_(prefs), 60 : prefs_(prefs),
79 user_data_dir_(user_data_dir) { 61 user_data_dir_(user_data_dir) {
80 // Populate the cache 62 // Populate the cache
81 const DictionaryValue* cache = 63 const DictionaryValue* cache =
82 prefs_->GetDictionary(prefs::kProfileInfoCache); 64 prefs_->GetDictionary(prefs::kProfileInfoCache);
83 for (DictionaryValue::key_iterator it = cache->begin_keys(); 65 for (DictionaryValue::key_iterator it = cache->begin_keys();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 188 }
207 } 189 }
208 190
209 int ProfileInfoCache::ChooseAvatarIconIndexForNewProfile() { 191 int ProfileInfoCache::ChooseAvatarIconIndexForNewProfile() {
210 // Start with a random icon to introduce variety. 192 // Start with a random icon to introduce variety.
211 size_t rand_start_index = base::RandInt(0, GetDefaultAvatarIconCount() - 1); 193 size_t rand_start_index = base::RandInt(0, GetDefaultAvatarIconCount() - 1);
212 for (size_t icon_index = 0; icon_index < GetDefaultAvatarIconCount(); 194 for (size_t icon_index = 0; icon_index < GetDefaultAvatarIconCount();
213 ++icon_index) { 195 ++icon_index) {
214 size_t rand_icon_index = 196 size_t rand_icon_index =
215 (icon_index + rand_start_index) % GetDefaultAvatarIconCount(); 197 (icon_index + rand_start_index) % GetDefaultAvatarIconCount();
216 if (IsAvatarIconGeneric(GetDefaultAvatarIconResourceIDAtIndex(
217 rand_icon_index)))
218 continue;
219
220 bool icon_found = false; 198 bool icon_found = false;
221 for (size_t i = 0; i < GetNumberOfProfiles(); ++i) { 199 for (size_t i = 0; i < GetNumberOfProfiles(); ++i) {
222 if (GetAvatarIconIndexOfProfileAtIndex(i) == rand_icon_index) { 200 if (GetAvatarIconIndexOfProfileAtIndex(i) == rand_icon_index) {
223 icon_found = true; 201 icon_found = true;
224 break; 202 break;
225 } 203 }
226 } 204 }
227 if (!icon_found) 205 if (!icon_found)
228 return rand_icon_index; 206 return rand_icon_index;
229 } 207 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (key_compare < 0) 293 if (key_compare < 0)
316 return sorted_keys_.begin() + i; 294 return sorted_keys_.begin() + i;
317 } 295 }
318 } 296 }
319 return sorted_keys_.end(); 297 return sorted_keys_.end();
320 } 298 }
321 299
322 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) { 300 void ProfileInfoCache::RegisterPrefs(PrefService* prefs) {
323 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache); 301 prefs->RegisterDictionaryPref(prefs::kProfileInfoCache);
324 } 302 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/views/avatar_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698