[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 1 | // 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] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 7 | #include "ash/accessibility_delegate.h" |
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 8 | #include "ash/default_accessibility_delegate.h" |
[email protected] | a7611df | 2013-09-26 07:57:10 | [diff] [blame] | 9 | #include "ash/default_user_wallpaper_delegate.h" |
[email protected] | 99edff3e | 2014-01-31 18:20:36 | [diff] [blame] | 10 | #include "ash/gpu_support_stub.h" |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 11 | #include "ash/media_delegate.h" |
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 12 | #include "ash/new_window_delegate.h" |
[email protected] | fdf74bf | 2014-04-30 21:24:02 | [diff] [blame] | 13 | #include "ash/session/session_state_delegate.h" |
ben | b91330f | 2015-10-03 22:20:18 | [diff] [blame] | 14 | #include "ash/shell/content/shell_content_state_impl.h" |
[email protected] | 565f32fc0 | 2013-03-05 18:51:48 | [diff] [blame] | 15 | #include "ash/shell/context_menu.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 16 | #include "ash/shell/example_factory.h" |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 17 | #include "ash/shell/shelf_delegate_impl.h" |
[email protected] | b77236f7 | 2012-03-25 03:07:19 | [diff] [blame] | 18 | #include "ash/shell/toplevel_window.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 19 | #include "ash/shell_window_ids.h" |
[email protected] | 9f19d5c | 2013-09-13 17:01:48 | [diff] [blame] | 20 | #include "ash/system/tray/default_system_tray_delegate.h" |
ben | 974286a | 2015-10-10 00:45:12 | [diff] [blame] | 21 | #include "ash/test/test_keyboard_ui.h" |
[email protected] | a41b4e1 | 2013-09-20 04:36:34 | [diff] [blame] | 22 | #include "ash/wm/window_state.h" |
[email protected] | 9e3e635 | 2013-07-17 04:07:51 | [diff] [blame] | 23 | #include "base/message_loop/message_loop.h" |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 24 | #include "base/strings/utf_string_conversions.h" |
[email protected] | d66eac4 | 2014-07-14 23:48:30 | [diff] [blame] | 25 | #include "components/user_manager/user_info_impl.h" |
tapted | 537b88b1 | 2014-09-19 02:48:52 | [diff] [blame] | 26 | #include "ui/app_list/app_list_view_delegate.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 27 | #include "ui/aura/window.h" |
afakhry | cd2bb98d | 2015-09-09 09:03:42 | [diff] [blame] | 28 | #include "ui/gfx/image/image.h" |
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 29 | #include "ui/gfx/image/image_skia.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 30 | |
31 | namespace ash { | ||||
32 | namespace shell { | ||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 33 | namespace { |
34 | |||||
35 | class NewWindowDelegateImpl : public NewWindowDelegate { | ||||
36 | public: | ||||
37 | NewWindowDelegateImpl() {} | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 38 | ~NewWindowDelegateImpl() override {} |
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 39 | |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 40 | // NewWindowDelegate: |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 41 | void NewTab() override {} |
42 | void NewWindow(bool incognito) override { | ||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 43 | 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 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 48 | void OpenFileManager() override {} |
49 | void OpenCrosh() override {} | ||||
cylee | b6ce38f | 2015-01-08 12:25:31 | [diff] [blame] | 50 | void OpenGetHelp() override {} |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 51 | void RestoreTab() override {} |
52 | void ShowKeyboardOverlay() override {} | ||||
53 | void ShowTaskManager() override {} | ||||
54 | void OpenFeedbackPage() override {} | ||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 55 | |
56 | private: | ||||
57 | DISALLOW_COPY_AND_ASSIGN(NewWindowDelegateImpl); | ||||
58 | }; | ||||
59 | |||||
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 60 | class MediaDelegateImpl : public MediaDelegate { |
61 | public: | ||||
62 | MediaDelegateImpl() {} | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 63 | ~MediaDelegateImpl() override {} |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 64 | |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 65 | // MediaDelegate: |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 66 | void HandleMediaNextTrack() override {} |
67 | void HandleMediaPlayPause() override {} | ||||
68 | void HandleMediaPrevTrack() override {} | ||||
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 69 | MediaCaptureState GetMediaCaptureState(UserIndex index) override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 70 | return MEDIA_CAPTURE_VIDEO; |
71 | } | ||||
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 72 | |
73 | private: | ||||
74 | DISALLOW_COPY_AND_ASSIGN(MediaDelegateImpl); | ||||
75 | }; | ||||
76 | |||||
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 77 | class SessionStateDelegateImpl : public SessionStateDelegate { |
78 | public: | ||||
79 | SessionStateDelegateImpl() | ||||
[email protected] | d66eac4 | 2014-07-14 23:48:30 | [diff] [blame] | 80 | : screen_locked_(false), user_info_(new user_manager::UserInfoImpl()) {} |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 81 | |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 82 | ~SessionStateDelegateImpl() override {} |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 83 | |
84 | // SessionStateDelegate: | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 85 | int GetMaximumNumberOfLoggedInUsers() const override { return 3; } |
86 | int NumberOfLoggedInUsers() const override { | ||||
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 87 | // ash_shell has 2 users. |
88 | return 2; | ||||
89 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 90 | 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] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 95 | shell::CreateLockScreen(); |
96 | screen_locked_ = true; | ||||
97 | Shell::GetInstance()->UpdateShelfVisibility(); | ||||
98 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 99 | void UnlockScreen() override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 100 | screen_locked_ = false; |
101 | Shell::GetInstance()->UpdateShelfVisibility(); | ||||
102 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 103 | bool IsUserSessionBlocked() const override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 104 | return !IsActiveUserSessionStarted() || IsScreenLocked(); |
105 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 106 | SessionState GetSessionState() const override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 107 | // Assume that if session is not active we're at login. |
108 | return IsActiveUserSessionStarted() ? SESSION_STATE_ACTIVE | ||||
109 | : SESSION_STATE_LOGIN_PRIMARY; | ||||
110 | } | ||||
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 111 | const user_manager::UserInfo* GetUserInfo(UserIndex index) const override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 112 | return user_info_.get(); |
113 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 114 | bool ShouldShowAvatar(aura::Window* window) const override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 115 | return !user_info_->GetImage().isNull(); |
116 | } | ||||
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 117 | gfx::ImageSkia GetAvatarImageForWindow(aura::Window* window) const override { |
118 | return gfx::ImageSkia(); | ||||
119 | } | ||||
alemate | cdf46dd | 2015-11-12 03:15:16 | [diff] [blame] | 120 | void SwitchActiveUser(const AccountId& account_id) override {} |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 121 | void CycleActiveUser(CycleUser cycle_user) override {} |
122 | bool IsMultiProfileAllowedByPrimaryUserPolicy() const override { | ||||
[email protected] | 815dfac9 | 2014-08-13 16:04:04 | [diff] [blame] | 123 | return true; |
124 | } | ||||
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 125 | void AddSessionStateObserver(ash::SessionStateObserver* observer) override {} |
126 | void RemoveSessionStateObserver( | ||||
mostynb | 10d6b38 | 2014-10-03 16:23:45 | [diff] [blame] | 127 | ash::SessionStateObserver* observer) override {} |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 128 | |
129 | private: | ||||
130 | bool screen_locked_; | ||||
131 | |||||
132 | // A pseudo user info. | ||||
[email protected] | d66eac4 | 2014-07-14 23:48:30 | [diff] [blame] | 133 | scoped_ptr<user_manager::UserInfo> user_info_; |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 134 | |
135 | DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl); | ||||
136 | }; | ||||
137 | |||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 138 | } // namespace |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 139 | |
msw | c3cf79d | 2016-01-05 20:52:06 | [diff] [blame] | 140 | ShellDelegateImpl::ShellDelegateImpl() : shelf_delegate_(nullptr) {} |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 141 | |
msw | c3cf79d | 2016-01-05 20:52:06 | [diff] [blame] | 142 | ShellDelegateImpl::~ShellDelegateImpl() {} |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 143 | |
[email protected] | 5c85d5d | 2012-12-03 14:22:56 | [diff] [blame] | 144 | bool ShellDelegateImpl::IsFirstRunAfterBoot() const { |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 145 | return false; |
146 | } | ||||
147 | |||||
[email protected] | 5ecf612 | 2013-10-31 12:24:09 | [diff] [blame] | 148 | bool ShellDelegateImpl::IsIncognitoAllowed() const { |
149 | return true; | ||||
150 | } | ||||
151 | |||||
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 152 | bool ShellDelegateImpl::IsMultiProfilesEnabled() const { |
153 | return false; | ||||
154 | } | ||||
155 | |||||
[email protected] | 565f32fc0 | 2013-03-05 18:51:48 | [diff] [blame] | 156 | bool ShellDelegateImpl::IsRunningInForcedAppMode() const { |
157 | return false; | ||||
158 | } | ||||
159 | |||||
ben | 894584d | 2015-09-30 23:56:53 | [diff] [blame] | 160 | bool ShellDelegateImpl::CanShowWindowForUser(aura::Window* window) const { |
161 | return true; | ||||
162 | } | ||||
163 | |||||
peletskyi | da0bbb1 | 2015-04-08 17:11:04 | [diff] [blame] | 164 | bool ShellDelegateImpl::IsForceMaximizeOnFirstRun() const { |
165 | return false; | ||||
166 | } | ||||
167 | |||||
[email protected] | dcc99072 | 2013-03-24 16:35:20 | [diff] [blame] | 168 | void ShellDelegateImpl::PreInit() { |
169 | } | ||||
170 | |||||
[email protected] | 050e7718 | 2014-03-25 15:29:16 | [diff] [blame] | 171 | void ShellDelegateImpl::PreShutdown() { |
[email protected] | 3528b7d | 2012-04-18 10:46:36 | [diff] [blame] | 172 | } |
173 | |||||
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 174 | void ShellDelegateImpl::Exit() { |
sadrul | d3af96a | 2016-01-28 16:16:24 | [diff] [blame^] | 175 | base::MessageLoop::current()->QuitWhenIdle(); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 176 | } |
177 | |||||
ben | 974286a | 2015-10-10 00:45:12 | [diff] [blame] | 178 | keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() { |
179 | return new TestKeyboardUI; | ||||
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 180 | } |
181 | |||||
[email protected] | 40db36e | 2014-04-04 14:08:18 | [diff] [blame] | 182 | void ShellDelegateImpl::VirtualKeyboardActivated(bool activated) { |
183 | } | ||||
184 | |||||
185 | void ShellDelegateImpl::AddVirtualKeyboardStateObserver( | ||||
186 | VirtualKeyboardStateObserver* observer) { | ||||
187 | } | ||||
188 | |||||
189 | void ShellDelegateImpl::RemoveVirtualKeyboardStateObserver( | ||||
190 | VirtualKeyboardStateObserver* observer) { | ||||
191 | } | ||||
192 | |||||
tapted | 537b88b1 | 2014-09-19 02:48:52 | [diff] [blame] | 193 | app_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] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 197 | } |
198 | |||||
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 199 | ShelfDelegate* ShellDelegateImpl::CreateShelfDelegate(ShelfModel* model) { |
msw | c3cf79d | 2016-01-05 20:52:06 | [diff] [blame] | 200 | shelf_delegate_ = new ShelfDelegateImpl(); |
[email protected] | 8b57e94 | 2013-12-09 19:39:20 | [diff] [blame] | 201 | return shelf_delegate_; |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 202 | } |
203 | |||||
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 204 | ash::SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() { |
[email protected] | 9f19d5c | 2013-09-13 17:01:48 | [diff] [blame] | 205 | return new DefaultSystemTrayDelegate; |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 206 | } |
207 | |||||
208 | ash::UserWallpaperDelegate* ShellDelegateImpl::CreateUserWallpaperDelegate() { | ||||
[email protected] | a7611df | 2013-09-26 07:57:10 | [diff] [blame] | 209 | return new DefaultUserWallpaperDelegate(); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 210 | } |
[email protected] | 4d7ce435 | 2012-07-13 06:56:06 | [diff] [blame] | 211 | |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 212 | ash::SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 213 | return new SessionStateDelegateImpl; |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 214 | } |
215 | |||||
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 216 | ash::AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 217 | return new DefaultAccessibilityDelegate; |
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 218 | } |
219 | |||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 220 | ash::NewWindowDelegate* ShellDelegateImpl::CreateNewWindowDelegate() { |
221 | return new NewWindowDelegateImpl; | ||||
[email protected] | c2885361 | 2012-05-31 22:43:44 | [diff] [blame] | 222 | } |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 223 | |
[email protected] | efc897f7 | 2013-11-01 11:43:07 | [diff] [blame] | 224 | ash::MediaDelegate* ShellDelegateImpl::CreateMediaDelegate() { |
225 | return new MediaDelegateImpl; | ||||
226 | } | ||||
227 | |||||
[email protected] | e0cfc7f | 2014-01-09 20:25:42 | [diff] [blame] | 228 | ui::MenuModel* ShellDelegateImpl::CreateContextMenu( |
229 | aura::Window* root, | ||||
230 | ash::ShelfItemDelegate* item_delegate, | ||||
[email protected] | eec097142 | 2014-02-03 23:51:27 | [diff] [blame] | 231 | ash::ShelfItem* item) { |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 232 | return new ContextMenu(root); |
233 | } | ||||
234 | |||||
[email protected] | 99edff3e | 2014-01-31 18:20:36 | [diff] [blame] | 235 | GPUSupport* ShellDelegateImpl::CreateGPUSupport() { |
236 | // Real GPU support depends on src/content, so just use a stub. | ||||
237 | return new GPUSupportStub; | ||||
238 | } | ||||
239 | |||||
[email protected] | ed95e02 | 2013-04-11 04:03:32 | [diff] [blame] | 240 | base::string16 ShellDelegateImpl::GetProductName() const { |
241 | return base::string16(); | ||||
[email protected] | 5673bf5 | 2013-02-01 06:14:24 | [diff] [blame] | 242 | } |
243 | |||||
afakhry | cd2bb98d | 2015-09-09 09:03:42 | [diff] [blame] | 244 | gfx::Image ShellDelegateImpl::GetDeprecatedAcceleratorImage() const { |
245 | return gfx::Image(); | ||||
246 | } | ||||
247 | |||||
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 248 | } // namespace shell |
249 | } // namespace ash |