- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / profiles / avatar_menu_chromeos.cc
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/profiles/avatar_menu.h"
6
7 #include <string>
8
9 #include "chrome/browser/chromeos/login/user_manager.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12
13 // static
14 void AvatarMenu::GetImageForMenuButton(Profile* profile,
15                                        gfx::Image* image,
16                                        bool* is_rectangle) {
17   // Find the user for this profile.
18   std::string user_id_hash =
19       chromeos::ProfileHelper::GetUserIdHashFromProfile(profile);
20   chromeos::UserList users = chromeos::UserManager::Get()->GetLoggedInUsers();
21
22   for (chromeos::UserList::const_iterator it = users.begin();
23       it != users.end(); ++it) {
24     if ((*it)->username_hash() == user_id_hash) {
25       *image = gfx::Image((*it)->image());
26       break;
27     }
28   }
29
30   // ChromeOS user images are rectangular, unlike Chrome profile avatars.
31   *is_rectangle = true;
32 }