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