OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/mus/sysui_application.h" | 5 #include "ash/mus/sysui_application.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/host/ash_window_tree_host_init_params.h" | 8 #include "ash/host/ash_window_tree_host_init_params.h" |
9 #include "ash/host/ash_window_tree_host_platform.h" | 9 #include "ash/host/ash_window_tree_host_platform.h" |
10 #include "ash/mus/keyboard_ui_mus.h" | |
11 #include "ash/mus/mojo_shell.h" | |
10 #include "ash/mus/shell_delegate_mus.h" | 12 #include "ash/mus/shell_delegate_mus.h" |
11 #include "ash/mus/stub_context_factory.h" | 13 #include "ash/mus/stub_context_factory.h" |
12 #include "ash/root_window_settings.h" | 14 #include "ash/root_window_settings.h" |
13 #include "ash/shell.h" | 15 #include "ash/shell.h" |
14 #include "ash/shell_init_params.h" | 16 #include "ash/shell_init_params.h" |
15 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
18 #include "base/bind.h" | |
16 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
17 #include "components/mus/public/cpp/property_type_converters.h" | 20 #include "components/mus/public/cpp/property_type_converters.h" |
18 #include "mash/wm/public/interfaces/container.mojom.h" | 21 #include "mash/wm/public/interfaces/container.mojom.h" |
19 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
20 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/base/ui_base_paths.h" | 24 #include "ui/base/ui_base_paths.h" |
22 #include "ui/message_center/message_center.h" | 25 #include "ui/message_center/message_center.h" |
23 #include "ui/platform_window/stub/stub_window.h" | 26 #include "ui/platform_window/stub/stub_window.h" |
24 #include "ui/views/mus/aura_init.h" | 27 #include "ui/views/mus/aura_init.h" |
25 #include "ui/views/mus/native_widget_mus.h" | 28 #include "ui/views/mus/native_widget_mus.h" |
26 #include "ui/views/mus/window_manager_connection.h" | 29 #include "ui/views/mus/window_manager_connection.h" |
27 #include "ui/views/views_delegate.h" | 30 #include "ui/views/views_delegate.h" |
28 | 31 |
29 using views::ViewsDelegate; | 32 using views::ViewsDelegate; |
30 | 33 |
31 namespace ash { | 34 namespace ash { |
32 namespace sysui { | 35 namespace sysui { |
33 | 36 |
34 namespace { | 37 namespace { |
35 | 38 |
39 mojo::Shell* mojo_shell = nullptr; | |
40 | |
36 // Tries to determine the corresponding container in mash from the ash container | 41 // Tries to determine the corresponding container in mash from the ash container |
37 // for the widget. | 42 // for the widget. |
38 mash::wm::mojom::Container GetContainerId(aura::Window* container) { | 43 mash::wm::mojom::Container GetContainerId(aura::Window* container) { |
39 DCHECK(container); | 44 DCHECK(container); |
40 int id = container->id(); | 45 int id = container->id(); |
41 if (id == kShellWindowId_DesktopBackgroundContainer) | 46 if (id == kShellWindowId_DesktopBackgroundContainer) |
42 return mash::wm::mojom::Container::USER_BACKGROUND; | 47 return mash::wm::mojom::Container::USER_BACKGROUND; |
43 if (id == kShellWindowId_ShelfContainer) | 48 if (id == kShellWindowId_ShelfContainer) |
44 return mash::wm::mojom::Container::USER_SHELF; | 49 return mash::wm::mojom::Container::USER_SHELF; |
45 return mash::wm::mojom::Container::COUNT; | 50 return mash::wm::mojom::Container::COUNT; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 ui::RegisterPathProvider(); | 127 ui::RegisterPathProvider(); |
123 ui::ResourceBundle::InitSharedInstanceWithLocale( | 128 ui::ResourceBundle::InitSharedInstanceWithLocale( |
124 "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 129 "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
125 } | 130 } |
126 | 131 |
127 ~AshInit() { worker_pool_->Shutdown(); } | 132 ~AshInit() { worker_pool_->Shutdown(); } |
128 | 133 |
129 aura::Window* root() { return ash::Shell::GetPrimaryRootWindow(); } | 134 aura::Window* root() { return ash::Shell::GetPrimaryRootWindow(); } |
130 | 135 |
131 void Initialize(mojo::Shell* shell) { | 136 void Initialize(mojo::Shell* shell) { |
137 sysui::mojo_shell = shell; | |
138 | |
132 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); | 139 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); |
133 views::WindowManagerConnection::Create(shell); | 140 views::WindowManagerConnection::Create(shell); |
134 | 141 |
135 gfx::Screen* screen = gfx::Screen::GetScreen(); | 142 gfx::Screen* screen = gfx::Screen::GetScreen(); |
136 DCHECK(screen); | 143 DCHECK(screen); |
137 gfx::Size size = screen->GetPrimaryDisplay().bounds().size(); | 144 gfx::Size size = screen->GetPrimaryDisplay().bounds().size(); |
138 | 145 |
139 // Uninstall the ScreenMus installed by WindowManagerConnection, so that ash | 146 // Uninstall the ScreenMus installed by WindowManagerConnection, so that ash |
140 // installs and uses the ScreenAsh. This can be removed once ash learns to | 147 // installs and uses the ScreenAsh. This can be removed once ash learns to |
141 // talk to mus for managing displays. | 148 // talk to mus for managing displays. |
142 gfx::Screen::SetScreenInstance(nullptr); | 149 gfx::Screen::SetScreenInstance(nullptr); |
143 | 150 |
144 // Install some hook so that the WindowTreeHostMus created for widgets can | 151 // Install some hook so that the WindowTreeHostMus created for widgets can |
145 // be hooked up correctly. | 152 // be hooked up correctly. |
146 native_widget_factory_.reset(new NativeWidgetFactory()); | 153 native_widget_factory_.reset(new NativeWidgetFactory()); |
147 | 154 |
148 ash::AshWindowTreeHost::SetFactory(base::Bind(&CreateWindowTreeHostMus)); | 155 ash::AshWindowTreeHost::SetFactory(base::Bind(&CreateWindowTreeHostMus)); |
149 ash_delegate_ = new ShellDelegateMus; | 156 ash_delegate_ = new ShellDelegateMus; |
150 message_center::MessageCenter::Initialize(); | 157 message_center::MessageCenter::Initialize(); |
151 | 158 |
152 ash::ShellInitParams init_params; | 159 ash::ShellInitParams init_params; |
153 init_params.delegate = ash_delegate_; | 160 init_params.delegate = ash_delegate_; |
154 init_params.context_factory = new StubContextFactory; | 161 init_params.context_factory = new StubContextFactory; |
155 init_params.blocking_pool = worker_pool_.get(); | 162 init_params.blocking_pool = worker_pool_.get(); |
163 init_params.in_mus = true; | |
164 init_params.keyboard_factory = base::Bind(&KeyboardUIMus::Create); | |
sadrul
2016/02/11 17:42:11
Send |shell| with Bind instead of GetMojoShell()?
sky
2016/02/11 18:00:24
Done.
| |
156 ash::Shell::CreateInstance(init_params); | 165 ash::Shell::CreateInstance(init_params); |
157 ash::Shell::GetInstance()->CreateShelf(); | 166 ash::Shell::GetInstance()->CreateShelf(); |
158 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 167 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
159 ash::user::LOGGED_IN_USER); | 168 ash::user::LOGGED_IN_USER); |
160 // Reset the context factory, so that NativeWidgetMus installs the context | 169 // Reset the context factory, so that NativeWidgetMus installs the context |
161 // factory for the views::Widgets correctly. | 170 // factory for the views::Widgets correctly. |
162 aura::Env::GetInstance()->set_context_factory(nullptr); | 171 aura::Env::GetInstance()->set_context_factory(nullptr); |
163 | 172 |
164 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 173 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
165 SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); | 174 SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 SysUIApplication::~SysUIApplication() {} | 206 SysUIApplication::~SysUIApplication() {} |
198 | 207 |
199 void SysUIApplication::Initialize(mojo::Shell* shell, | 208 void SysUIApplication::Initialize(mojo::Shell* shell, |
200 const std::string& url, | 209 const std::string& url, |
201 uint32_t id) { | 210 uint32_t id) { |
202 ash_init_.reset(new AshInit()); | 211 ash_init_.reset(new AshInit()); |
203 ash_init_->Initialize(shell); | 212 ash_init_->Initialize(shell); |
204 } | 213 } |
205 | 214 |
206 } // namespace sysui | 215 } // namespace sysui |
216 | |
217 mojo::Shell* GetMojoShell() { | |
218 return sysui::mojo_shell; | |
219 } | |
220 | |
207 } // namespace ash | 221 } // namespace ash |
OLD | NEW |