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" |
| 10 | #include "ash/common/media_delegate.h" |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 11 | #include "ash/common/palette_delegate.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 12 | #include "ash/common/session/session_state_delegate.h" |
msw | 8283940 | 2016-08-30 18:57:29 | [diff] [blame] | 13 | #include "ash/common/wm_shell.h" |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 14 | #include "ash/mus/accessibility_delegate_mus.h" |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 15 | #include "ash/mus/context_menu_mus.h" |
sky | a279c7c | 2016-07-27 23:08:42 | [diff] [blame] | 16 | #include "ash/mus/new_window_delegate_mus.h" |
msw | 8283940 | 2016-08-30 18:57:29 | [diff] [blame] | 17 | #include "ash/mus/shelf_delegate_mus.h" |
msw | 7d03b206 | 2016-09-10 00:13:21 | [diff] [blame] | 18 | #include "ash/mus/wallpaper_delegate_mus.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 19 | #include "base/memory/ptr_util.h" |
| 20 | #include "base/strings/string16.h" |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 21 | #include "base/strings/string_util.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 22 | #include "components/user_manager/user_info_impl.h" |
| 23 | #include "ui/app_list/presenter/app_list_presenter.h" |
| 24 | #include "ui/gfx/image/image.h" |
| 25 | |
jamescook | 40496aa | 2016-09-29 18:38:47 | [diff] [blame] | 26 | #if defined(OS_CHROMEOS) |
| 27 | #include "ash/mus/system_tray_delegate_mus.h" |
| 28 | #else |
| 29 | #include "ash/common/system/tray/default_system_tray_delegate.h" |
| 30 | #endif |
| 31 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 32 | namespace ash { |
| 33 | namespace { |
| 34 | |
| 35 | class SessionStateDelegateStub : public SessionStateDelegate { |
| 36 | public: |
| 37 | SessionStateDelegateStub() |
| 38 | : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {} |
| 39 | |
| 40 | ~SessionStateDelegateStub() override {} |
| 41 | |
| 42 | // SessionStateDelegate: |
| 43 | int GetMaximumNumberOfLoggedInUsers() const override { return 3; } |
| 44 | int NumberOfLoggedInUsers() const override { |
| 45 | // ash_shell has 2 users. |
| 46 | return 2; |
| 47 | } |
| 48 | bool IsActiveUserSessionStarted() const override { return true; } |
| 49 | bool CanLockScreen() const override { return true; } |
| 50 | bool IsScreenLocked() const override { return screen_locked_; } |
| 51 | bool ShouldLockScreenBeforeSuspending() const override { return false; } |
| 52 | void LockScreen() override { |
| 53 | screen_locked_ = true; |
| 54 | NOTIMPLEMENTED(); |
| 55 | } |
| 56 | void UnlockScreen() override { |
| 57 | NOTIMPLEMENTED(); |
| 58 | screen_locked_ = false; |
| 59 | } |
| 60 | bool IsUserSessionBlocked() const override { return false; } |
| 61 | SessionState GetSessionState() const override { return SESSION_STATE_ACTIVE; } |
| 62 | const user_manager::UserInfo* GetUserInfo(UserIndex index) const override { |
| 63 | return user_info_.get(); |
| 64 | } |
| 65 | bool ShouldShowAvatar(WmWindow* window) const override { |
| 66 | NOTIMPLEMENTED(); |
| 67 | return !user_info_->GetImage().isNull(); |
| 68 | } |
| 69 | gfx::ImageSkia GetAvatarImageForWindow(WmWindow* window) const override { |
| 70 | NOTIMPLEMENTED(); |
| 71 | return gfx::ImageSkia(); |
| 72 | } |
| 73 | void SwitchActiveUser(const AccountId& account_id) override {} |
| 74 | void CycleActiveUser(CycleUser cycle_user) override {} |
| 75 | bool IsMultiProfileAllowedByPrimaryUserPolicy() const override { |
| 76 | return true; |
| 77 | } |
| 78 | void AddSessionStateObserver(ash::SessionStateObserver* observer) override {} |
| 79 | void RemoveSessionStateObserver( |
| 80 | ash::SessionStateObserver* observer) override {} |
| 81 | |
| 82 | private: |
| 83 | bool screen_locked_; |
| 84 | |
| 85 | // A pseudo user info. |
| 86 | std::unique_ptr<user_manager::UserInfo> user_info_; |
| 87 | |
| 88 | DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); |
| 89 | }; |
| 90 | |
| 91 | class MediaDelegateStub : public MediaDelegate { |
| 92 | public: |
| 93 | MediaDelegateStub() {} |
| 94 | ~MediaDelegateStub() override {} |
| 95 | |
| 96 | // MediaDelegate: |
| 97 | void HandleMediaNextTrack() override { NOTIMPLEMENTED(); } |
| 98 | void HandleMediaPlayPause() override { NOTIMPLEMENTED(); } |
| 99 | void HandleMediaPrevTrack() override { NOTIMPLEMENTED(); } |
| 100 | MediaCaptureState GetMediaCaptureState(UserIndex index) override { |
| 101 | NOTIMPLEMENTED(); |
| 102 | return MEDIA_CAPTURE_NONE; |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | DISALLOW_COPY_AND_ASSIGN(MediaDelegateStub); |
| 107 | }; |
| 108 | |
| 109 | } // namespace |
| 110 | |
msw | 2fbb48a | 2016-09-13 06:03:23 | [diff] [blame] | 111 | ShellDelegateMus::ShellDelegateMus(shell::Connector* connector) |
| 112 | : connector_(connector), app_list_presenter_(connector) { |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 113 | // |connector_| may be null in tests. |
| 114 | } |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 115 | |
| 116 | ShellDelegateMus::~ShellDelegateMus() {} |
| 117 | |
jamescook | 2a6b869 | 2016-10-04 02:41:29 | [diff] [blame^] | 118 | ::shell::Connector* ShellDelegateMus::GetShellConnector() const { |
| 119 | return connector_; |
| 120 | } |
| 121 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 122 | bool ShellDelegateMus::IsFirstRunAfterBoot() const { |
| 123 | NOTIMPLEMENTED(); |
| 124 | return false; |
| 125 | } |
| 126 | |
| 127 | bool ShellDelegateMus::IsIncognitoAllowed() const { |
| 128 | NOTIMPLEMENTED(); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | bool ShellDelegateMus::IsMultiProfilesEnabled() const { |
| 133 | NOTIMPLEMENTED(); |
| 134 | return false; |
| 135 | } |
| 136 | |
| 137 | bool ShellDelegateMus::IsRunningInForcedAppMode() const { |
| 138 | NOTIMPLEMENTED(); |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | bool ShellDelegateMus::CanShowWindowForUser(WmWindow* window) const { |
| 143 | NOTIMPLEMENTED(); |
| 144 | return true; |
| 145 | } |
| 146 | |
| 147 | bool ShellDelegateMus::IsForceMaximizeOnFirstRun() const { |
| 148 | NOTIMPLEMENTED(); |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | void ShellDelegateMus::PreInit() { |
| 153 | NOTIMPLEMENTED(); |
| 154 | } |
| 155 | |
| 156 | void ShellDelegateMus::PreShutdown() { |
| 157 | NOTIMPLEMENTED(); |
| 158 | } |
| 159 | |
| 160 | void ShellDelegateMus::Exit() { |
| 161 | NOTIMPLEMENTED(); |
| 162 | } |
| 163 | |
| 164 | keyboard::KeyboardUI* ShellDelegateMus::CreateKeyboardUI() { |
| 165 | NOTIMPLEMENTED(); |
| 166 | return nullptr; |
| 167 | } |
| 168 | |
kenobi | b7af62b | 2016-07-29 21:40:16 | [diff] [blame] | 169 | void ShellDelegateMus::OpenUrlFromArc(const GURL& url) { |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 170 | NOTIMPLEMENTED(); |
| 171 | } |
| 172 | |
| 173 | app_list::AppListPresenter* ShellDelegateMus::GetAppListPresenter() { |
msw | 2fbb48a | 2016-09-13 06:03:23 | [diff] [blame] | 174 | return &app_list_presenter_; |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | ShelfDelegate* ShellDelegateMus::CreateShelfDelegate(ShelfModel* model) { |
msw | 8283940 | 2016-08-30 18:57:29 | [diff] [blame] | 178 | return new ShelfDelegateMus(WmShell::Get()->shelf_model()); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | SystemTrayDelegate* ShellDelegateMus::CreateSystemTrayDelegate() { |
jamescook | 40496aa | 2016-09-29 18:38:47 | [diff] [blame] | 182 | #if defined(OS_CHROMEOS) |
jamescook | 2a6b869 | 2016-10-04 02:41:29 | [diff] [blame^] | 183 | return new SystemTrayDelegateMus(); |
jamescook | 40496aa | 2016-09-29 18:38:47 | [diff] [blame] | 184 | #else |
| 185 | // Windows and Linux do not support the services required for most system tray |
| 186 | // items. Use the same stub delegate as ash_shell_with_content. |
| 187 | return new DefaultSystemTrayDelegate(); |
| 188 | #endif |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 189 | } |
| 190 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 191 | std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() { |
msw | 7d03b206 | 2016-09-10 00:13:21 | [diff] [blame] | 192 | return base::MakeUnique<WallpaperDelegateMus>(connector_); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | SessionStateDelegate* ShellDelegateMus::CreateSessionStateDelegate() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 196 | // TODO: http://crbug.com/647416. |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 197 | NOTIMPLEMENTED() << " Using a stub SessionStateDeleagte implementation"; |
| 198 | return new SessionStateDelegateStub; |
| 199 | } |
| 200 | |
| 201 | AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() { |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 202 | return new AccessibilityDelegateMus(connector_); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | NewWindowDelegate* ShellDelegateMus::CreateNewWindowDelegate() { |
sky | a279c7c | 2016-07-27 23:08:42 | [diff] [blame] | 206 | return new mus::NewWindowDelegateMus; |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | MediaDelegate* ShellDelegateMus::CreateMediaDelegate() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 210 | // TODO: http://crbug.com/647409. |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 211 | NOTIMPLEMENTED() << " Using a stub MediaDelegate implementation"; |
| 212 | return new MediaDelegateStub; |
| 213 | } |
| 214 | |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 215 | std::unique_ptr<PaletteDelegate> ShellDelegateMus::CreatePaletteDelegate() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 216 | // TODO: http://crbug.com/647417. |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 217 | NOTIMPLEMENTED(); |
| 218 | return nullptr; |
| 219 | } |
| 220 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 221 | ui::MenuModel* ShellDelegateMus::CreateContextMenu(WmShelf* wm_shelf, |
| 222 | const ShelfItem* item) { |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 223 | return new ContextMenuMus(wm_shelf); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | GPUSupport* ShellDelegateMus::CreateGPUSupport() { |
sky | 1eb7caa | 2016-09-16 00:02:46 | [diff] [blame] | 227 | // TODO: http://crbug.com/647421. |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 228 | NOTIMPLEMENTED() << " Using a stub GPUSupport implementation"; |
| 229 | return new GPUSupportStub(); |
| 230 | } |
| 231 | |
| 232 | base::string16 ShellDelegateMus::GetProductName() const { |
| 233 | NOTIMPLEMENTED(); |
| 234 | return base::string16(); |
| 235 | } |
| 236 | |
| 237 | gfx::Image ShellDelegateMus::GetDeprecatedAcceleratorImage() const { |
| 238 | NOTIMPLEMENTED(); |
| 239 | return gfx::Image(); |
| 240 | } |
| 241 | |
| 242 | } // namespace ash |