blob: 6fd7660fb96ff41af4fcde704d7562eadb02421a [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"
[email protected]565f32fc02013-03-05 18:51:4814#include "ash/shell/context_menu.h"
[email protected]262f8bd2012-03-23 19:30:2715#include "ash/shell/example_factory.h"
[email protected]8b57e942013-12-09 19:39:2016#include "ash/shell/shelf_delegate_impl.h"
[email protected]b77236f72012-03-25 03:07:1917#include "ash/shell/toplevel_window.h"
[email protected]262f8bd2012-03-23 19:30:2718#include "ash/shell_window_ids.h"
[email protected]9f19d5c2013-09-13 17:01:4819#include "ash/system/tray/default_system_tray_delegate.h"
ben974286a2015-10-10 00:45:1220#include "ash/test/test_keyboard_ui.h"
[email protected]a41b4e12013-09-20 04:36:3421#include "ash/wm/window_state.h"
[email protected]9e3e6352013-07-17 04:07:5122#include "base/message_loop/message_loop.h"
[email protected]7009d9b2014-05-03 21:38:3623#include "base/strings/utf_string_conversions.h"
[email protected]d66eac42014-07-14 23:48:3024#include "components/user_manager/user_info_impl.h"
tapted537b88b12014-09-19 02:48:5225#include "ui/app_list/app_list_view_delegate.h"
[email protected]262f8bd2012-03-23 19:30:2726#include "ui/aura/window.h"
afakhrycd2bb98d2015-09-09 09:03:4227#include "ui/gfx/image/image.h"
ben93072442015-10-05 19:14:3228#include "ui/gfx/image/image_skia.h"
[email protected]262f8bd2012-03-23 19:30:2729
30namespace ash {
31namespace shell {
[email protected]47686c42013-10-25 01:49:1732namespace {
33
34class NewWindowDelegateImpl : public NewWindowDelegate {
35 public:
36 NewWindowDelegateImpl() {}
dchengf5963512014-10-28 01:14:1337 ~NewWindowDelegateImpl() override {}
[email protected]47686c42013-10-25 01:49:1738
[email protected]7009d9b2014-05-03 21:38:3639 // NewWindowDelegate:
dchengf5963512014-10-28 01:14:1340 void NewTab() override {}
41 void NewWindow(bool incognito) override {
[email protected]47686c42013-10-25 01:49:1742 ash::shell::ToplevelWindow::CreateParams create_params;
43 create_params.can_resize = true;
44 create_params.can_maximize = true;
45 ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
46 }
dchengf5963512014-10-28 01:14:1347 void OpenFileManager() override {}
48 void OpenCrosh() override {}
cyleeb6ce38f2015-01-08 12:25:3149 void OpenGetHelp() override {}
dchengf5963512014-10-28 01:14:1350 void RestoreTab() override {}
51 void ShowKeyboardOverlay() override {}
52 void ShowTaskManager() override {}
53 void OpenFeedbackPage() override {}
[email protected]47686c42013-10-25 01:49:1754
55 private:
56 DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl);
57};
58
[email protected]efc897f72013-11-01 11:43:0759class MediaDelegateImpl : public MediaDelegate {
60 public:
61 MediaDelegateImpl() {}
dchengf5963512014-10-28 01:14:1362 ~MediaDelegateImpl() override {}
[email protected]efc897f72013-11-01 11:43:0763
[email protected]7009d9b2014-05-03 21:38:3664 // MediaDelegate:
dchengf5963512014-10-28 01:14:1365 void HandleMediaNextTrack() override {}
66 void HandleMediaPlayPause() override {}
67 void HandleMediaPrevTrack() override {}
ben93072442015-10-05 19:14:3268 MediaCaptureState GetMediaCaptureState(UserIndex index) override {
[email protected]7009d9b2014-05-03 21:38:3669 return MEDIA_CAPTURE_VIDEO;
70 }
[email protected]efc897f72013-11-01 11:43:0771
72 private:
73 DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl);
74};
75
[email protected]7009d9b2014-05-03 21:38:3676class SessionStateDelegateImpl : public SessionStateDelegate {
77 public:
78 SessionStateDelegateImpl()
[email protected]d66eac42014-07-14 23:48:3079 : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {}
[email protected]7009d9b2014-05-03 21:38:3680
dchengf5963512014-10-28 01:14:1381 ~SessionStateDelegateImpl() override {}
[email protected]7009d9b2014-05-03 21:38:3682
83 // SessionStateDelegate:
dchengf5963512014-10-28 01:14:1384 int GetMaximumNumberOfLoggedInUsers() const override { return 3; }
85 int NumberOfLoggedInUsers() const override {
[email protected]7009d9b2014-05-03 21:38:3686 // ash_shell has 2 users.
87 return 2;
88 }
dchengf5963512014-10-28 01:14:1389 bool IsActiveUserSessionStarted() const override { return true; }
90 bool CanLockScreen() const override { return true; }
91 bool IsScreenLocked() const override { return screen_locked_; }
92 bool ShouldLockScreenBeforeSuspending() const override { return false; }
93 void LockScreen() override {
[email protected]7009d9b2014-05-03 21:38:3694 shell::CreateLockScreen();
95 screen_locked_ = true;
96 Shell::GetInstance()->UpdateShelfVisibility();
97 }
dchengf5963512014-10-28 01:14:1398 void UnlockScreen() override {
[email protected]7009d9b2014-05-03 21:38:3699 screen_locked_ = false;
100 Shell::GetInstance()->UpdateShelfVisibility();
101 }
dchengf5963512014-10-28 01:14:13102 bool IsUserSessionBlocked() const override {
[email protected]7009d9b2014-05-03 21:38:36103 return !IsActiveUserSessionStarted() || IsScreenLocked();
104 }
dchengf5963512014-10-28 01:14:13105 SessionState GetSessionState() const override {
[email protected]7009d9b2014-05-03 21:38:36106 // Assume that if session is not active we're at login.
107 return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE
108 : SESSION_STATE_LOGIN_PRIMARY;
109 }
ben93072442015-10-05 19:14:32110 const user_manager::UserInfo* GetUserInfo(UserIndex index) const override {
[email protected]7009d9b2014-05-03 21:38:36111 return user_info_.get();
112 }
dchengf5963512014-10-28 01:14:13113 bool ShouldShowAvatar(aura::Window* window) const override {
[email protected]7009d9b2014-05-03 21:38:36114 return !user_info_->GetImage().isNull();
115 }
ben93072442015-10-05 19:14:32116 gfx::ImageSkia GetAvatarImageForWindow(aura::Window* window) const override {
117 return gfx::ImageSkia();
118 }
alematecdf46dd2015-11-12 03:15:16119 void SwitchActiveUser(const AccountId& account_id) override {}
dchengf5963512014-10-28 01:14:13120 void CycleActiveUser(CycleUser cycle_user) override {}
121 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override {
[email protected]815dfac92014-08-13 16:04:04122 return true;
123 }
dchengf5963512014-10-28 01:14:13124 void AddSessionStateObserver(ash::SessionStateObserver* observer) override {}
125 void RemoveSessionStateObserver(
mostynb10d6b382014-10-03 16:23:45126 ash::SessionStateObserver* observer) override {}
[email protected]7009d9b2014-05-03 21:38:36127
128 private:
129 bool screen_locked_;
130
131 // A pseudo user info.
[email protected]d66eac42014-07-14 23:48:30132 scoped_ptr<user_manager::UserInfo> user_info_;
[email protected]7009d9b2014-05-03 21:38:36133
134 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl);
135};
136
[email protected]47686c42013-10-25 01:49:17137} // namespace
[email protected]262f8bd2012-03-23 19:30:27138
mswc3cf79d2016-01-05 20:52:06139ShellDelegateImpl::ShellDelegateImpl() : shelf_delegate_(nullptr) {}
[email protected]262f8bd2012-03-23 19:30:27140
mswc3cf79d2016-01-05 20:52:06141ShellDelegateImpl::~ShellDelegateImpl() {}
[email protected]262f8bd2012-03-23 19:30:27142
[email protected]5c85d5d2012-12-03 14:22:56143bool ShellDelegateImpl::IsFirstRunAfterBoot() const {
[email protected]697f04c2012-10-03 01:15:10144 return false;
145}
146
[email protected]5ecf6122013-10-31 12:24:09147bool ShellDelegateImpl::IsIncognitoAllowed() const {
148 return true;
149}
150
[email protected]e718e6f2013-04-15 16:01:59151bool ShellDelegateImpl::IsMultiProfilesEnabled() const {
152 return false;
153}
154
[email protected]565f32fc02013-03-05 18:51:48155bool ShellDelegateImpl::IsRunningInForcedAppMode() const {
156 return false;
157}
158
ben894584d2015-09-30 23:56:53159bool ShellDelegateImpl::CanShowWindowForUser(aura::Window* window) const {
160 return true;
161}
162
peletskyida0bbb12015-04-08 17:11:04163bool ShellDelegateImpl::IsForceMaximizeOnFirstRun() const {
164 return false;
165}
166
[email protected]dcc990722013-03-24 16:35:20167void ShellDelegateImpl::PreInit() {
168}
169
[email protected]050e77182014-03-25 15:29:16170void ShellDelegateImpl::PreShutdown() {
[email protected]3528b7d2012-04-18 10:46:36171}
172
[email protected]262f8bd2012-03-23 19:30:27173void ShellDelegateImpl::Exit() {
sadruld3af96a2016-01-28 16:16:24174 base::MessageLoop::current()->QuitWhenIdle();
[email protected]262f8bd2012-03-23 19:30:27175}
176
ben974286a2015-10-10 00:45:12177keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() {
178 return new TestKeyboardUI;
[email protected]86459e2c2013-04-10 13:39:24179}
180
[email protected]40db36e2014-04-04 14:08:18181void ShellDelegateImpl::VirtualKeyboardActivated(bool activated) {
182}
183
184void ShellDelegateImpl::AddVirtualKeyboardStateObserver(
185 VirtualKeyboardStateObserver* observer) {
186}
187
188void ShellDelegateImpl::RemoveVirtualKeyboardStateObserver(
189 VirtualKeyboardStateObserver* observer) {
190}
191
yusukes0b08bdbb2016-03-30 21:39:54192void ShellDelegateImpl::OpenUrl(const GURL& url) {}
193
tapted537b88b12014-09-19 02:48:52194app_list::AppListViewDelegate* ShellDelegateImpl::GetAppListViewDelegate() {
195 if (!app_list_view_delegate_)
196 app_list_view_delegate_.reset(ash::shell::CreateAppListViewDelegate());
197 return app_list_view_delegate_.get();
[email protected]262f8bd2012-03-23 19:30:27198}
199
[email protected]8b57e942013-12-09 19:39:20200ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) {
mswc3cf79d2016-01-05 20:52:06201 shelf_delegate_ = new ShelfDelegateImpl();
[email protected]8b57e942013-12-09 19:39:20202 return shelf_delegate_;
[email protected]262f8bd2012-03-23 19:30:27203}
204
[email protected]51ed5992012-11-07 10:14:39205ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() {
[email protected]9f19d5c2013-09-13 17:01:48206 return new DefaultSystemTrayDelegate;
[email protected]262f8bd2012-03-23 19:30:27207}
208
209ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() {
[email protected]a7611df2013-09-26 07:57:10210 return new DefaultUserWallpaperDelegate();
[email protected]262f8bd2012-03-23 19:30:27211}
[email protected]4d7ce4352012-07-13 06:56:06212
[email protected]fcb123d2013-04-17 15:58:49213ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() {
[email protected]7009d9b2014-05-03 21:38:36214 return new SessionStateDelegateImpl;
[email protected]fcb123d2013-04-17 15:58:49215}
216
[email protected]f3ab6eff52013-10-24 03:29:38217ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() {
[email protected]093b8d642014-04-03 20:59:28218 return new DefaultAccessibilityDelegate;
[email protected]f3ab6eff52013-10-24 03:29:38219}
220
[email protected]47686c42013-10-25 01:49:17221ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() {
222 return new NewWindowDelegateImpl;
[email protected]c28853612012-05-31 22:43:44223}
[email protected]262f8bd2012-03-23 19:30:27224
[email protected]efc897f72013-11-01 11:43:07225ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() {
226 return new MediaDelegateImpl;
227}
228
[email protected]e0cfc7f2014-01-09 20:25:42229ui::MenuModel* ShellDelegateImpl::CreateContextMenu(
msw953caf1f2016-03-18 00:33:29230 ash::Shelf* shelf,
msw141c6b22016-03-04 00:55:30231 const ash::ShelfItem* item) {
msw953caf1f2016-03-18 00:33:29232 return new ContextMenu(shelf);
[email protected]431552c2012-10-23 00:38:33233}
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