blob: df9d36e61113e51b04f89a00d924124416e8ecac [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"
msw82839402016-08-30 18:57:2913#include "ash/common/wm_shell.h"
jamescook428f986f2016-07-15 19:13:2514#include "ash/mus/accessibility_delegate_mus.h"
msw0e91d932016-08-25 22:34:0915#include "ash/mus/context_menu_mus.h"
skya279c7c2016-07-27 23:08:4216#include "ash/mus/new_window_delegate_mus.h"
msw82839402016-08-30 18:57:2917#include "ash/mus/shelf_delegate_mus.h"
msw7d03b2062016-09-10 00:13:2118#include "ash/mus/wallpaper_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
jamescook40496aa2016-09-29 18:38:4726#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
jamescook33375732016-07-14 22:09:2832namespace ash {
33namespace {
34
35class 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
91class 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
rockot400ea35b2016-10-15 19:15:32111ShellDelegateMus::ShellDelegateMus(service_manager::Connector* connector)
msw2fbb48a2016-09-13 06:03:23112 : connector_(connector), app_list_presenter_(connector) {
jamescook428f986f2016-07-15 19:13:25113 // |connector_| may be null in tests.
114}
jamescook33375732016-07-14 22:09:28115
116ShellDelegateMus::~ShellDelegateMus() {}
117
rockot400ea35b2016-10-15 19:15:32118service_manager::Connector* ShellDelegateMus::GetShellConnector() const {
jamescook2a6b8692016-10-04 02:41:29119 return connector_;
120}
121
jamescook33375732016-07-14 22:09:28122bool ShellDelegateMus::IsFirstRunAfterBoot() const {
123 NOTIMPLEMENTED();
124 return false;
125}
126
127bool ShellDelegateMus::IsIncognitoAllowed() const {
128 NOTIMPLEMENTED();
129 return false;
130}
131
132bool ShellDelegateMus::IsMultiProfilesEnabled() const {
133 NOTIMPLEMENTED();
134 return false;
135}
136
137bool ShellDelegateMus::IsRunningInForcedAppMode() const {
138 NOTIMPLEMENTED();
139 return false;
140}
141
142bool ShellDelegateMus::CanShowWindowForUser(WmWindow* window) const {
143 NOTIMPLEMENTED();
144 return true;
145}
146
147bool ShellDelegateMus::IsForceMaximizeOnFirstRun() const {
148 NOTIMPLEMENTED();
149 return false;
150}
151
152void ShellDelegateMus::PreInit() {
153 NOTIMPLEMENTED();
154}
155
156void ShellDelegateMus::PreShutdown() {
157 NOTIMPLEMENTED();
158}
159
160void ShellDelegateMus::Exit() {
161 NOTIMPLEMENTED();
162}
163
164keyboard::KeyboardUI* ShellDelegateMus::CreateKeyboardUI() {
165 NOTIMPLEMENTED();
166 return nullptr;
167}
168
kenobib7af62b2016-07-29 21:40:16169void ShellDelegateMus::OpenUrlFromArc(const GURL& url) {
jamescook33375732016-07-14 22:09:28170 NOTIMPLEMENTED();
171}
172
173app_list::AppListPresenter* ShellDelegateMus::GetAppListPresenter() {
msw2fbb48a2016-09-13 06:03:23174 return &app_list_presenter_;
jamescook33375732016-07-14 22:09:28175}
176
177ShelfDelegate* ShellDelegateMus::CreateShelfDelegate(ShelfModel* model) {
msw49cfb892016-10-11 16:46:15178 return new ShelfDelegateMus();
jamescook33375732016-07-14 22:09:28179}
180
181SystemTrayDelegate* ShellDelegateMus::CreateSystemTrayDelegate() {
jamescook40496aa2016-09-29 18:38:47182#if defined(OS_CHROMEOS)
jamescook2a6b8692016-10-04 02:41:29183 return new SystemTrayDelegateMus();
jamescook40496aa2016-09-29 18:38:47184#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
jamescook33375732016-07-14 22:09:28189}
190
msw0e91d932016-08-25 22:34:09191std::unique_ptr<WallpaperDelegate> ShellDelegateMus::CreateWallpaperDelegate() {
msw7d03b2062016-09-10 00:13:21192 return base::MakeUnique<WallpaperDelegateMus>(connector_);
jamescook33375732016-07-14 22:09:28193}
194
195SessionStateDelegate* ShellDelegateMus::CreateSessionStateDelegate() {
sky1eb7caa2016-09-16 00:02:46196 // TODO: http://crbug.com/647416.
jamescook33375732016-07-14 22:09:28197 NOTIMPLEMENTED() << " Using a stub SessionStateDeleagte implementation";
198 return new SessionStateDelegateStub;
199}
200
201AccessibilityDelegate* ShellDelegateMus::CreateAccessibilityDelegate() {
jamescook428f986f2016-07-15 19:13:25202 return new AccessibilityDelegateMus(connector_);
jamescook33375732016-07-14 22:09:28203}
204
205NewWindowDelegate* ShellDelegateMus::CreateNewWindowDelegate() {
skya279c7c2016-07-27 23:08:42206 return new mus::NewWindowDelegateMus;
jamescook33375732016-07-14 22:09:28207}
208
209MediaDelegate* ShellDelegateMus::CreateMediaDelegate() {
sky1eb7caa2016-09-16 00:02:46210 // TODO: http://crbug.com/647409.
jamescook33375732016-07-14 22:09:28211 NOTIMPLEMENTED() << " Using a stub MediaDelegate implementation";
212 return new MediaDelegateStub;
213}
214
jdufault0f4fa6e2016-08-05 19:13:59215std::unique_ptr<PaletteDelegate> ShellDelegateMus::CreatePaletteDelegate() {
sky1eb7caa2016-09-16 00:02:46216 // TODO: http://crbug.com/647417.
jdufault0f4fa6e2016-08-05 19:13:59217 NOTIMPLEMENTED();
218 return nullptr;
219}
220
jamescook33375732016-07-14 22:09:28221ui::MenuModel* ShellDelegateMus::CreateContextMenu(WmShelf* wm_shelf,
222 const ShelfItem* item) {
msw0e91d932016-08-25 22:34:09223 return new ContextMenuMus(wm_shelf);
jamescook33375732016-07-14 22:09:28224}
225
226GPUSupport* ShellDelegateMus::CreateGPUSupport() {
sky1eb7caa2016-09-16 00:02:46227 // TODO: http://crbug.com/647421.
jamescook33375732016-07-14 22:09:28228 NOTIMPLEMENTED() << " Using a stub GPUSupport implementation";
229 return new GPUSupportStub();
230}
231
232base::string16 ShellDelegateMus::GetProductName() const {
233 NOTIMPLEMENTED();
234 return base::string16();
235}
236
237gfx::Image ShellDelegateMus::GetDeprecatedAcceleratorImage() const {
238 NOTIMPLEMENTED();
239 return gfx::Image();
240}
241
242} // namespace ash