| 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 "components/html_viewer/global_state.h" | 5 #include "components/html_viewer/global_state.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/icu_util.h" | 11 #include "base/i18n/icu_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "components/html_viewer/blink_platform_impl.h" | 13 #include "components/html_viewer/blink_platform_impl.h" |
| 14 #include "components/html_viewer/media_factory.h" | 14 #include "components/html_viewer/media_factory.h" |
| 15 #include "components/scheduler/renderer/renderer_scheduler.h" | 15 #include "components/scheduler/renderer/renderer_scheduler.h" |
| 16 #include "gin/v8_initializer.h" | 16 #include "gin/v8_initializer.h" |
| 17 #include "mojo/application/public/cpp/application_impl.h" | 17 #include "mojo/application/public/cpp/application_impl.h" |
| 18 #include "third_party/WebKit/public/web/WebKit.h" | 18 #include "third_party/WebKit/public/web/WebKit.h" |
| 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/base/ui_base_paths.h" | 21 #include "ui/base/ui_base_paths.h" |
| 22 #include "ui/mojo/init/ui_init.h" | 22 #include "ui/mojo/init/ui_init.h" |
| 23 #include "v8/include/v8.h" | 23 #include "v8/include/v8.h" |
| 24 | 24 |
| 25 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 26 #include "components/font_service/public/cpp/font_loader.h" |
| 27 #endif |
| 28 |
| 25 namespace html_viewer { | 29 namespace html_viewer { |
| 26 | 30 |
| 27 namespace { | 31 namespace { |
| 28 | 32 |
| 29 // Disables support for (unprefixed) Encrypted Media Extensions. | 33 // Disables support for (unprefixed) Encrypted Media Extensions. |
| 30 const char kDisableEncryptedMedia[] = "disable-encrypted-media"; | 34 const char kDisableEncryptedMedia[] = "disable-encrypted-media"; |
| 31 | 35 |
| 32 // Prevents creation of any output surface. | 36 // Prevents creation of any output surface. |
| 33 const char kIsHeadless[] = "is-headless"; | 37 const char kIsHeadless[] = "is-headless"; |
| 34 | 38 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 did_init_ = true; | 90 did_init_ = true; |
| 87 device_pixel_ratio_ = device_pixel_ratio; | 91 device_pixel_ratio_ = device_pixel_ratio; |
| 88 screen_size_in_pixels_ = screen_size_in_pixels; | 92 screen_size_in_pixels_ = screen_size_in_pixels; |
| 89 | 93 |
| 90 if (!resource_loader_.BlockUntilLoaded()) { | 94 if (!resource_loader_.BlockUntilLoaded()) { |
| 91 // Assume on error we're being shut down. | 95 // Assume on error we're being shut down. |
| 92 app_->Terminate(); | 96 app_->Terminate(); |
| 93 return; | 97 return; |
| 94 } | 98 } |
| 95 | 99 |
| 100 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 101 SkFontConfigInterface::SetGlobal(new font_service::FontLoader(app_)); |
| 102 #endif |
| 103 |
| 96 ui_init_.reset( | 104 ui_init_.reset( |
| 97 new ui::mojo::UIInit(screen_size_in_pixels, device_pixel_ratio)); | 105 new ui::mojo::UIInit(screen_size_in_pixels, device_pixel_ratio)); |
| 98 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); | 106 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
| 99 | 107 |
| 100 renderer_scheduler_ = scheduler::RendererScheduler::Create(); | 108 renderer_scheduler_ = scheduler::RendererScheduler::Create(); |
| 101 blink_platform_.reset(new BlinkPlatformImpl(app_, renderer_scheduler_.get())); | 109 blink_platform_.reset(new BlinkPlatformImpl(app_, renderer_scheduler_.get())); |
| 102 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 110 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 103 gin::V8Initializer::LoadV8SnapshotFromFD( | 111 gin::V8Initializer::LoadV8SnapshotFromFD( |
| 104 resource_loader_.ReleaseFile(kResourceSnapshotBlob).TakePlatformFile(), | 112 resource_loader_.ReleaseFile(kResourceSnapshotBlob).TakePlatformFile(), |
| 105 0u, 0u); | 113 0u, 0u); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 media_factory_.reset( | 148 media_factory_.reset( |
| 141 new MediaFactory(compositor_thread_.task_runner(), app_->shell())); | 149 new MediaFactory(compositor_thread_.task_runner(), app_->shell())); |
| 142 | 150 |
| 143 if (command_line->HasSwitch(kJavaScriptFlags)) { | 151 if (command_line->HasSwitch(kJavaScriptFlags)) { |
| 144 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags)); | 152 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags)); |
| 145 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 153 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 146 } | 154 } |
| 147 } | 155 } |
| 148 | 156 |
| 149 } // namespace html_viewer | 157 } // namespace html_viewer |
| OLD | NEW |