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 | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 13 | #include "ash/common/shelf/shelf_delegate.h" |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 14 | #include "ash/common/system/tray/default_system_tray_delegate.h" |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame^] | 15 | #include "ash/common/wallpaper/wallpaper_delegate.h" |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 16 | #include "ash/mus/accessibility_delegate_mus.h" |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame^] | 17 | #include "ash/mus/context_menu_mus.h" |
sky | a279c7c | 2016-07-27 23:08:42 | [diff] [blame] | 18 | #include "ash/mus/new_window_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 | |
| 26 | namespace ash { |
| 27 | namespace { |
| 28 | |
| 29 | class SessionStateDelegateStub : public SessionStateDelegate { |
| 30 | public: |
| 31 | SessionStateDelegateStub() |
| 32 | : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {} |
| 33 | |
| 34 | ~SessionStateDelegateStub() override {} |
| 35 | |
| 36 | // SessionStateDelegate: |
| 37 | int GetMaximumNumberOfLoggedInUsers() const override { return 3; } |
| 38 | int NumberOfLoggedInUsers() const override { |
| 39 | // ash_shell has 2 users. |
| 40 | return 2; |
| 41 | } |
| 42 | bool IsActiveUserSessionStarted() const override { return true; } |
| 43 | bool CanLockScreen() const override { return true; } |
| 44 | bool IsScreenLocked() const override { return screen_locked_; } |
| 45 | bool ShouldLockScreenBeforeSuspending() const override { return false; } |
| 46 | void LockScreen() override { |
| 47 | screen_locked_ = true; |
| 48 | NOTIMPLEMENTED(); |
| 49 | } |
| 50 | void UnlockScreen() override { |
| 51 | NOTIMPLEMENTED(); |
| 52 | screen_locked_ = false; |
| 53 | } |
| 54 | bool IsUserSessionBlocked() const override { return false; } |
| 55 | SessionState GetSessionState() const override { return SESSION_STATE_ACTIVE; } |
| 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 | |
| 85 | class MediaDelegateStub : public MediaDelegate { |
| 86 | public: |
| 87 | MediaDelegateStub() {} |
| 88 | ~MediaDelegateStub() override {} |
| 89 | |
| 90 | // MediaDelegate: |
| 91 | void HandleMediaNextTrack() override { NOTIMPLEMENTED(); } |
| 92 | void HandleMediaPlayPause() override { NOTIMPLEMENTED(); } |
| 93 | void HandleMediaPrevTrack() override { NOTIMPLEMENTED(); } |
| 94 | MediaCaptureState GetMediaCaptureState(UserIndex index) override { |
| 95 | NOTIMPLEMENTED(); |
| 96 | return MEDIA_CAPTURE_NONE; |
| 97 | } |
| 98 | |
| 99 | private: |
| 100 | DISALLOW_COPY_AND_ASSIGN(MediaDelegateStub); |
| 101 | }; |
| 102 | |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 103 | class ShelfDelegateStub : public ShelfDelegate { |
| 104 | public: |
| 105 | ShelfDelegateStub() {} |
| 106 | ~ShelfDelegateStub() override {} |
| 107 | |
| 108 | // ShelfDelegate overrides: |
jamescook | 3ad0bed | 2016-08-24 21:01:05 | [diff] [blame] | 109 | void OnShelfCreated(WmShelf* shelf) override {} |
| 110 | void OnShelfDestroyed(WmShelf* shelf) override {} |
| 111 | void OnShelfAlignmentChanged(WmShelf* shelf) override {} |
| 112 | void OnShelfAutoHideBehaviorChanged(WmShelf* shelf) override {} |
| 113 | void OnShelfAutoHideStateChanged(WmShelf* shelf) override {} |
| 114 | void OnShelfVisibilityStateChanged(WmShelf* shelf) override {} |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 115 | ShelfID GetShelfIDForAppID(const std::string& app_id) override { return 0; } |
| 116 | bool HasShelfIDToAppIDMapping(ShelfID id) const override { return false; } |
| 117 | const std::string& GetAppIDForShelfID(ShelfID id) override { |
| 118 | return base::EmptyString(); |
| 119 | } |
| 120 | void PinAppWithID(const std::string& app_id) override {} |
| 121 | bool IsAppPinned(const std::string& app_id) override { return false; } |
| 122 | void UnpinAppWithID(const std::string& app_id) override {} |
| 123 | |
| 124 | private: |
| 125 | DISALLOW_COPY_AND_ASSIGN(ShelfDelegateStub); |
| 126 | }; |
| 127 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 128 | } // namespace |
| 129 | |
| 130 | ShellDelegateMus::ShellDelegateMus( |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 131 | std::unique_ptr<app_list::AppListPresenter> app_list_presenter, |
| 132 | shell::Connector* connector) |
| 133 | : app_list_presenter_(std::move(app_list_presenter)), |
| 134 | connector_(connector) { |
| 135 | // |connector_| may be null in tests. |
| 136 | } |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 137 | |
| 138 | ShellDelegateMus::~ShellDelegateMus() {} |
| 139 | |
| 140 | bool ShellDelegateMus::IsFirstRunAfterBoot() const { |
| 141 | NOTIMPLEMENTED(); |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | bool ShellDelegateMus::IsIncognitoAllowed() const { |
| 146 | NOTIMPLEMENTED(); |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | bool ShellDelegateMus::IsMultiProfilesEnabled() const { |
| 151 | NOTIMPLEMENTED(); |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | bool ShellDelegateMus::IsRunningInForcedAppMode() const { |
| 156 | NOTIMPLEMENTED(); |
| 157 | return false; |
| 158 | } |
| 159 | |
| 160 | bool ShellDelegateMus::CanShowWindowForUser(WmWindow* window) const { |
| 161 | NOTIMPLEMENTED(); |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | bool ShellDelegateMus::IsForceMaximizeOnFirstRun() const { |
| 166 | NOTIMPLEMENTED(); |
| 167 | return false; |
| 168 | } |
| 169 | |
| 170 | void ShellDelegateMus::PreInit() { |
| 171 | NOTIMPLEMENTED(); |
| 172 | } |
| 173 | |
| 174 | void ShellDelegateMus::PreShutdown() { |
| 175 | NOTIMPLEMENTED(); |
| 176 | } |
| 177 | |
| 178 | void ShellDelegateMus::Exit() { |
| 179 | NOTIMPLEMENTED(); |
| 180 | } |
| 181 | |
| 182 | keyboard::KeyboardUI* ShellDelegateMus::CreateKeyboardUI() { |
| 183 | NOTIMPLEMENTED(); |
| 184 | return nullptr; |
| 185 | } |
| 186 | |
kenobi | b7af62b | 2016-07-29 21:40:16 | [diff] [blame] | 187 | void ShellDelegateMus::OpenUrlFromArc(const GURL& url) { |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 188 | NOTIMPLEMENTED(); |
| 189 | } |
| 190 | |
| 191 | app_list::AppListPresenter* ShellDelegateMus::GetAppListPresenter() { |
| 192 | return app_list_presenter_.get(); |
| 193 | } |
| 194 | |
| 195 | ShelfDelegate* ShellDelegateMus::CreateShelfDelegate(ShelfModel* model) { |
msw | ccb5d69 | 2016-08-17 20:37:48 | [diff] [blame] | 196 | // TODO(mash): Implement a real shelf delegate; maybe port ShelfDelegateMus? |
| 197 | return new ShelfDelegateStub; |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | SystemTrayDelegate* ShellDelegateMus::CreateSystemTrayDelegate() { |
| 201 | NOTIMPLEMENTED() << " Using the default SystemTrayDelegate implementation"; |
| 202 | return new DefaultSystemTrayDelegate; |
| 203 | } |
| 204 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame^] | 205 | std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() { |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 206 | NOTIMPLEMENTED(); |
| 207 | return nullptr; |
| 208 | } |
| 209 | |
| 210 | SessionStateDelegate* ShellDelegateMus::CreateSessionStateDelegate() { |
| 211 | NOTIMPLEMENTED() << " Using a stub SessionStateDeleagte implementation"; |
| 212 | return new SessionStateDelegateStub; |
| 213 | } |
| 214 | |
| 215 | AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() { |
jamescook | 428f986f | 2016-07-15 19:13:25 | [diff] [blame] | 216 | return new AccessibilityDelegateMus(connector_); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | NewWindowDelegate* ShellDelegateMus::CreateNewWindowDelegate() { |
sky | a279c7c | 2016-07-27 23:08:42 | [diff] [blame] | 220 | return new mus::NewWindowDelegateMus; |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | MediaDelegate* ShellDelegateMus::CreateMediaDelegate() { |
| 224 | NOTIMPLEMENTED() << " Using a stub MediaDelegate implementation"; |
| 225 | return new MediaDelegateStub; |
| 226 | } |
| 227 | |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 228 | std::unique_ptr<PaletteDelegate> ShellDelegateMus::CreatePaletteDelegate() { |
| 229 | NOTIMPLEMENTED(); |
| 230 | return nullptr; |
| 231 | } |
| 232 | |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 233 | ui::MenuModel* ShellDelegateMus::CreateContextMenu(WmShelf* wm_shelf, |
| 234 | const ShelfItem* item) { |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame^] | 235 | return new ContextMenuMus(wm_shelf); |
jamescook | 3337573 | 2016-07-14 22:09:28 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | GPUSupport* ShellDelegateMus::CreateGPUSupport() { |
| 239 | NOTIMPLEMENTED() << " Using a stub GPUSupport implementation"; |
| 240 | return new GPUSupportStub(); |
| 241 | } |
| 242 | |
| 243 | base::string16 ShellDelegateMus::GetProductName() const { |
| 244 | NOTIMPLEMENTED(); |
| 245 | return base::string16(); |
| 246 | } |
| 247 | |
| 248 | gfx::Image ShellDelegateMus::GetDeprecatedAcceleratorImage() const { |
| 249 | NOTIMPLEMENTED(); |
| 250 | return gfx::Image(); |
| 251 | } |
| 252 | |
| 253 | } // namespace ash |