OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/mus/mus_app.h" | 5 #include "components/mus/mus_app.h" |
6 | 6 |
7 #include "base/path_service.h" | |
8 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
9 #include "components/mus/common/args.h" | 8 #include "components/mus/common/args.h" |
10 #include "components/mus/gles2/gpu_impl.h" | 9 #include "components/mus/gles2/gpu_impl.h" |
11 #include "components/mus/surfaces/surfaces_scheduler.h" | 10 #include "components/mus/surfaces/surfaces_scheduler.h" |
12 #include "components/mus/ws/client_connection.h" | 11 #include "components/mus/ws/client_connection.h" |
13 #include "components/mus/ws/connection_manager.h" | 12 #include "components/mus/ws/connection_manager.h" |
14 #include "components/mus/ws/forwarding_window_manager.h" | 13 #include "components/mus/ws/forwarding_window_manager.h" |
15 #include "components/mus/ws/window_tree_host_connection.h" | 14 #include "components/mus/ws/window_tree_host_connection.h" |
16 #include "components/mus/ws/window_tree_host_impl.h" | 15 #include "components/mus/ws/window_tree_host_impl.h" |
17 #include "components/mus/ws/window_tree_impl.h" | 16 #include "components/mus/ws/window_tree_impl.h" |
18 #include "components/resource_provider/public/cpp/resource_loader.h" | |
19 #include "mojo/application/public/cpp/application_connection.h" | 17 #include "mojo/application/public/cpp/application_connection.h" |
20 #include "mojo/application/public/cpp/application_impl.h" | 18 #include "mojo/application/public/cpp/application_impl.h" |
21 #include "mojo/application/public/cpp/application_runner.h" | 19 #include "mojo/application/public/cpp/application_runner.h" |
22 #include "mojo/public/c/system/main.h" | 20 #include "mojo/public/c/system/main.h" |
23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 21 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
24 #include "ui/base/resource/resource_bundle.h" | |
25 #include "ui/base/ui_base_paths.h" | |
26 #include "ui/events/event_switches.h" | 22 #include "ui/events/event_switches.h" |
27 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
28 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
29 | 25 |
30 #if defined(USE_X11) | 26 #if defined(USE_X11) |
31 #include <X11/Xlib.h> | 27 #include <X11/Xlib.h> |
32 #include "base/command_line.h" | 28 #include "base/command_line.h" |
33 #include "ui/platform_window/x11/x11_window.h" | 29 #include "ui/platform_window/x11/x11_window.h" |
34 #endif | 30 #endif |
35 | 31 |
36 using mojo::ApplicationConnection; | 32 using mojo::ApplicationConnection; |
37 using mojo::ApplicationImpl; | 33 using mojo::ApplicationImpl; |
38 using mojo::InterfaceRequest; | 34 using mojo::InterfaceRequest; |
39 using mus::mojom::WindowTreeHostFactory; | 35 using mus::mojom::WindowTreeHostFactory; |
40 using mus::mojom::Gpu; | 36 using mus::mojom::Gpu; |
41 | 37 |
42 namespace mus { | 38 namespace mus { |
43 namespace { | |
44 | |
45 void InitResources(ApplicationImpl* app) { | |
46 const std::string resource_file = "ui_resources_100_percent.pak"; | |
47 | |
48 std::set<std::string> paths; | |
49 paths.insert(resource_file); | |
50 resource_provider::ResourceLoader resource_loader(app, paths); | |
51 CHECK(resource_loader.BlockUntilLoaded()); | |
52 CHECK(resource_loader.loaded()); | |
53 ui::RegisterPathProvider(); | |
54 base::File pak_file = resource_loader.ReleaseFile(resource_file); | |
55 base::File pak_file_2 = pak_file.Duplicate(); | |
56 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | |
57 pak_file.Pass(), base::MemoryMappedFile::Region::kWholeFile); | |
58 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile( | |
59 pak_file_2.Pass(), ui::SCALE_FACTOR_100P); | |
60 } | |
61 | |
62 } // namespace | |
63 | 39 |
64 MandolineUIServicesApp::MandolineUIServicesApp() | 40 MandolineUIServicesApp::MandolineUIServicesApp() |
65 : app_impl_(nullptr) {} | 41 : app_impl_(nullptr) {} |
66 | 42 |
67 MandolineUIServicesApp::~MandolineUIServicesApp() { | 43 MandolineUIServicesApp::~MandolineUIServicesApp() { |
68 if (gpu_state_) | 44 if (gpu_state_) |
69 gpu_state_->StopControlThread(); | 45 gpu_state_->StopControlThread(); |
70 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 46 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
71 connection_manager_.reset(); | 47 connection_manager_.reset(); |
72 } | 48 } |
73 | 49 |
74 void MandolineUIServicesApp::Initialize(ApplicationImpl* app) { | 50 void MandolineUIServicesApp::Initialize(ApplicationImpl* app) { |
75 InitResources(app); | |
76 | |
77 app_impl_ = app; | 51 app_impl_ = app; |
78 surfaces_state_ = new SurfacesState; | 52 surfaces_state_ = new SurfacesState; |
79 | 53 |
80 #if defined(USE_X11) | 54 #if defined(USE_X11) |
81 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
82 if (command_line->HasSwitch(kUseX11TestConfig)) { | 56 if (command_line->HasSwitch(kUseX11TestConfig)) { |
83 XInitThreads(); | 57 XInitThreads(); |
84 ui::test::SetUseOverrideRedirectWindowByDefault(true); | 58 ui::test::SetUseOverrideRedirectWindowByDefault(true); |
85 } | 59 } |
86 #endif | 60 #endif |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 host_client.Pass(), connection_manager_.get(), app_impl_, gpu_state_, | 148 host_client.Pass(), connection_manager_.get(), app_impl_, gpu_state_, |
175 surfaces_state_, window_manager.Pass()); | 149 surfaces_state_, window_manager.Pass()); |
176 | 150 |
177 // WindowTreeHostConnection manages its own lifetime. | 151 // WindowTreeHostConnection manages its own lifetime. |
178 host_impl->Init(new ws::WindowTreeHostConnectionImpl( | 152 host_impl->Init(new ws::WindowTreeHostConnectionImpl( |
179 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), | 153 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), |
180 connection_manager_.get())); | 154 connection_manager_.get())); |
181 } | 155 } |
182 | 156 |
183 } // namespace mus | 157 } // namespace mus |
OLD | NEW |