1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_VIEW_H_
6#define CHROME_BROWSER_CHROMEOS_LOGIN_USER_VIEW_H_
7#pragma once
8
9#include <string>
10
11#include "views/controls/button/button.h"
12#include "views/controls/link.h"
13#include "views/view.h"
14
15class SkBitmap;
16
17namespace views {
18class ImageView;
19class TextButton;
20class Throbber;
21}  // namespace views
22
23namespace chromeos {
24
25class SignoutView;
26class PodImageView;
27
28class UserView : public views::View,
29                 public views::LinkController,
30                 public views::ButtonListener {
31 public:
32  class Delegate {
33   public:
34    virtual ~Delegate() {}
35
36    // Notifies that user pressed signout button on screen locker.
37    virtual void OnSignout() {}
38
39    // Notifies that user would like to remove this user from login screen.
40    virtual void OnRemoveUser() {}
41
42    // Returns true if current user is selected.
43    virtual bool IsUserSelected() const = 0;
44
45    // Notifies about locale change.
46    virtual void OnLocaleChanged() {}
47  };
48
49  // Creates UserView for login screen (|is_login| == true) or screen locker.
50  // On login screen this will have remove button.
51  // On screen locker it will have sign out button. |need_background| is needed
52  // to show image with transparent areas.
53  UserView(Delegate* delegate, bool is_login, bool need_background);
54
55  // view::View overrides.
56  virtual gfx::Size GetPreferredSize();
57  virtual void OnLocaleChanged();
58
59  // Sets the user's image. If image's size is less than
60  // 75% of window size, image size is preserved to avoid blur. Otherwise,
61  // the image is resized to fit window size precisely. Image view repaints
62  // itself.
63  void SetImage(const SkBitmap& image, const SkBitmap& image_hot);
64
65  // Sets tooltip over the image.
66  void SetTooltipText(const std::wstring& text);
67
68  // Show/Hide remove button.
69  void SetRemoveButtonVisible(bool flag);
70
71  // Enable/Disable sign-out button.
72  void SetSignoutEnabled(bool enabled);
73
74  // Implements LinkController.
75  // Called when a signout link is clicked.
76  virtual void LinkActivated(views::Link* source, int event_flags);
77
78  // Overridden from views::ButtonListener.
79  virtual void ButtonPressed(views::Button* sender, const views::Event& event);
80
81 private:
82  void Init(bool need_background);
83
84  Delegate* delegate_;
85
86  SignoutView* signout_view_;
87  PodImageView* image_view_;
88
89  views::TextButton* remove_button_;
90
91  DISALLOW_COPY_AND_ASSIGN(UserView);
92};
93
94}  // chromeos
95
96#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_USER_VIEW_H_
97