OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "ash/session_state_delegate_stub.h" | |
6 | |
7 #include "ash/shell.h" | |
8 #include "ash/shell/example_factory.h" | |
9 #include "ash/shell_delegate.h" | |
10 #include "base/strings/string16.h" | |
11 #include "base/strings/utf_string_conversions.h" | |
12 | |
13 namespace ash { | |
14 | |
15 SessionStateDelegateStub::SessionStateDelegateStub() : screen_locked_(false) { | |
16 } | |
17 | |
18 SessionStateDelegateStub::~SessionStateDelegateStub() { | |
19 } | |
20 | |
21 content::BrowserContext* | |
22 SessionStateDelegateStub::GetBrowserContextByIndex( | |
23 MultiProfileIndex index) { | |
24 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); | |
25 } | |
26 | |
27 content::BrowserContext* | |
28 SessionStateDelegateStub::GetBrowserContextForWindow( | |
29 aura::Window* window) { | |
30 return Shell::GetInstance()->delegate()->GetActiveBrowserContext(); | |
31 } | |
32 | |
33 int SessionStateDelegateStub::GetMaximumNumberOfLoggedInUsers() const { | |
34 return 3; | |
35 } | |
36 | |
37 int SessionStateDelegateStub::NumberOfLoggedInUsers() const { | |
38 return 1; | |
39 } | |
40 | |
41 bool SessionStateDelegateStub::IsActiveUserSessionStarted() const { | |
42 return true; | |
43 } | |
44 | |
45 bool SessionStateDelegateStub::CanLockScreen() const { | |
46 return true; | |
47 } | |
48 | |
49 bool SessionStateDelegateStub::IsScreenLocked() const { | |
50 return screen_locked_; | |
51 } | |
52 | |
53 bool SessionStateDelegateStub::ShouldLockScreenBeforeSuspending() const { | |
54 return false; | |
55 } | |
56 | |
57 void SessionStateDelegateStub::LockScreen() { | |
58 shell::CreateLockScreen(); | |
59 screen_locked_ = true; | |
60 Shell::GetInstance()->UpdateShelfVisibility(); | |
61 } | |
62 | |
63 void SessionStateDelegateStub::UnlockScreen() { | |
64 screen_locked_ = false; | |
65 Shell::GetInstance()->UpdateShelfVisibility(); | |
66 } | |
67 | |
68 bool SessionStateDelegateStub::IsUserSessionBlocked() const { | |
69 return !IsActiveUserSessionStarted() || IsScreenLocked(); | |
70 } | |
71 | |
72 SessionStateDelegate::SessionState SessionStateDelegateStub::GetSessionState() | |
73 const { | |
74 // Assume that if session is not active we're at login. | |
75 return IsActiveUserSessionStarted() ? | |
76 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY; | |
77 } | |
78 | |
79 const base::string16 SessionStateDelegateStub::GetUserDisplayName( | |
80 MultiProfileIndex index) const { | |
81 return base::UTF8ToUTF16("stub-user"); | |
82 } | |
83 | |
84 const base::string16 SessionStateDelegateStub::GetUserGivenName( | |
85 MultiProfileIndex index) const { | |
86 return base::UTF8ToUTF16("Stub"); | |
87 } | |
88 | |
89 const std::string SessionStateDelegateStub::GetUserEmail( | |
90 MultiProfileIndex index) const { | |
91 return "stub-user@domain.com"; | |
92 } | |
93 | |
94 const std::string SessionStateDelegateStub::GetUserID( | |
95 MultiProfileIndex index) const { | |
96 return GetUserEmail(index); | |
97 } | |
98 | |
99 const gfx::ImageSkia& SessionStateDelegateStub::GetUserImage( | |
100 content::BrowserContext* context) const { | |
101 return user_image_; | |
102 } | |
103 | |
104 bool SessionStateDelegateStub::ShouldShowAvatar(aura::Window* window) { | |
105 return !user_image_.isNull(); | |
106 } | |
107 | |
108 void SessionStateDelegateStub::SwitchActiveUser(const std::string& user_id) { | |
109 } | |
110 | |
111 void SessionStateDelegateStub::CycleActiveUser(CycleUser cycle_user) { | |
112 } | |
113 | |
114 void SessionStateDelegateStub::AddSessionStateObserver( | |
115 ash::SessionStateObserver* observer) { | |
116 } | |
117 | |
118 void SessionStateDelegateStub::RemoveSessionStateObserver( | |
119 ash::SessionStateObserver* observer) { | |
120 } | |
121 | |
122 } // namespace ash | |
OLD | NEW |