jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 1 | // Copyright 2016 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/mus/shell_delegate_mus.h" |
| 6 | |
| 7 | #include <utility> |
| 8 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 9 | #include "ash/common/gpu_support_stub.h" |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 10 | #include "ash/common/palette_delegate.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 11 | #include "ash/common/session/session_state_delegate.h" |
msw | 8283940 | 2016-08-30 18:57:29 | [diff] [blame] | 12 | #include "ash/common/wm_shell.h" |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 13 | #include "ash/mus/accessibility_delegate_mus.h" |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 14 | #include "ash/mus/context_menu_mus.h" |
msw | 8283940 | 2016-08-30 18:57:29 | [diff] [blame] | 15 | #include "ash/mus/shelf_delegate_mus.h" |
jamescook | 01bf23e7 | 2017-01-09 19:58:15 | [diff] [blame] | 16 | #include "ash/mus/system_tray_delegate_mus.h" |
msw | 7d03b206 | 2016-09-10 00:13:21 | [diff] [blame] | 17 | #include "ash/mus/wallpaper_delegate_mus.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 18 | #include "base/memory/ptr_util.h" |
| 19 | #include "base/strings/string16.h" |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 20 | #include "base/strings/string_util.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 21 | #include "components/user_manager/user_info_impl.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 22 | #include "ui/gfx/image/image.h" |
| 23 | |
| 24 | namespace ash { |
| 25 | namespace { |
| 26 | |
| 27 | class SessionStateDelegateStub : public SessionStateDelegate { |
| 28 | public: |
| 29 | SessionStateDelegateStub() |
| 30 | : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {} |
| 31 | |
| 32 | ~SessionStateDelegateStub() override {} |
| 33 | |
| 34 | // SessionStateDelegate: |
| 35 | int GetMaximumNumberOfLoggedInUsers() const override { return 3; } |
| 36 | int NumberOfLoggedInUsers() const override { |
| 37 | // ash_shell has 2 users. |
| 38 | return 2; |
| 39 | } |
| 40 | bool IsActiveUserSessionStarted() const override { return true; } |
| 41 | bool CanLockScreen() const override { return true; } |
| 42 | bool IsScreenLocked() const override { return screen_locked_; } |
warx | b3fd59ca | 2016-10-25 04:06:07 | [diff] [blame] | 43 | bool ShouldLockScreenAutomatically() const override { return false; } |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 44 | void LockScreen() override { |
| 45 | screen_locked_ = true; |
| 46 | NOTIMPLEMENTED(); |
| 47 | } |
| 48 | void UnlockScreen() override { |
| 49 | NOTIMPLEMENTED(); |
| 50 | screen_locked_ = false; |
| 51 | } |
| 52 | bool IsUserSessionBlocked() const override { return false; } |
xiyuan | ba4b204b | 2016-10-18 17:14:10 | [diff] [blame] | 53 | session_manager::SessionState GetSessionState() const override { |
| 54 | return session_manager::SessionState::ACTIVE; |
| 55 | } |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 56 | const user_manager::UserInfo* GetUserInfo(UserIndex index) const override { |
| 57 | return user_info_.get(); |
| 58 | } |
| 59 | bool ShouldShowAvatar(WmWindow* window) const override { |
| 60 | NOTIMPLEMENTED(); |
| 61 | return !user_info_->GetImage().isNull(); |
| 62 | } |
| 63 | gfx::ImageSkia GetAvatarImageForWindow(WmWindow* window) const override { |
| 64 | NOTIMPLEMENTED(); |
| 65 | return gfx::ImageSkia(); |
| 66 | } |
| 67 | void SwitchActiveUser(const AccountId& account_id) override {} |
| 68 | void CycleActiveUser(CycleUser cycle_user) override {} |
| 69 | bool IsMultiProfileAllowedByPrimaryUserPolicy() const override { |
| 70 | return true; |
| 71 | } |
| 72 | void AddSessionStateObserver(ash::SessionStateObserver* observer) override {} |
| 73 | void RemoveSessionStateObserver( |
| 74 | ash::SessionStateObserver* observer) override {} |
| 75 | |
| 76 | private: |
| 77 | bool screen_locked_; |
| 78 | |
| 79 | // A pseudo user info. |
| 80 | std::unique_ptr<user_manager::UserInfo> user_info_; |
| 81 | |
| 82 | DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); |
| 83 | }; |
| 84 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 85 | } // namespace |
| 86 | |
msw | 0bc6a07 | 2017-02-14 16:33:38 | [diff] [blame^] | 87 | ShellDelegateMus::ShellDelegateMus(service_manager::Connector* connector) |
| 88 | : connector_(connector) {} |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 89 | |
| 90 | ShellDelegateMus::~ShellDelegateMus() {} |
| 91 | |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 92 | service_manager::Connector* ShellDelegateMus::GetShellConnector() const { |
jamescook | 2a6b869 | 2016-10-04 02:41:29 | [diff] [blame] | 93 | return connector_; |
| 94 | } |
| 95 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 96 | bool ShellDelegateMus::IsIncognitoAllowed() const { |
| 97 | NOTIMPLEMENTED(); |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | bool ShellDelegateMus::IsMultiProfilesEnabled() const { |
| 102 | NOTIMPLEMENTED(); |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | bool ShellDelegateMus::IsRunningInForcedAppMode() const { |
| 107 | NOTIMPLEMENTED(); |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | bool ShellDelegateMus::CanShowWindowForUser(WmWindow* window) const { |
| 112 | NOTIMPLEMENTED(); |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | bool ShellDelegateMus::IsForceMaximizeOnFirstRun() const { |
| 117 | NOTIMPLEMENTED(); |
| 118 | return false; |
| 119 | } |
| 120 | |
| 121 | void ShellDelegateMus::PreInit() { |
| 122 | NOTIMPLEMENTED(); |
| 123 | } |
| 124 | |
| 125 | void ShellDelegateMus::PreShutdown() { |
| 126 | NOTIMPLEMENTED(); |
| 127 | } |
| 128 | |
| 129 | void ShellDelegateMus::Exit() { |
| 130 | NOTIMPLEMENTED(); |
| 131 | } |
| 132 | |
| 133 | keyboard::KeyboardUI* ShellDelegateMus::CreateKeyboardUI() { |
| 134 | NOTIMPLEMENTED(); |
| 135 | return nullptr; |
| 136 | } |
| 137 | |
kenobi | b7af62b | 2016-07-29 21:40:16 | [diff] [blame] | 138 | void ShellDelegateMus::OpenUrlFromArc(const GURL& url) { |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 139 | NOTIMPLEMENTED(); |
| 140 | } |
| 141 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 142 | ShelfDelegate* ShellDelegateMus::CreateShelfDelegate(ShelfModel* model) { |
msw | 49cfb89 | 2016-10-11 16:46:15 | [diff] [blame] | 143 | return new ShelfDelegateMus(); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | SystemTrayDelegate* ShellDelegateMus::CreateSystemTrayDelegate() { |
jamescook | 2a6b869 | 2016-10-04 02:41:29 | [diff] [blame] | 147 | return new SystemTrayDelegateMus(); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 148 | } |
| 149 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 150 | std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() { |
msw | c691bf1 | 2016-10-19 17:05:39 | [diff] [blame] | 151 | return base::MakeUnique<WallpaperDelegateMus>(); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | SessionStateDelegate* ShellDelegateMus::CreateSessionStateDelegate() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 155 | // TODO: http://crbug.com/647416. |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 156 | NOTIMPLEMENTED() << " Using a stub SessionStateDeleagte implementation"; |
| 157 | return new SessionStateDelegateStub; |
| 158 | } |
| 159 | |
| 160 | AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() { |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 161 | return new AccessibilityDelegateMus(connector_); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 162 | } |
| 163 | |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 164 | std::unique_ptr<PaletteDelegate> ShellDelegateMus::CreatePaletteDelegate() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 165 | // TODO: http://crbug.com/647417. |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 166 | NOTIMPLEMENTED(); |
| 167 | return nullptr; |
| 168 | } |
| 169 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 170 | ui::MenuModel* ShellDelegateMus::CreateContextMenu(WmShelf* wm_shelf, |
| 171 | const ShelfItem* item) { |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 172 | return new ContextMenuMus(wm_shelf); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | GPUSupport* ShellDelegateMus::CreateGPUSupport() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 176 | // TODO: http://crbug.com/647421. |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 177 | NOTIMPLEMENTED() << " Using a stub GPUSupport implementation"; |
| 178 | return new GPUSupportStub(); |
| 179 | } |
| 180 | |
| 181 | base::string16 ShellDelegateMus::GetProductName() const { |
| 182 | NOTIMPLEMENTED(); |
| 183 | return base::string16(); |
| 184 | } |
| 185 | |
| 186 | gfx::Image ShellDelegateMus::GetDeprecatedAcceleratorImage() const { |
| 187 | NOTIMPLEMENTED(); |
| 188 | return gfx::Image(); |
| 189 | } |
| 190 | |
warx | 4c8baedb | 2016-12-03 22:38:50 | [diff] [blame] | 191 | bool ShellDelegateMus::IsTouchscreenEnabledInPrefs(bool use_local_state) const { |
| 192 | NOTIMPLEMENTED(); |
| 193 | return true; |
| 194 | } |
| 195 | |
| 196 | void ShellDelegateMus::SetTouchscreenEnabledInPrefs(bool enabled, |
| 197 | bool use_local_state) { |
| 198 | NOTIMPLEMENTED(); |
| 199 | } |
| 200 | |
| 201 | void ShellDelegateMus::UpdateTouchscreenStatusFromPrefs() { |
| 202 | NOTIMPLEMENTED(); |
| 203 | } |
| 204 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 205 | } // namespace ash |