blob: c750ae4b1c87b70dd3f2f650312c847ad23b678e [file] [log] [blame]
[email protected]262f8bd2012-03-23 19:30:271// Copyright (c) 2012 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/shell/shell_delegate_impl.h"
6
[email protected]f3ab6eff52013-10-24 03:29:387#include "ash/accessibility_delegate.h"
[email protected]f3ab6eff52013-10-24 03:29:388#include "ash/default_accessibility_delegate.h"
[email protected]a7611df2013-09-26 07:57:109#include "ash/default_user_wallpaper_delegate.h"
[email protected]99edff3e2014-01-31 18:20:3610#include "ash/gpu_support_stub.h"
[email protected]efc897f72013-11-01 11:43:0711#include "ash/media_delegate.h"
[email protected]47686c42013-10-25 01:49:1712#include "ash/new_window_delegate.h"
[email protected]fdf74bf2014-04-30 21:24:0213#include "ash/session/session_state_delegate.h"
benb91330f2015-10-03 22:20:1814#include "ash/shell/content/shell_content_state_impl.h"
[email protected]565f32fc02013-03-05 18:51:4815#include "ash/shell/context_menu.h"
[email protected]262f8bd2012-03-23 19:30:2716#include "ash/shell/example_factory.h"
[email protected]8b57e942013-12-09 19:39:2017#include "ash/shell/shelf_delegate_impl.h"
[email protected]b77236f72012-03-25 03:07:1918#include "ash/shell/toplevel_window.h"
[email protected]262f8bd2012-03-23 19:30:2719#include "ash/shell_window_ids.h"
[email protected]9f19d5c2013-09-13 17:01:4820#include "ash/system/tray/default_system_tray_delegate.h"
ben974286a2015-10-10 00:45:1221#include "ash/test/test_keyboard_ui.h"
[email protected]a41b4e12013-09-20 04:36:3422#include "ash/wm/window_state.h"
[email protected]9e3e6352013-07-17 04:07:5123#include "base/message_loop/message_loop.h"
[email protected]7009d9b2014-05-03 21:38:3624#include "base/strings/utf_string_conversions.h"
[email protected]d66eac42014-07-14 23:48:3025#include "components/user_manager/user_info_impl.h"
tapted537b88b12014-09-19 02:48:5226#include "ui/app_list/app_list_view_delegate.h"
[email protected]262f8bd2012-03-23 19:30:2727#include "ui/aura/window.h"
afakhrycd2bb98d2015-09-09 09:03:4228#include "ui/gfx/image/image.h"
ben93072442015-10-05 19:14:3229#include "ui/gfx/image/image_skia.h"
[email protected]262f8bd2012-03-23 19:30:2730
31namespace ash {
32namespace shell {
[email protected]47686c42013-10-25 01:49:1733namespace {
34
35class NewWindowDelegateImpl : public NewWindowDelegate {
36 public:
37 NewWindowDelegateImpl() {}
dchengf5963512014-10-28 01:14:1338 ~NewWindowDelegateImpl() override {}
[email protected]47686c42013-10-25 01:49:1739
[email protected]7009d9b2014-05-03 21:38:3640 // NewWindowDelegate:
dchengf5963512014-10-28 01:14:1341 void NewTab() override {}
42 void NewWindow(bool incognito) override {
[email protected]47686c42013-10-25 01:49:1743 ash::shell::ToplevelWindow::CreateParams create_params;
44 create_params.can_resize = true;
45 create_params.can_maximize = true;
46 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
47 }
dchengf5963512014-10-28 01:14:1348 void OpenFileManager() override {}
49 void OpenCrosh() override {}
cyleeb6ce38f2015-01-08 12:25:3150 void OpenGetHelp() override {}
dchengf5963512014-10-28 01:14:1351 void RestoreTab() override {}
52 void ShowKeyboardOverlay() override {}
53 void ShowTaskManager() override {}
54 void OpenFeedbackPage() override {}
[email protected]47686c42013-10-25 01:49:1755
56 private:
57 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
58};
59
[email protected]efc897f72013-11-01 11:43:0760class MediaDelegateImpl : public MediaDelegate {
61 public:
62 MediaDelegateImpl() {}
dchengf5963512014-10-28 01:14:1363 ~MediaDelegateImpl() override {}
[email protected]efc897f72013-11-01 11:43:0764
[email protected]7009d9b2014-05-03 21:38:3665 // MediaDelegate:
dchengf5963512014-10-28 01:14:1366 void HandleMediaNextTrack() override {}
67 void HandleMediaPlayPause() override {}
68 void HandleMediaPrevTrack() override {}
ben93072442015-10-05 19:14:3269 MediaCaptureState GetMediaCaptureState(UserIndex index) override {
[email protected]7009d9b2014-05-03 21:38:3670 return MEDIA_CAPTURE_VIDEO;
71 }
[email protected]efc897f72013-11-01 11:43:0772
73 private:
74 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
75};
76
[email protected]7009d9b2014-05-03 21:38:3677class SessionStateDelegateImpl : public SessionStateDelegate {
78 public:
79 SessionStateDelegateImpl()
[email protected]d66eac42014-07-14 23:48:3080 : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {}
[email protected]7009d9b2014-05-03 21:38:3681
dchengf5963512014-10-28 01:14:1382 ~SessionStateDelegateImpl() override {}
[email protected]7009d9b2014-05-03 21:38:3683
84 // SessionStateDelegate:
dchengf5963512014-10-28 01:14:1385 int GetMaximumNumberOfLoggedInUsers() const override { return 3; }
86 int NumberOfLoggedInUsers() const override {
[email protected]7009d9b2014-05-03 21:38:3687 // ash_shell has 2 users.
88 return 2;
89 }
dchengf5963512014-10-28 01:14:1390 bool IsActiveUserSessionStarted() const override { return true; }
91 bool CanLockScreen() const override { return true; }
92 bool IsScreenLocked() const override { return screen_locked_; }
93 bool ShouldLockScreenBeforeSuspending() const override { return false; }
94 void LockScreen() override {
[email protected]7009d9b2014-05-03 21:38:3695 shell::CreateLockScreen();
96 screen_locked_ = true;
97 Shell::GetInstance()->UpdateShelfVisibility();
98 }
dchengf5963512014-10-28 01:14:1399 void UnlockScreen() override {
[email protected]7009d9b2014-05-03 21:38:36100 screen_locked_ = false;
101 Shell::GetInstance()->UpdateShelfVisibility();
102 }
dchengf5963512014-10-28 01:14:13103 bool IsUserSessionBlocked() const override {
[email protected]7009d9b2014-05-03 21:38:36104 return !IsActiveUserSessionStarted() || IsScreenLocked();
105 }
dchengf5963512014-10-28 01:14:13106 SessionState GetSessionState() const override {
[email protected]7009d9b2014-05-03 21:38:36107 // Assume that if session is not active we're at login.
108 return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE
109 : SESSION_STATE_LOGIN_PRIMARY;
110 }
ben93072442015-10-05 19:14:32111 const user_manager::UserInfo* GetUserInfo(UserIndex index) const override {
[email protected]7009d9b2014-05-03 21:38:36112 return user_info_.get();
113 }
dchengf5963512014-10-28 01:14:13114 bool ShouldShowAvatar(aura::Window* window) const override {
[email protected]7009d9b2014-05-03 21:38:36115 return !user_info_->GetImage().isNull();
116 }
ben93072442015-10-05 19:14:32117 gfx::ImageSkia GetAvatarImageForWindow(aura::Window* window) const override {
118 return gfx::ImageSkia();
119 }
alematecdf46dd2015-11-12 03:15:16120 void SwitchActiveUser(const AccountId& account_id) override {}
dchengf5963512014-10-28 01:14:13121 void CycleActiveUser(CycleUser cycle_user) override {}
122 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override {
[email protected]815dfac92014-08-13 16:04:04123 return true;
124 }
dchengf5963512014-10-28 01:14:13125 void AddSessionStateObserver(ash::SessionStateObserver* observer) override {}
126 void RemoveSessionStateObserver(
mostynb10d6b382014-10-03 16:23:45127 ash::SessionStateObserver* observer) override {}
[email protected]7009d9b2014-05-03 21:38:36128
129 private:
130 bool screen_locked_;
131
132 // A pseudo user info.
[email protected]d66eac42014-07-14 23:48:30133 scoped_ptr<user_manager::UserInfo> user_info_;
[email protected]7009d9b2014-05-03 21:38:36134
135 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl);
136};
137
[email protected]47686c42013-10-25 01:49:17138} // namespace
[email protected]262f8bd2012-03-23 19:30:27139
mswc3cf79d2016-01-05 20:52:06140ShellDelegateImpl::ShellDelegateImpl() : shelf_delegate_(nullptr) {}
[email protected]262f8bd2012-03-23 19:30:27141
mswc3cf79d2016-01-05 20:52:06142ShellDelegateImpl::~ShellDelegateImpl() {}
[email protected]262f8bd2012-03-23 19:30:27143
[email protected]5c85d5d2012-12-03 14:22:56144bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
[email protected]697f04c2012-10-03 01:15:10145 return false;
146}
147
[email protected]5ecf6122013-10-31 12:24:09148bool ShellDelegateImpl::IsIncognitoAllowed() const {
149 return true;
150}
151
[email protected]e718e6f2013-04-15 16:01:59152bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
153 return false;
154}
155
[email protected]565f32fc02013-03-05 18:51:48156bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
157 return false;
158}
159
ben894584d2015-09-30 23:56:53160bool ShellDelegateImpl::CanShowWindowForUser(aura::Window* window) const {
161 return true;
162}
163
peletskyida0bbb12015-04-08 17:11:04164bool ShellDelegateImpl::IsForceMaximizeOnFirstRun() const {
165 return false;
166}
167
[email protected]dcc990722013-03-24 16:35:20168void ShellDelegateImpl::PreInit() {
169}
170
[email protected]050e77182014-03-25 15:29:16171void ShellDelegateImpl::PreShutdown() {
[email protected]3528b7d2012-04-18 10:46:36172}
173
[email protected]262f8bd2012-03-23 19:30:27174void ShellDelegateImpl::Exit() {
sadruld3af96a2016-01-28 16:16:24175 base::MessageLoop::current()->QuitWhenIdle();
[email protected]262f8bd2012-03-23 19:30:27176}
177
ben974286a2015-10-10 00:45:12178keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() {
179 return new TestKeyboardUI;
[email protected]86459e2c2013-04-10 13:39:24180}
181
[email protected]40db36e2014-04-04 14:08:18182void ShellDelegateImpl::VirtualKeyboardActivated(bool activated) {
183}
184
185void ShellDelegateImpl::AddVirtualKeyboardStateObserver(
186 VirtualKeyboardStateObserver* observer) {
187}
188
189void ShellDelegateImpl::RemoveVirtualKeyboardStateObserver(
190 VirtualKeyboardStateObserver* observer) {
191}
192
tapted537b88b12014-09-19 02:48:52193app_list::AppListViewDelegate* ShellDelegateImpl::GetAppListViewDelegate() {
194 if (!app_list_view_delegate_)
195 app_list_view_delegate_.reset(ash::shell::CreateAppListViewDelegate());
196 return app_list_view_delegate_.get();
[email protected]262f8bd2012-03-23 19:30:27197}
198
[email protected]8b57e942013-12-09 19:39:20199ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
mswc3cf79d2016-01-05 20:52:06200 shelf_delegate_ = new ShelfDelegateImpl();
[email protected]8b57e942013-12-09 19:39:20201 return shelf_delegate_;
[email protected]262f8bd2012-03-23 19:30:27202}
203
[email protected]51ed5992012-11-07 10:14:39204ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
[email protected]9f19d5c2013-09-13 17:01:48205 return new DefaultSystemTrayDelegate;
[email protected]262f8bd2012-03-23 19:30:27206}
207
208ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
[email protected]a7611df2013-09-26 07:57:10209 return new DefaultUserWallpaperDelegate();
[email protected]262f8bd2012-03-23 19:30:27210}
[email protected]4d7ce4352012-07-13 06:56:06211
[email protected]fcb123d2013-04-17 15:58:49212ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
[email protected]7009d9b2014-05-03 21:38:36213 return new SessionStateDelegateImpl;
[email protected]fcb123d2013-04-17 15:58:49214}
215
[email protected]f3ab6eff52013-10-24 03:29:38216ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
[email protected]093b8d642014-04-03 20:59:28217 return new DefaultAccessibilityDelegate;
[email protected]f3ab6eff52013-10-24 03:29:38218}
219
[email protected]47686c42013-10-25 01:49:17220ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
221 return new NewWindowDelegateImpl;
[email protected]c28853612012-05-31 22:43:44222}
[email protected]262f8bd2012-03-23 19:30:27223
[email protected]efc897f72013-11-01 11:43:07224ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
225 return new MediaDelegateImpl;
226}
227
[email protected]e0cfc7f2014-01-09 20:25:42228ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
229 aura::Window* root,
230 ash::ShelfItemDelegate* item_delegate,
[email protected]eec0971422014-02-03 23:51:27231 ash::ShelfItem* item) {
[email protected]431552c2012-10-23 00:38:33232 return new ContextMenu(root);
233}
234
[email protected]99edff3e2014-01-31 18:20:36235GPUSupport* ShellDelegateImpl::CreateGPUSupport() {
236 // Real GPU support depends on src/content, so just use a stub.
237 return new GPUSupportStub;
238}
239
[email protected]ed95e022013-04-11 04:03:32240base::string16 ShellDelegateImpl::GetProductName() const {
241 return base::string16();
[email protected]5673bf52013-02-01 06:14:24242}
243
afakhrycd2bb98d2015-09-09 09:03:42244gfx::Image ShellDelegateImpl::GetDeprecatedAcceleratorImage() const {
245 return gfx::Image();
246}
247
[email protected]262f8bd2012-03-23 19:30:27248} // namespace shell
249} // namespace ash