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