Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / ash / session_state_delegate_chromeos.h
blob114bcde0bd985ff135c60e25c774f45ec7fcd40b
1 // Copyright (c) 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.
5 #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
6 #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
8 #include "ash/session/session_state_delegate.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/observer_list.h"
12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
13 #include "chromeos/login/login_state.h"
14 #include "components/user_manager/user_manager.h"
16 namespace ash {
17 class SessionStateObserver;
18 } // namespace ash
20 class SessionStateDelegateChromeos
21 : public ash::SessionStateDelegate,
22 public chromeos::LoginState::Observer,
23 public user_manager::UserManager::UserSessionStateObserver,
24 public chromeos::UserAddingScreen::Observer {
25 public:
26 SessionStateDelegateChromeos();
27 virtual ~SessionStateDelegateChromeos();
29 // ash::SessionStateDelegate:
30 virtual content::BrowserContext* GetBrowserContextByIndex(
31 ash::MultiProfileIndex index) override;
32 virtual content::BrowserContext* GetBrowserContextForWindow(
33 aura::Window* window) override;
34 virtual int GetMaximumNumberOfLoggedInUsers() const override;
35 virtual int NumberOfLoggedInUsers() const override;
36 virtual bool CanAddUserToMultiProfile(AddUserError* error) const override;
37 virtual bool IsActiveUserSessionStarted() const override;
38 virtual bool CanLockScreen() const override;
39 virtual bool IsScreenLocked() const override;
40 virtual bool ShouldLockScreenBeforeSuspending() const override;
41 virtual void LockScreen() override;
42 virtual void UnlockScreen() override;
43 virtual bool IsUserSessionBlocked() const override;
44 virtual SessionState GetSessionState() const override;
45 virtual const user_manager::UserInfo* GetUserInfo(
46 ash::MultiProfileIndex index) const override;
47 virtual const user_manager::UserInfo* GetUserInfo(
48 content::BrowserContext* context) const override;
49 virtual bool ShouldShowAvatar(aura::Window* window) const override;
50 virtual void SwitchActiveUser(const std::string& user_id) override;
51 virtual void CycleActiveUser(CycleUser cycle_user) override;
52 virtual bool IsMultiProfileAllowedByPrimaryUserPolicy() const override;
53 virtual void AddSessionStateObserver(
54 ash::SessionStateObserver* observer) override;
55 virtual void RemoveSessionStateObserver(
56 ash::SessionStateObserver* observer) override;
58 // chromeos::LoginState::Observer overrides.
59 virtual void LoggedInStateChanged() override;
61 // user_manager::UserManager::UserSessionStateObserver:
62 virtual void ActiveUserChanged(
63 const user_manager::User* active_user) override;
64 virtual void UserAddedToSession(
65 const user_manager::User* added_user) override;
67 // chromeos::UserAddingScreen::Observer:
68 virtual void OnUserAddingStarted() override;
69 virtual void OnUserAddingFinished() override;
71 private:
72 // Sets session state to |new_state|.
73 // If |force| is true then |new_state| is set even if existing session
74 // state is the same (used for explicit initialization).
75 void SetSessionState(SessionState new_state, bool force);
77 // Notify observers about session state change.
78 void NotifySessionStateChanged();
80 // Switches to a new user. This call might show a dialog asking the user if he
81 // wants to stop desktop casting before switching.
82 void TryToSwitchUser(const std::string& user_id);
84 // List of observers is only used on Chrome OS for now.
85 ObserverList<ash::SessionStateObserver> session_state_observer_list_;
87 // Session state (e.g. login screen vs. user session).
88 SessionState session_state_;
90 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeos);
93 #endif // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_