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

Side by Side Diff: components/mus/mus_app.cc

Issue 1466483003: Makes window manager include ui pak file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « components/mus/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
7 #include "base/stl_util.h" 8 #include "base/stl_util.h"
8 #include "components/mus/common/args.h" 9 #include "components/mus/common/args.h"
9 #include "components/mus/gles2/gpu_impl.h" 10 #include "components/mus/gles2/gpu_impl.h"
10 #include "components/mus/surfaces/surfaces_scheduler.h" 11 #include "components/mus/surfaces/surfaces_scheduler.h"
11 #include "components/mus/ws/client_connection.h" 12 #include "components/mus/ws/client_connection.h"
12 #include "components/mus/ws/connection_manager.h" 13 #include "components/mus/ws/connection_manager.h"
13 #include "components/mus/ws/forwarding_window_manager.h" 14 #include "components/mus/ws/forwarding_window_manager.h"
14 #include "components/mus/ws/window_tree_host_connection.h" 15 #include "components/mus/ws/window_tree_host_connection.h"
15 #include "components/mus/ws/window_tree_host_impl.h" 16 #include "components/mus/ws/window_tree_host_impl.h"
16 #include "components/mus/ws/window_tree_impl.h" 17 #include "components/mus/ws/window_tree_impl.h"
18 #include "components/resource_provider/public/cpp/resource_loader.h"
17 #include "mojo/application/public/cpp/application_connection.h" 19 #include "mojo/application/public/cpp/application_connection.h"
18 #include "mojo/application/public/cpp/application_impl.h" 20 #include "mojo/application/public/cpp/application_impl.h"
19 #include "mojo/application/public/cpp/application_runner.h" 21 #include "mojo/application/public/cpp/application_runner.h"
20 #include "mojo/public/c/system/main.h" 22 #include "mojo/public/c/system/main.h"
21 #include "mojo/services/tracing/public/cpp/tracing_impl.h" 23 #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"
22 #include "ui/events/event_switches.h" 26 #include "ui/events/event_switches.h"
23 #include "ui/events/platform/platform_event_source.h" 27 #include "ui/events/platform/platform_event_source.h"
24 #include "ui/gl/gl_surface.h" 28 #include "ui/gl/gl_surface.h"
25 29
26 #if defined(USE_X11) 30 #if defined(USE_X11)
27 #include <X11/Xlib.h> 31 #include <X11/Xlib.h>
28 #include "base/command_line.h" 32 #include "base/command_line.h"
29 #include "ui/platform_window/x11/x11_window.h" 33 #include "ui/platform_window/x11/x11_window.h"
30 #endif 34 #endif
31 35
32 using mojo::ApplicationConnection; 36 using mojo::ApplicationConnection;
33 using mojo::ApplicationImpl; 37 using mojo::ApplicationImpl;
34 using mojo::InterfaceRequest; 38 using mojo::InterfaceRequest;
35 using mus::mojom::WindowTreeHostFactory; 39 using mus::mojom::WindowTreeHostFactory;
36 using mus::mojom::Gpu; 40 using mus::mojom::Gpu;
37 41
38 namespace mus { 42 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
39 63
40 MandolineUIServicesApp::MandolineUIServicesApp() 64 MandolineUIServicesApp::MandolineUIServicesApp()
41 : app_impl_(nullptr) {} 65 : app_impl_(nullptr) {}
42 66
43 MandolineUIServicesApp::~MandolineUIServicesApp() { 67 MandolineUIServicesApp::~MandolineUIServicesApp() {
44 if (gpu_state_) 68 if (gpu_state_)
45 gpu_state_->StopControlThread(); 69 gpu_state_->StopControlThread();
46 // Destroy |connection_manager_| first, since it depends on |event_source_|. 70 // Destroy |connection_manager_| first, since it depends on |event_source_|.
47 connection_manager_.reset(); 71 connection_manager_.reset();
48 } 72 }
49 73
50 void MandolineUIServicesApp::Initialize(ApplicationImpl* app) { 74 void MandolineUIServicesApp::Initialize(ApplicationImpl* app) {
75 InitResources(app);
76
51 app_impl_ = app; 77 app_impl_ = app;
52 surfaces_state_ = new SurfacesState; 78 surfaces_state_ = new SurfacesState;
53 79
54 #if defined(USE_X11) 80 #if defined(USE_X11)
55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 81 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
56 if (command_line->HasSwitch(kUseX11TestConfig)) { 82 if (command_line->HasSwitch(kUseX11TestConfig)) {
57 XInitThreads(); 83 XInitThreads();
58 ui::test::SetUseOverrideRedirectWindowByDefault(true); 84 ui::test::SetUseOverrideRedirectWindowByDefault(true);
59 } 85 }
60 #endif 86 #endif
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 host_client.Pass(), connection_manager_.get(), app_impl_, gpu_state_, 174 host_client.Pass(), connection_manager_.get(), app_impl_, gpu_state_,
149 surfaces_state_, window_manager.Pass()); 175 surfaces_state_, window_manager.Pass());
150 176
151 // WindowTreeHostConnection manages its own lifetime. 177 // WindowTreeHostConnection manages its own lifetime.
152 host_impl->Init(new ws::WindowTreeHostConnectionImpl( 178 host_impl->Init(new ws::WindowTreeHostConnectionImpl(
153 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), 179 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(),
154 connection_manager_.get())); 180 connection_manager_.get()));
155 } 181 }
156 182
157 } // namespace mus 183 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698