blob: 873a63040e376498f5b8f36830d86890a3c2776b [file] [log] [blame]
jamescook33375732016-07-14 22:09:281// 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
jamescook33375732016-07-14 22:09:289#include "ash/common/gpu_support_stub.h"
10#include "ash/common/media_delegate.h"
jdufault0f4fa6e2016-08-05 19:13:5911#include "ash/common/palette_delegate.h"
jamescook33375732016-07-14 22:09:2812#include "ash/common/session/session_state_delegate.h"
mswccb5d692016-08-17 20:37:4813#include "ash/common/shelf/shelf_delegate.h"
jamescook33375732016-07-14 22:09:2814#include "ash/common/system/tray/default_system_tray_delegate.h"
msw0e91d932016-08-25 22:34:0915#include "ash/common/wallpaper/wallpaper_delegate.h"
jamescook428f986f2016-07-15 19:13:2516#include "ash/mus/accessibility_delegate_mus.h"
msw0e91d932016-08-25 22:34:0917#include "ash/mus/context_menu_mus.h"
skya279c7c2016-07-27 23:08:4218#include "ash/mus/new_window_delegate_mus.h"
jamescook33375732016-07-14 22:09:2819#include "base/memory/ptr_util.h"
20#include "base/strings/string16.h"
mswccb5d692016-08-17 20:37:4821#include "base/strings/string_util.h"
jamescook33375732016-07-14 22:09:2822#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
26namespace ash {
27namespace {
28
29class 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
85class 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
mswccb5d692016-08-17 20:37:48103class ShelfDelegateStub : public ShelfDelegate {
104 public:
105 ShelfDelegateStub() {}
106 ~ShelfDelegateStub() override {}
107
108 // ShelfDelegate overrides:
jamescook3ad0bed2016-08-24 21:01:05109 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 {}
mswccb5d692016-08-17 20:37:48115 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
jamescook33375732016-07-14 22:09:28128} // namespace
129
130ShellDelegateMus::ShellDelegateMus(
jamescook428f986f2016-07-15 19:13:25131 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}
jamescook33375732016-07-14 22:09:28137
138ShellDelegateMus::~ShellDelegateMus() {}
139
140bool ShellDelegateMus::IsFirstRunAfterBoot() const {
141 NOTIMPLEMENTED();
142 return false;
143}
144
145bool ShellDelegateMus::IsIncognitoAllowed() const {
146 NOTIMPLEMENTED();
147 return false;
148}
149
150bool ShellDelegateMus::IsMultiProfilesEnabled() const {
151 NOTIMPLEMENTED();
152 return false;
153}
154
155bool ShellDelegateMus::IsRunningInForcedAppMode() const {
156 NOTIMPLEMENTED();
157 return false;
158}
159
160bool ShellDelegateMus::CanShowWindowForUser(WmWindow* window) const {
161 NOTIMPLEMENTED();
162 return true;
163}
164
165bool ShellDelegateMus::IsForceMaximizeOnFirstRun() const {
166 NOTIMPLEMENTED();
167 return false;
168}
169
170void ShellDelegateMus::PreInit() {
171 NOTIMPLEMENTED();
172}
173
174void ShellDelegateMus::PreShutdown() {
175 NOTIMPLEMENTED();
176}
177
178void ShellDelegateMus::Exit() {
179 NOTIMPLEMENTED();
180}
181
182keyboard::KeyboardUI* ShellDelegateMus::CreateKeyboardUI() {
183 NOTIMPLEMENTED();
184 return nullptr;
185}
186
kenobib7af62b2016-07-29 21:40:16187void ShellDelegateMus::OpenUrlFromArc(const GURL& url) {
jamescook33375732016-07-14 22:09:28188 NOTIMPLEMENTED();
189}
190
191app_list::AppListPresenter* ShellDelegateMus::GetAppListPresenter() {
192 return app_list_presenter_.get();
193}
194
195ShelfDelegate* ShellDelegateMus::CreateShelfDelegate(ShelfModel* model) {
mswccb5d692016-08-17 20:37:48196 // TODO(mash): Implement a real shelf delegate; maybe port ShelfDelegateMus?
197 return new ShelfDelegateStub;
jamescook33375732016-07-14 22:09:28198}
199
200SystemTrayDelegate* ShellDelegateMus::CreateSystemTrayDelegate() {
201 NOTIMPLEMENTED() << " Using the default SystemTrayDelegate implementation";
202 return new DefaultSystemTrayDelegate;
203}
204
msw0e91d932016-08-25 22:34:09205std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() {
jamescook33375732016-07-14 22:09:28206 NOTIMPLEMENTED();
207 return nullptr;
208}
209
210SessionStateDelegate* ShellDelegateMus::CreateSessionStateDelegate() {
211 NOTIMPLEMENTED() << " Using a stub SessionStateDeleagte implementation";
212 return new SessionStateDelegateStub;
213}
214
215AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() {
jamescook428f986f2016-07-15 19:13:25216 return new AccessibilityDelegateMus(connector_);
jamescook33375732016-07-14 22:09:28217}
218
219NewWindowDelegate* ShellDelegateMus::CreateNewWindowDelegate() {
skya279c7c2016-07-27 23:08:42220 return new mus::NewWindowDelegateMus;
jamescook33375732016-07-14 22:09:28221}
222
223MediaDelegate* ShellDelegateMus::CreateMediaDelegate() {
224 NOTIMPLEMENTED() << " Using a stub MediaDelegate implementation";
225 return new MediaDelegateStub;
226}
227
jdufault0f4fa6e2016-08-05 19:13:59228std::unique_ptr<PaletteDelegate> ShellDelegateMus::CreatePaletteDelegate() {
229 NOTIMPLEMENTED();
230 return nullptr;
231}
232
jamescook33375732016-07-14 22:09:28233ui::MenuModel* ShellDelegateMus::CreateContextMenu(WmShelf* wm_shelf,
234 const ShelfItem* item) {
msw0e91d932016-08-25 22:34:09235 return new ContextMenuMus(wm_shelf);
jamescook33375732016-07-14 22:09:28236}
237
238GPUSupport* ShellDelegateMus::CreateGPUSupport() {
239 NOTIMPLEMENTED() << " Using a stub GPUSupport implementation";
240 return new GPUSupportStub();
241}
242
243base::string16 ShellDelegateMus::GetProductName() const {
244 NOTIMPLEMENTED();
245 return base::string16();
246}
247
248gfx::Image ShellDelegateMus::GetDeprecatedAcceleratorImage() const {
249 NOTIMPLEMENTED();
250 return gfx::Image();
251}
252
253} // namespace ash