- add sources.
[platform/framework/web/crosswalk.git] / src / ash / system / user / tray_user.h
1 // Copyright (c) 2012 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 ASH_SYSTEM_USER_TRAY_USER_H_
6 #define ASH_SYSTEM_USER_TRAY_USER_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/session_state_delegate.h"
10 #include "ash/system/tray/system_tray_item.h"
11 #include "ash/system/user/user_observer.h"
12 #include "base/compiler_specific.h"
13
14 namespace gfx {
15 class Rect;
16 class Point;
17 }
18
19 namespace views {
20 class ImageView;
21 class Label;
22 }
23
24 namespace ash {
25 namespace internal {
26
27 namespace tray {
28 class UserView;
29 class RoundedImageView;
30 }
31
32 class ASH_EXPORT TrayUser : public SystemTrayItem,
33                             public UserObserver {
34  public:
35   // The given |multiprofile_index| is the user number in a multi profile
36   // scenario. Index #0 is the running user, the other indices are other logged
37   // in users (if there are any). Depending on the multi user mode, there will
38   // be either one (index #0) or all users be visible in the system tray.
39   TrayUser(SystemTray* system_tray, MultiProfileIndex index);
40   virtual ~TrayUser();
41
42   // Allows unit tests to see if the item was created.
43   enum TestState {
44     HIDDEN,               // The item is hidden.
45     SEPARATOR,            // the item gets shown as a separator.
46     SHOWN,                // The item gets presented to the user.
47     HOVERED,              // The item is hovered and presented to the user.
48     ACTIVE,               // The item was clicked and can add a user.
49     ACTIVE_BUT_DISABLED   // The item was clicked anc cannot add a user.
50   };
51   TestState GetStateForTest() const;
52
53   // Checks if a drag and drop operation would be able to land a window on this
54   // |point_in_screen|.
55   bool CanDropWindowHereToTransferToUser(const gfx::Point& point_in_screen);
56
57   // Try to re-parent the |window| to a new owner. Returns true if the window
58   // got transfered.
59   bool TransferWindowToUser(aura::Window* window);
60
61   // Returns the bounds of the user panel in screen coordinates.
62   // Note: This only works when the panel shown.
63   gfx::Rect GetUserPanelBoundsInScreenForTest() const;
64
65  private:
66   // Overridden from SystemTrayItem.
67   virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
68   virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
69   virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
70   virtual void DestroyTrayView() OVERRIDE;
71   virtual void DestroyDefaultView() OVERRIDE;
72   virtual void DestroyDetailedView() OVERRIDE;
73   virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
74   virtual void UpdateAfterShelfAlignmentChange(
75       ShelfAlignment alignment) OVERRIDE;
76
77   // Overridden from UserObserver.
78   virtual void OnUserUpdate() OVERRIDE;
79   virtual void OnUserAddedToSession() OVERRIDE;
80
81   void UpdateAvatarImage(user::LoginStatus status);
82
83   // Get the user index which should be used for the tray icon of this item.
84   MultiProfileIndex GetTrayIndex();
85
86   // Return the radius for the tray item to use.
87   int GetTrayItemRadius();
88
89   // Updates the layout of this item.
90   void UpdateLayoutOfItem();
91
92   // The user index to use.
93   MultiProfileIndex multiprofile_index_;
94
95   tray::UserView* user_;
96
97   // View that contains label and/or avatar.
98   views::View* layout_view_;
99   tray::RoundedImageView* avatar_;
100   views::Label* label_;
101
102   // True if this element is the separator and it is shown.
103   bool separator_shown_;
104
105   DISALLOW_COPY_AND_ASSIGN(TrayUser);
106 };
107
108 }  // namespace internal
109 }  // namespace ash
110
111 #endif  // ASH_SYSTEM_USER_TRAY_USER_H_