OLD | NEW |
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 "ui/views/mus/aura_init.h" | 5 #include "ui/views/mus/aura_init.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #endif | 43 #endif |
44 void OnBeforeWidgetInit( | 44 void OnBeforeWidgetInit( |
45 Widget::InitParams* params, | 45 Widget::InitParams* params, |
46 internal::NativeWidgetDelegate* delegate) override {} | 46 internal::NativeWidgetDelegate* delegate) override {} |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(MusViewsDelegate); | 48 DISALLOW_COPY_AND_ASSIGN(MusViewsDelegate); |
49 }; | 49 }; |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 AuraInit::AuraInit(mojo::Connector* connector, const std::string& resource_file) | 53 AuraInit::AuraInit(shell::Connector* connector, |
| 54 const std::string& resource_file) |
54 : resource_file_(resource_file), | 55 : resource_file_(resource_file), |
55 env_(aura::Env::CreateInstance()), | 56 env_(aura::Env::CreateInstance()), |
56 views_delegate_(new MusViewsDelegate) { | 57 views_delegate_(new MusViewsDelegate) { |
57 InitializeResources(connector); | 58 InitializeResources(connector); |
58 | 59 |
59 ui::InitializeInputMethodForTesting(); | 60 ui::InitializeInputMethodForTesting(); |
60 } | 61 } |
61 | 62 |
62 AuraInit::~AuraInit() { | 63 AuraInit::~AuraInit() { |
63 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 64 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
64 if (font_loader_.get()) { | 65 if (font_loader_.get()) { |
65 SkFontConfigInterface::SetGlobal(nullptr); | 66 SkFontConfigInterface::SetGlobal(nullptr); |
66 // FontLoader is ref counted. We need to explicitly shutdown the background | 67 // FontLoader is ref counted. We need to explicitly shutdown the background |
67 // thread, otherwise the background thread may be shutdown after the app is | 68 // thread, otherwise the background thread may be shutdown after the app is |
68 // torn down, when we're in a bad state. | 69 // torn down, when we're in a bad state. |
69 font_loader_->Shutdown(); | 70 font_loader_->Shutdown(); |
70 } | 71 } |
71 #endif | 72 #endif |
72 } | 73 } |
73 | 74 |
74 void AuraInit::InitializeResources(mojo::Connector* connector) { | 75 void AuraInit::InitializeResources(shell::Connector* connector) { |
75 if (ui::ResourceBundle::HasSharedInstance()) | 76 if (ui::ResourceBundle::HasSharedInstance()) |
76 return; | 77 return; |
77 resource_provider::ResourceLoader resource_loader( | 78 resource_provider::ResourceLoader resource_loader( |
78 connector, GetResourcePaths(resource_file_)); | 79 connector, GetResourcePaths(resource_file_)); |
79 CHECK(resource_loader.BlockUntilLoaded()); | 80 CHECK(resource_loader.BlockUntilLoaded()); |
80 CHECK(resource_loader.loaded()); | 81 CHECK(resource_loader.loaded()); |
81 ui::RegisterPathProvider(); | 82 ui::RegisterPathProvider(); |
82 base::File pak_file = resource_loader.ReleaseFile(resource_file_); | 83 base::File pak_file = resource_loader.ReleaseFile(resource_file_); |
83 base::File pak_file_2 = pak_file.Duplicate(); | 84 base::File pak_file_2 = pak_file.Duplicate(); |
84 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | 85 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
85 std::move(pak_file), base::MemoryMappedFile::Region::kWholeFile); | 86 std::move(pak_file), base::MemoryMappedFile::Region::kWholeFile); |
86 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile( | 87 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFile( |
87 std::move(pak_file_2), ui::SCALE_FACTOR_100P); | 88 std::move(pak_file_2), ui::SCALE_FACTOR_100P); |
88 | 89 |
89 // Initialize the skia font code to go ask fontconfig underneath. | 90 // Initialize the skia font code to go ask fontconfig underneath. |
90 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 91 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
91 font_loader_ = skia::AdoptRef(new font_service::FontLoader(connector)); | 92 font_loader_ = skia::AdoptRef(new font_service::FontLoader(connector)); |
92 SkFontConfigInterface::SetGlobal(font_loader_.get()); | 93 SkFontConfigInterface::SetGlobal(font_loader_.get()); |
93 #endif | 94 #endif |
94 | 95 |
95 // There is a bunch of static state in gfx::Font, by running this now, | 96 // There is a bunch of static state in gfx::Font, by running this now, |
96 // before any other apps load, we ensure all the state is set up. | 97 // before any other apps load, we ensure all the state is set up. |
97 gfx::Font(); | 98 gfx::Font(); |
98 } | 99 } |
99 | 100 |
100 } // namespace views | 101 } // namespace views |
OLD | NEW |