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