[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 | |||||
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 7 | #include "ash/accessibility_delegate.h" |
8 | #include "ash/default_accessibility_delegate.h" | ||||
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 9 | #include "ash/default_wallpaper_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 10 | #include "ash/gpu_support_stub.h" |
11 | #include "ash/palette_delegate.h" | ||||
jamescook | 8800b823 | 2016-10-19 12:46:27 | [diff] [blame] | 12 | #include "ash/public/cpp/shell_window_ids.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 13 | #include "ash/session/session_state_delegate.h" |
jamescook | fd4ba1d | 2016-06-10 04:38:17 | [diff] [blame] | 14 | #include "ash/shell.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] | b77236f7 | 2012-03-25 03:07:19 | [diff] [blame] | 17 | #include "ash/shell/toplevel_window.h" |
ben | 974286a | 2015-10-10 00:45:12 | [diff] [blame] | 18 | #include "ash/test/test_keyboard_ui.h" |
jamescook | 1a147372 | 2017-04-19 00:29:49 | [diff] [blame] | 19 | #include "ash/test/test_system_tray_delegate.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 20 | #include "ash/wm/window_state.h" |
mfomitchev | 493ed60 | 2016-04-09 00:48:39 | [diff] [blame] | 21 | #include "base/memory/ptr_util.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" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 25 | #include "ui/aura/window.h" |
afakhry | cd2bb98d | 2015-09-09 09:03:42 | [diff] [blame] | 26 | #include "ui/gfx/image/image.h" |
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 27 | #include "ui/gfx/image/image_skia.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 28 | |
29 | namespace ash { | ||||
30 | namespace shell { | ||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 31 | namespace { |
32 | |||||
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 33 | class PaletteDelegateImpl : public PaletteDelegate { |
34 | public: | ||||
jdufault | 77dfb185 | 2016-08-22 18:46:30 | [diff] [blame] | 35 | PaletteDelegateImpl() {} |
36 | ~PaletteDelegateImpl() override {} | ||||
37 | |||||
38 | // PaletteDelegate: | ||||
jdufault | fbe81f6 | 2016-08-26 16:51:06 | [diff] [blame] | 39 | std::unique_ptr<EnableListenerSubscription> AddPaletteEnableListener( |
40 | const EnableListener& on_state_changed) override { | ||||
41 | on_state_changed.Run(false); | ||||
42 | return nullptr; | ||||
43 | } | ||||
jdufault | 77dfb185 | 2016-08-22 18:46:30 | [diff] [blame] | 44 | void CreateNote() override {} |
45 | bool HasNoteApp() override { return false; } | ||||
jdufault | d57fbda | 2016-08-26 00:18:01 | [diff] [blame] | 46 | bool ShouldAutoOpenPalette() override { return false; } |
jdufault | a0ff8862 | 2016-08-26 22:22:13 | [diff] [blame] | 47 | bool ShouldShowPalette() override { return false; } |
jdufault | e18aeb2 | 2016-08-24 00:46:35 | [diff] [blame] | 48 | void TakeScreenshot() override {} |
jdufault | e4546d22 | 2016-09-02 20:27:17 | [diff] [blame] | 49 | void TakePartialScreenshot(const base::Closure& done) override { |
50 | if (done) | ||||
51 | done.Run(); | ||||
52 | } | ||||
53 | void CancelPartialScreenshot() override {} | ||||
kaznacheev | 466e48c8 | 2017-04-20 22:35:24 | [diff] [blame^] | 54 | bool IsMetalayerSupported() override { return false; } |
55 | void ShowMetalayer(const base::Closure& closed) override {} | ||||
56 | void HideMetalayer() override {} | ||||
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 57 | |
58 | private: | ||||
59 | DISALLOW_COPY_AND_ASSIGN(PaletteDelegateImpl); | ||||
60 | }; | ||||
61 | |||||
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 62 | class SessionStateDelegateImpl : public SessionStateDelegate { |
63 | public: | ||||
xiyuan | f1ff14d | 2017-03-20 20:28:14 | [diff] [blame] | 64 | SessionStateDelegateImpl() : user_info_(new user_manager::UserInfoImpl()) {} |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 65 | |
dcheng | f596351 | 2014-10-28 01:14:13 | [diff] [blame] | 66 | ~SessionStateDelegateImpl() override {} |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 67 | |
68 | // SessionStateDelegate: | ||||
jamescook | 26db34d5 | 2016-06-07 18:25:38 | [diff] [blame] | 69 | bool ShouldShowAvatar(WmWindow* window) const override { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 70 | return !user_info_->GetImage().isNull(); |
71 | } | ||||
jamescook | 26db34d5 | 2016-06-07 18:25:38 | [diff] [blame] | 72 | gfx::ImageSkia GetAvatarImageForWindow(WmWindow* window) const override { |
ben | 9307244 | 2015-10-05 19:14:32 | [diff] [blame] | 73 | return gfx::ImageSkia(); |
74 | } | ||||
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 75 | |
76 | private: | ||||
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 77 | // A pseudo user info. |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 78 | std::unique_ptr<user_manager::UserInfo> user_info_; |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 79 | |
80 | DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateImpl); | ||||
81 | }; | ||||
82 | |||||
[email protected] | 47686c4 | 2013-10-25 01:49:17 | [diff] [blame] | 83 | } // namespace |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 84 | |
msw | fb83464 | 2017-01-04 22:50:05 | [diff] [blame] | 85 | ShellDelegateImpl::ShellDelegateImpl() {} |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 86 | |
msw | c3cf79d | 2016-01-05 20:52:06 | [diff] [blame] | 87 | ShellDelegateImpl::~ShellDelegateImpl() {} |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 88 | |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 89 | ::service_manager::Connector* ShellDelegateImpl::GetShellConnector() const { |
jamescook | 2a6b869 | 2016-10-04 02:41:29 | [diff] [blame] | 90 | return nullptr; |
91 | } | ||||
92 | |||||
[email protected] | 5ecf612 | 2013-10-31 12:24:09 | [diff] [blame] | 93 | bool ShellDelegateImpl::IsIncognitoAllowed() const { |
94 | return true; | ||||
95 | } | ||||
96 | |||||
[email protected] | e718e6f | 2013-04-15 16:01:59 | [diff] [blame] | 97 | bool ShellDelegateImpl::IsMultiProfilesEnabled() const { |
98 | return false; | ||||
99 | } | ||||
100 | |||||
[email protected] | 565f32fc0 | 2013-03-05 18:51:48 | [diff] [blame] | 101 | bool ShellDelegateImpl::IsRunningInForcedAppMode() const { |
102 | return false; | ||||
103 | } | ||||
104 | |||||
jamescook | fd4ba1d | 2016-06-10 04:38:17 | [diff] [blame] | 105 | bool ShellDelegateImpl::CanShowWindowForUser(WmWindow* window) const { |
ben | 894584d | 2015-09-30 23:56:53 | [diff] [blame] | 106 | return true; |
107 | } | ||||
108 | |||||
peletskyi | da0bbb1 | 2015-04-08 17:11:04 | [diff] [blame] | 109 | bool ShellDelegateImpl::IsForceMaximizeOnFirstRun() const { |
110 | return false; | ||||
111 | } | ||||
112 | |||||
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 113 | void ShellDelegateImpl::PreInit() {} |
[email protected] | dcc99072 | 2013-03-24 16:35:20 | [diff] [blame] | 114 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 115 | void ShellDelegateImpl::PreShutdown() {} |
[email protected] | 3528b7d | 2012-04-18 10:46:36 | [diff] [blame] | 116 | |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 117 | void ShellDelegateImpl::Exit() { |
sadrul | d3af96a | 2016-01-28 16:16:24 | [diff] [blame] | 118 | base::MessageLoop::current()->QuitWhenIdle(); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 119 | } |
120 | |||||
ben | 974286a | 2015-10-10 00:45:12 | [diff] [blame] | 121 | keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() { |
122 | return new TestKeyboardUI; | ||||
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 123 | } |
124 | |||||
kenobi | b7af62b | 2016-07-29 21:40:16 | [diff] [blame] | 125 | void ShellDelegateImpl::OpenUrlFromArc(const GURL& url) {} |
yusukes | 0b08bdbb | 2016-03-30 21:39:54 | [diff] [blame] | 126 | |
msw | 5138f3d | 2017-04-20 00:22:07 | [diff] [blame] | 127 | void ShellDelegateImpl::ShelfInit() {} |
128 | |||||
129 | void ShellDelegateImpl::ShelfShutdown() {} | ||||
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 130 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 131 | SystemTrayDelegate* ShellDelegateImpl::CreateSystemTrayDelegate() { |
jamescook | 1a147372 | 2017-04-19 00:29:49 | [diff] [blame] | 132 | return new test::TestSystemTrayDelegate; |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 133 | } |
134 | |||||
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 135 | std::unique_ptr<WallpaperDelegate> |
136 | ShellDelegateImpl::CreateWallpaperDelegate() { | ||||
137 | return base::MakeUnique<DefaultWallpaperDelegate>(); | ||||
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 138 | } |
[email protected] | 4d7ce435 | 2012-07-13 06:56:06 | [diff] [blame] | 139 | |
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 140 | SessionStateDelegate* ShellDelegateImpl::CreateSessionStateDelegate() { |
[email protected] | 7009d9b | 2014-05-03 21:38:36 | [diff] [blame] | 141 | return new SessionStateDelegateImpl; |
[email protected] | fcb123d | 2013-04-17 15:58:49 | [diff] [blame] | 142 | } |
143 | |||||
msw | 0e91d93 | 2016-08-25 22:34:09 | [diff] [blame] | 144 | AccessibilityDelegate* ShellDelegateImpl::CreateAccessibilityDelegate() { |
[email protected] | 093b8d64 | 2014-04-03 20:59:28 | [diff] [blame] | 145 | return new DefaultAccessibilityDelegate; |
[email protected] | f3ab6eff5 | 2013-10-24 03:29:38 | [diff] [blame] | 146 | } |
147 | |||||
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 148 | std::unique_ptr<PaletteDelegate> ShellDelegateImpl::CreatePaletteDelegate() { |
ricea | c9462d4 | 2016-08-22 02:40:28 | [diff] [blame] | 149 | return base::MakeUnique<PaletteDelegateImpl>(); |
jdufault | 0f4fa6e | 2016-08-05 19:13:59 | [diff] [blame] | 150 | } |
151 | |||||
jamescook | da53c14 | 2016-06-08 23:38:56 | [diff] [blame] | 152 | ui::MenuModel* ShellDelegateImpl::CreateContextMenu(WmShelf* wm_shelf, |
153 | const ShelfItem* item) { | ||||
154 | return new ContextMenu(wm_shelf); | ||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 155 | } |
156 | |||||
[email protected] | 99edff3e | 2014-01-31 18:20:36 | [diff] [blame] | 157 | GPUSupport* ShellDelegateImpl::CreateGPUSupport() { |
158 | // Real GPU support depends on src/content, so just use a stub. | ||||
159 | return new GPUSupportStub; | ||||
160 | } | ||||
161 | |||||
[email protected] | ed95e02 | 2013-04-11 04:03:32 | [diff] [blame] | 162 | base::string16 ShellDelegateImpl::GetProductName() const { |
163 | return base::string16(); | ||||
[email protected] | 5673bf5 | 2013-02-01 06:14:24 | [diff] [blame] | 164 | } |
165 | |||||
afakhry | cd2bb98d | 2015-09-09 09:03:42 | [diff] [blame] | 166 | gfx::Image ShellDelegateImpl::GetDeprecatedAcceleratorImage() const { |
167 | return gfx::Image(); | ||||
168 | } | ||||
169 | |||||
warx | 4c8baedb | 2016-12-03 22:38:50 | [diff] [blame] | 170 | bool ShellDelegateImpl::IsTouchscreenEnabledInPrefs( |
171 | bool use_local_state) const { | ||||
172 | return true; | ||||
173 | } | ||||
174 | |||||
175 | void ShellDelegateImpl::SetTouchscreenEnabledInPrefs(bool enabled, | ||||
176 | bool use_local_state) {} | ||||
177 | |||||
178 | void ShellDelegateImpl::UpdateTouchscreenStatusFromPrefs() {} | ||||
179 | |||||
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 180 | } // namespace shell |
181 | } // namespace ash |