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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/display/display_manager.h" |
13 #include "ash/host/ash_window_tree_host_init_params.h" | 13 #include "ash/host/ash_window_tree_host_init_params.h" |
14 #include "ash/host/ash_window_tree_host_platform.h" | 14 #include "ash/host/ash_window_tree_host_platform.h" |
15 #include "ash/material_design/material_design_controller.h" | 15 #include "ash/material_design/material_design_controller.h" |
16 #include "ash/mus/app_list_presenter_mus.h" | 16 #include "ash/mus/app_list_presenter_mus.h" |
17 #include "ash/mus/keyboard_ui_mus.h" | 17 #include "ash/mus/keyboard_ui_mus.h" |
18 #include "ash/mus/shelf_delegate_mus.h" | 18 #include "ash/mus/shelf_delegate_mus.h" |
19 #include "ash/mus/shell_delegate_mus.h" | 19 #include "ash/mus/shell_delegate_mus.h" |
20 #include "ash/mus/stub_context_factory.h" | 20 #include "ash/mus/stub_context_factory.h" |
21 #include "ash/mus/user_wallpaper_delegate_mus.h" | |
21 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
22 #include "ash/shell.h" | 23 #include "ash/shell.h" |
23 #include "ash/shell_init_params.h" | 24 #include "ash/shell_init_params.h" |
24 #include "ash/shell_window_ids.h" | 25 #include "ash/shell_window_ids.h" |
25 #include "base/bind.h" | 26 #include "base/bind.h" |
26 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
27 #include "base/path_service.h" | 28 #include "base/path_service.h" |
28 #include "base/threading/sequenced_worker_pool.h" | 29 #include "base/threading/sequenced_worker_pool.h" |
29 #include "components/mus/public/cpp/property_type_converters.h" | 30 #include "components/mus/public/cpp/property_type_converters.h" |
30 #include "mash/wm/public/interfaces/ash_window_type.mojom.h" | 31 #include "mash/wm/public/interfaces/ash_window_type.mojom.h" |
31 #include "mash/wm/public/interfaces/container.mojom.h" | 32 #include "mash/wm/public/interfaces/container.mojom.h" |
32 #include "services/catalog/public/cpp/resource_loader.h" | 33 #include "services/catalog/public/cpp/resource_loader.h" |
33 #include "services/shell/public/cpp/connector.h" | 34 #include "services/shell/public/cpp/connector.h" |
34 #include "ui/aura/env.h" | 35 #include "ui/aura/env.h" |
35 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/base/ui_base_paths.h" | 37 #include "ui/base/ui_base_paths.h" |
38 #include "ui/display/display.h" | |
39 #include "ui/display/screen.h" | |
37 #include "ui/message_center/message_center.h" | 40 #include "ui/message_center/message_center.h" |
38 #include "ui/platform_window/stub/stub_window.h" | 41 #include "ui/platform_window/stub/stub_window.h" |
39 #include "ui/views/mus/aura_init.h" | 42 #include "ui/views/mus/aura_init.h" |
40 #include "ui/views/mus/native_widget_mus.h" | 43 #include "ui/views/mus/native_widget_mus.h" |
41 #include "ui/views/mus/window_manager_connection.h" | 44 #include "ui/views/mus/window_manager_connection.h" |
42 #include "ui/views/views_delegate.h" | 45 #include "ui/views/views_delegate.h" |
43 | 46 |
44 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
45 #include "chromeos/audio/cras_audio_handler.h" | 48 #include "chromeos/audio/cras_audio_handler.h" |
46 #include "chromeos/dbus/dbus_thread_manager.h" | 49 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 init_params.blocking_pool = worker_pool_.get(); | 233 init_params.blocking_pool = worker_pool_.get(); |
231 init_params.in_mus = true; | 234 init_params.in_mus = true; |
232 init_params.keyboard_factory = | 235 init_params.keyboard_factory = |
233 base::Bind(&KeyboardUIMus::Create, connector); | 236 base::Bind(&KeyboardUIMus::Create, connector); |
234 ash::Shell::CreateInstance(init_params); | 237 ash::Shell::CreateInstance(init_params); |
235 ash::Shell::GetInstance()->CreateShelf(); | 238 ash::Shell::GetInstance()->CreateShelf(); |
236 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 239 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
237 ash::user::LOGGED_IN_USER); | 240 ash::user::LOGGED_IN_USER); |
238 | 241 |
239 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 242 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
240 SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); | |
241 } | 243 } |
242 | 244 |
243 void InitializeResourceBundle(::shell::Connector* connector) { | 245 void InitializeResourceBundle(::shell::Connector* connector) { |
244 if (ui::ResourceBundle::HasSharedInstance()) | 246 if (ui::ResourceBundle::HasSharedInstance()) |
245 return; | 247 return; |
246 | 248 |
247 std::set<std::string> resource_paths; | 249 std::set<std::string> resource_paths; |
248 resource_paths.insert(kResourceFileStrings); | 250 resource_paths.insert(kResourceFileStrings); |
249 resource_paths.insert(kResourceFile100); | 251 resource_paths.insert(kResourceFile100); |
250 resource_paths.insert(kResourceFile200); | 252 resource_paths.insert(kResourceFile200); |
251 | 253 |
252 catalog::ResourceLoader loader; | 254 catalog::ResourceLoader loader; |
253 filesystem::mojom::DirectoryPtr directory; | 255 filesystem::mojom::DirectoryPtr directory; |
254 connector->ConnectToInterface("mojo:catalog", &directory); | 256 connector->ConnectToInterface("mojo:catalog", &directory); |
255 CHECK(loader.OpenFiles(std::move(directory), resource_paths)); | 257 CHECK(loader.OpenFiles(std::move(directory), resource_paths)); |
256 | 258 |
257 // Load ash resources and en-US strings; not 'common' (Chrome) resources. | 259 // Load ash resources and en-US strings; not 'common' (Chrome) resources. |
258 // TODO(msw): Check ResourceBundle::IsScaleFactorSupported; load 300% etc. | 260 // TODO(msw): Check ResourceBundle::IsScaleFactorSupported; load 300% etc. |
259 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | 261 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
260 loader.TakeFile(kResourceFileStrings), | 262 loader.TakeFile(kResourceFileStrings), |
261 base::MemoryMappedFile::Region::kWholeFile); | 263 base::MemoryMappedFile::Region::kWholeFile); |
262 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
263 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100), | 265 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile100), |
264 ui::SCALE_FACTOR_100P); | 266 ui::SCALE_FACTOR_100P); |
265 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), | 267 rb.AddDataPackFromFile(loader.TakeFile(kResourceFile200), |
266 ui::SCALE_FACTOR_200P); | 268 ui::SCALE_FACTOR_200P); |
267 } | 269 } |
268 | 270 |
269 void SetupWallpaper(SkColor color) { | |
James Cook
2016/05/19 22:29:59
So nice to see this going away!
msw
2016/05/20 19:53:05
Acknowledged.
| |
270 SkBitmap bitmap; | |
271 bitmap.allocN32Pixels(16, 16); | |
272 bitmap.eraseColor(color); | |
273 #if !defined(NDEBUG) | |
274 // In debug builds we generate a simple pattern that allows visually | |
275 // notice if transparency is broken. | |
276 { | |
277 SkAutoLockPixels alp(bitmap); | |
278 *bitmap.getAddr32(0, 0) = SkColorSetRGB(0, 0, 0); | |
279 } | |
280 #endif | |
281 gfx::ImageSkia wallpaper = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
282 ash::Shell::GetInstance() | |
283 ->desktop_background_controller() | |
284 ->SetWallpaperImage(wallpaper, wallpaper::WALLPAPER_LAYOUT_TILE); | |
285 } | |
286 | |
287 void InitializeComponents() { | 271 void InitializeComponents() { |
288 message_center::MessageCenter::Initialize(); | 272 message_center::MessageCenter::Initialize(); |
289 | 273 |
290 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
291 ui::DeviceDataManager::CreateInstance(); | 275 ui::DeviceDataManager::CreateInstance(); |
292 chromeos::DBusThreadManager::Initialize(); | 276 chromeos::DBusThreadManager::Initialize(); |
293 bluez::BluezDBusManager::Initialize( | 277 bluez::BluezDBusManager::Initialize( |
294 chromeos::DBusThreadManager::Get()->GetSystemBus(), | 278 chromeos::DBusThreadManager::Get()->GetSystemBus(), |
295 chromeos::DBusThreadManager::Get()->IsUsingStub( | 279 chromeos::DBusThreadManager::Get()->IsUsingStub( |
296 chromeos::DBusClientBundle::BLUETOOTH)); | 280 chromeos::DBusClientBundle::BLUETOOTH)); |
(...skipping 16 matching lines...) Expand all Loading... | |
313 | 297 |
314 void SysUIApplication::Initialize(::shell::Connector* connector, | 298 void SysUIApplication::Initialize(::shell::Connector* connector, |
315 const ::shell::Identity& identity, | 299 const ::shell::Identity& identity, |
316 uint32_t id) { | 300 uint32_t id) { |
317 ash_init_.reset(new AshInit()); | 301 ash_init_.reset(new AshInit()); |
318 ash_init_->Initialize(connector, identity); | 302 ash_init_->Initialize(connector, identity); |
319 } | 303 } |
320 | 304 |
321 bool SysUIApplication::AcceptConnection(::shell::Connection* connection) { | 305 bool SysUIApplication::AcceptConnection(::shell::Connection* connection) { |
322 connection->AddInterface<mash::shelf::mojom::ShelfController>(this); | 306 connection->AddInterface<mash::shelf::mojom::ShelfController>(this); |
307 connection->AddInterface<mash::mojom::WallpaperController>(this); | |
323 return true; | 308 return true; |
324 } | 309 } |
325 | 310 |
326 void SysUIApplication::Create( | 311 void SysUIApplication::Create( |
327 ::shell::Connection* connection, | 312 ::shell::Connection* connection, |
328 mojo::InterfaceRequest<mash::shelf::mojom::ShelfController> request) { | 313 mash::shelf::mojom::ShelfControllerRequest request) { |
329 mash::shelf::mojom::ShelfController* shelf_controller = | 314 mash::shelf::mojom::ShelfController* shelf_controller = |
330 static_cast<ShelfDelegateMus*>(Shell::GetInstance()->GetShelfDelegate()); | 315 static_cast<ShelfDelegateMus*>(Shell::GetInstance()->GetShelfDelegate()); |
331 shelf_controller_bindings_.AddBinding(shelf_controller, std::move(request)); | 316 shelf_controller_bindings_.AddBinding(shelf_controller, std::move(request)); |
332 } | 317 } |
333 | 318 |
319 void SysUIApplication::Create(::shell::Connection* connection, | |
320 mash::mojom::WallpaperControllerRequest request) { | |
321 mash::mojom::WallpaperController* wallpaper_controller = | |
322 static_cast<UserWallpaperDelegateMus*>( | |
323 Shell::GetInstance()->user_wallpaper_delegate()); | |
324 wallpaper_controller_bindings_.AddBinding(wallpaper_controller, | |
325 std::move(request)); | |
326 } | |
327 | |
334 } // namespace sysui | 328 } // namespace sysui |
335 } // namespace ash | 329 } // namespace ash |
OLD | NEW |