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

Unified Diff: chrome/browser/chromeos/login/user_manager.cc

Issue 7790025: [cros] Default user picture is chosen randomly. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/user_manager.cc
diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
index d77d5f4c019a304633faefb5c518549a4194fab4..64b530c937fc2d11fd65e47f0b0752bb769325b6 100644
--- a/chrome/browser/chromeos/login/user_manager.cc
+++ b/chrome/browser/chromeos/login/user_manager.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
+#include "base/rand_util.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/time.h"
@@ -544,39 +545,10 @@ void UserManager::SetDefaultUserImage(const std::string& username) {
if (!g_browser_process)
return;
- PrefService* local_state = g_browser_process->local_state();
- DCHECK(local_state);
- const ListValue* prefs_users = local_state->GetList(kLoggedInUsers);
- DCHECK(prefs_users);
- const DictionaryValue* prefs_images =
- local_state->GetDictionary(kUserImages);
- DCHECK(prefs_images);
-
- // We want to distribute default images between users uniformly so that if
- // there're more users with red image, we won't add red one for sure.
- // Thus we count how many default images of each color are used and choose
- // the first color with minimal usage.
- std::vector<int> colors_count(kDefaultImagesCount, 0);
- for (ListValue::const_iterator it = prefs_users->begin();
- it != prefs_users->end();
- ++it) {
- std::string email;
- if ((*it)->GetAsString(&email)) {
- std::string image_path;
- int default_image_id = kDefaultImagesCount;
- if (prefs_images->GetStringWithoutPathExpansion(email, &image_path) &&
- IsDefaultImagePath(image_path, &default_image_id)) {
- DCHECK(default_image_id < kDefaultImagesCount);
- ++colors_count[default_image_id];
- }
- }
- }
- std::vector<int>::const_iterator min_it =
- std::min_element(colors_count.begin(), colors_count.end());
- int selected_id = min_it - colors_count.begin();
- std::string user_image_path =
- GetDefaultImagePath(selected_id);
- int resource_id = kDefaultImageResources[selected_id];
+ // Choose a random default image.
+ int image_id = base::RandInt(0, kDefaultImagesCount - 1);
+ std::string user_image_path = GetDefaultImagePath(image_id);
+ int resource_id = kDefaultImageResources[image_id];
SkBitmap user_image = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
resource_id);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698