Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: ash/mus/window_manager_application.cc

Issue 2539363005: Converts ash to use aura-mus (Closed)
Patch Set: merge Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/window_manager_application.h" 5 #include "ash/mus/window_manager_application.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/mojo_interface_factory.h" 10 #include "ash/common/mojo_interface_factory.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/mus/native_widget_factory_mus.h"
13 #include "ash/mus/window_manager.h" 12 #include "ash/mus/window_manager.h"
14 #include "base/bind.h" 13 #include "base/bind.h"
15 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
16 #include "services/service_manager/public/cpp/connection.h" 15 #include "services/service_manager/public/cpp/connection.h"
17 #include "services/service_manager/public/cpp/connector.h" 16 #include "services/service_manager/public/cpp/connector.h"
18 #include "services/service_manager/public/cpp/service_context.h" 17 #include "services/service_manager/public/cpp/service_context.h"
19 #include "services/tracing/public/cpp/provider.h" 18 #include "services/tracing/public/cpp/provider.h"
20 #include "services/ui/common/accelerator_util.h" 19 #include "services/ui/common/accelerator_util.h"
21 #include "services/ui/public/cpp/gpu/gpu_service.h" 20 #include "services/ui/public/cpp/gpu/gpu_service.h"
22 #include "services/ui/public/cpp/window.h"
23 #include "services/ui/public/cpp/window_tree_client.h"
24 #include "ui/aura/env.h" 21 #include "ui/aura/env.h"
22 #include "ui/aura/mus/mus_context_factory.h"
23 #include "ui/aura/mus/window_tree_client.h"
25 #include "ui/events/event.h" 24 #include "ui/events/event.h"
26 #include "ui/message_center/message_center.h" 25 #include "ui/message_center/message_center.h"
27 #include "ui/views/mus/aura_init.h" 26 #include "ui/views/mus/aura_init.h"
28 #include "ui/views/mus/surface_context_factory.h" 27 #include "ui/views/mus/surface_context_factory.h"
29 28
30 #if defined(OS_CHROMEOS) 29 #if defined(OS_CHROMEOS)
31 #include "ash/common/system/chromeos/power/power_status.h" 30 #include "ash/common/system/chromeos/power/power_status.h"
32 #include "ash/mus/network_connect_delegate_mus.h" 31 #include "ash/mus/network_connect_delegate_mus.h"
33 #include "chromeos/audio/cras_audio_handler.h" 32 #include "chromeos/audio/cras_audio_handler.h"
34 #include "chromeos/dbus/dbus_thread_manager.h" 33 #include "chromeos/dbus/dbus_thread_manager.h"
(...skipping 24 matching lines...) Expand all
59 } 58 }
60 59
61 gpu_service_.reset(); 60 gpu_service_.reset();
62 #if defined(OS_CHROMEOS) 61 #if defined(OS_CHROMEOS)
63 statistics_provider_.reset(); 62 statistics_provider_.reset();
64 #endif 63 #endif
65 ShutdownComponents(); 64 ShutdownComponents();
66 } 65 }
67 66
68 void WindowManagerApplication::InitWindowManager( 67 void WindowManagerApplication::InitWindowManager(
69 std::unique_ptr<ui::WindowTreeClient> window_tree_client, 68 std::unique_ptr<aura::WindowTreeClient> window_tree_client,
70 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { 69 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) {
70 // Tests may have already set the WindowTreeClient.
71 if (!aura::Env::GetInstance()->HasWindowTreeClient())
72 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client.get());
71 InitializeComponents(); 73 InitializeComponents();
72 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
73 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data 75 // TODO(jamescook): Refactor StatisticsProvider so we can get just the data
74 // we need in ash. Right now StatisticsProviderImpl launches the crossystem 76 // we need in ash. Right now StatisticsProviderImpl launches the crossystem
75 // binary to get system data, which we don't want to do twice on startup. 77 // binary to get system data, which we don't want to do twice on startup.
76 statistics_provider_.reset( 78 statistics_provider_.reset(
77 new chromeos::system::ScopedFakeStatisticsProvider()); 79 new chromeos::system::ScopedFakeStatisticsProvider());
78 statistics_provider_->SetMachineStatistic("initial_locale", "en-US"); 80 statistics_provider_->SetMachineStatistic("initial_locale", "en-US");
79 statistics_provider_->SetMachineStatistic("keyboard_layout", ""); 81 statistics_provider_->SetMachineStatistic("keyboard_layout", "");
80 #endif 82 #endif
81 window_manager_->Init(std::move(window_tree_client), blocking_pool); 83 window_manager_->Init(std::move(window_tree_client), blocking_pool);
82 native_widget_factory_mus_ =
83 base::MakeUnique<NativeWidgetFactoryMus>(window_manager_.get());
84 } 84 }
85 85
86 void WindowManagerApplication::InitializeComponents() { 86 void WindowManagerApplication::InitializeComponents() {
87 message_center::MessageCenter::Initialize(); 87 message_center::MessageCenter::Initialize();
88 #if defined(OS_CHROMEOS) 88 #if defined(OS_CHROMEOS)
89 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but 89 // Must occur after mojo::ApplicationRunner has initialized AtExitManager, but
90 // before WindowManager::Init(). 90 // before WindowManager::Init().
91 chromeos::DBusThreadManager::Initialize( 91 chromeos::DBusThreadManager::Initialize(
92 chromeos::DBusThreadManager::PROCESS_ASH); 92 chromeos::DBusThreadManager::PROCESS_ASH);
93 93
(...skipping 19 matching lines...) Expand all
113 chromeos::NetworkHandler::Shutdown(); 113 chromeos::NetworkHandler::Shutdown();
114 bluez::BluezDBusManager::Shutdown(); 114 bluez::BluezDBusManager::Shutdown();
115 chromeos::DBusThreadManager::Shutdown(); 115 chromeos::DBusThreadManager::Shutdown();
116 #endif 116 #endif
117 message_center::MessageCenter::Shutdown(); 117 message_center::MessageCenter::Shutdown();
118 } 118 }
119 119
120 void WindowManagerApplication::OnStart() { 120 void WindowManagerApplication::OnStart() {
121 aura_init_ = base::MakeUnique<views::AuraInit>( 121 aura_init_ = base::MakeUnique<views::AuraInit>(
122 context()->connector(), context()->identity(), "ash_mus_resources.pak", 122 context()->connector(), context()->identity(), "ash_mus_resources.pak",
123 "ash_mus_resources_200.pak"); 123 "ash_mus_resources_200.pak", nullptr,
124 views::AuraInit::Mode::AURA_MUS_WINDOW_MANAGER);
124 gpu_service_ = ui::GpuService::Create(context()->connector()); 125 gpu_service_ = ui::GpuService::Create(context()->connector());
125 compositor_context_factory_.reset( 126 compositor_context_factory_ =
126 new views::SurfaceContextFactory(gpu_service_.get())); 127 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get());
127 aura::Env::GetInstance()->set_context_factory( 128 aura::Env::GetInstance()->set_context_factory(
128 compositor_context_factory_.get()); 129 compositor_context_factory_.get());
129 window_manager_.reset(new WindowManager(context()->connector())); 130 window_manager_.reset(new WindowManager(context()->connector()));
130 131
131 MaterialDesignController::Initialize(); 132 MaterialDesignController::Initialize();
132 133
133 tracing_.Initialize(context()->connector(), context()->identity().name()); 134 tracing_.Initialize(context()->connector(), context()->identity().name());
134 135
135 std::unique_ptr<ui::WindowTreeClient> window_tree_client = 136 std::unique_ptr<aura::WindowTreeClient> window_tree_client =
136 base::MakeUnique<ui::WindowTreeClient>(window_manager_.get(), 137 base::MakeUnique<aura::WindowTreeClient>(
137 window_manager_.get()); 138 context()->connector(), window_manager_.get(), window_manager_.get());
138 window_tree_client->ConnectAsWindowManager(context()->connector()); 139 window_tree_client->ConnectAsWindowManager();
139 140
140 const size_t kMaxNumberThreads = 3u; // Matches that of content. 141 const size_t kMaxNumberThreads = 3u; // Matches that of content.
141 const char kThreadNamePrefix[] = "MashBlocking"; 142 const char kThreadNamePrefix[] = "MashBlocking";
142 blocking_pool_ = new base::SequencedWorkerPool( 143 blocking_pool_ = new base::SequencedWorkerPool(
143 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); 144 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE);
144 InitWindowManager(std::move(window_tree_client), blocking_pool_); 145 InitWindowManager(std::move(window_tree_client), blocking_pool_);
145 } 146 }
146 147
147 bool WindowManagerApplication::OnConnect( 148 bool WindowManagerApplication::OnConnect(
148 const service_manager::ServiceInfo& remote_info, 149 const service_manager::ServiceInfo& remote_info,
149 service_manager::InterfaceRegistry* registry) { 150 service_manager::InterfaceRegistry* registry) {
150 // Register services used in both classic ash and mash. 151 // Register services used in both classic ash and mash.
151 mojo_interface_factory::RegisterInterfaces( 152 mojo_interface_factory::RegisterInterfaces(
152 registry, base::ThreadTaskRunnerHandle::Get()); 153 registry, base::ThreadTaskRunnerHandle::Get());
153 154
154 if (remote_info.identity.name() == "mash_session") { 155 if (remote_info.identity.name() == "mash_session") {
155 context()->connector()->ConnectToInterface(remote_info.identity, &session_); 156 context()->connector()->ConnectToInterface(remote_info.identity, &session_);
156 session_->AddScreenlockStateListener( 157 session_->AddScreenlockStateListener(
157 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); 158 screenlock_state_listener_binding_.CreateInterfacePtrAndBind());
158 } 159 }
159 return true; 160 return true;
160 } 161 }
161 162
162 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { 163 void WindowManagerApplication::ScreenlockStateChanged(bool locked) {
163 window_manager_->SetScreenLocked(locked); 164 window_manager_->SetScreenLocked(locked);
164 } 165 }
165 166
166 } // namespace mus 167 } // namespace mus
167 } // namespace ash 168 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698