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