| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/discardable_memory_allocator.h" |
| 12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/common/chrome_utility_messages.h" | 17 #include "chrome/common/chrome_utility_messages.h" |
| 17 #include "chrome/common/file_patcher.mojom.h" | 18 #include "chrome/common/file_patcher.mojom.h" |
| 18 #include "chrome/common/safe_browsing/zip_analyzer.h" | 19 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 19 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 20 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 20 #include "chrome/utility/utility_message_handler.h" | 21 #include "chrome/utility/utility_message_handler.h" |
| 21 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" | 22 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" |
| 22 #include "content/public/child/image_decoder_utils.h" | 23 #include "content/public/child/image_decoder_utils.h" |
| 23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/service_info.h" | 25 #include "content/public/common/service_info.h" |
| 25 #include "content/public/utility/utility_thread.h" | 26 #include "content/public/utility/utility_thread.h" |
| 26 #include "courgette/courgette.h" | 27 #include "courgette/courgette.h" |
| 27 #include "courgette/third_party/bsdiff/bsdiff.h" | 28 #include "courgette/third_party/bsdiff/bsdiff.h" |
| 28 #include "extensions/features/features.h" | 29 #include "extensions/features/features.h" |
| 29 #include "ipc/ipc_channel.h" | 30 #include "ipc/ipc_channel.h" |
| 30 #include "mojo/public/cpp/bindings/strong_binding.h" | 31 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 31 #include "printing/features/features.h" | 32 #include "printing/features/features.h" |
| 32 #include "services/image_decoder/image_decoder_service.h" | 33 #include "services/image_decoder/image_decoder_service.h" |
| 33 #include "services/image_decoder/public/interfaces/constants.mojom.h" | 34 #include "services/image_decoder/public/interfaces/constants.mojom.h" |
| 35 #include "services/pdf_compositor/pdf_compositor_service.h" |
| 36 #include "services/pdf_compositor/public/interfaces/constants.mojom.h" |
| 34 #include "services/service_manager/public/cpp/interface_registry.h" | 37 #include "services/service_manager/public/cpp/interface_registry.h" |
| 35 #include "third_party/zlib/google/zip.h" | 38 #include "third_party/zlib/google/zip.h" |
| 36 #include "ui/gfx/geometry/size.h" | 39 #include "ui/gfx/geometry/size.h" |
| 37 | 40 |
| 38 #if !defined(OS_ANDROID) | 41 #if !defined(OS_ANDROID) |
| 39 #include "chrome/common/resource_usage_reporter.mojom.h" | 42 #include "chrome/common/resource_usage_reporter.mojom.h" |
| 40 #include "chrome/utility/profile_import_handler.h" | 43 #include "chrome/utility/profile_import_handler.h" |
| 41 #include "mojo/public/cpp/bindings/strong_binding.h" | 44 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 42 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 45 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 43 #include "net/proxy/proxy_resolver_v8.h" | 46 #include "net/proxy/proxy_resolver_v8.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(), | 140 mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(), |
| 138 std::move(request)); | 141 std::move(request)); |
| 139 } | 142 } |
| 140 #endif // !defined(OS_ANDROID) | 143 #endif // !defined(OS_ANDROID) |
| 141 | 144 |
| 142 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { | 145 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { |
| 143 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 146 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 144 return image_decoder::ImageDecoderService::Create(); | 147 return image_decoder::ImageDecoderService::Create(); |
| 145 } | 148 } |
| 146 | 149 |
| 150 std::unique_ptr<service_manager::Service> CreatePdfCompositorService() { |
| 151 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 152 return pdf_compositor::PdfCompositorService::Create(); |
| 153 } |
| 154 |
| 147 } // namespace | 155 } // namespace |
| 148 | 156 |
| 149 ChromeContentUtilityClient::ChromeContentUtilityClient() | 157 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 150 : utility_process_running_elevated_(false) { | 158 : utility_process_running_elevated_(false) { |
| 151 #if BUILDFLAG(ENABLE_EXTENSIONS) | 159 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 152 handlers_.push_back(new extensions::ExtensionsHandler()); | 160 handlers_.push_back(new extensions::ExtensionsHandler()); |
| 153 #endif | 161 #endif |
| 154 | 162 |
| 155 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 163 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 156 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 164 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 #if defined(OS_WIN) | 237 #if defined(OS_WIN) |
| 230 registry->AddInterface(base::Bind(&ShellHandlerImpl::Create)); | 238 registry->AddInterface(base::Bind(&ShellHandlerImpl::Create)); |
| 231 #endif | 239 #endif |
| 232 } | 240 } |
| 233 | 241 |
| 234 void ChromeContentUtilityClient::RegisterServices(StaticServiceMap* services) { | 242 void ChromeContentUtilityClient::RegisterServices(StaticServiceMap* services) { |
| 235 content::ServiceInfo image_decoder_info; | 243 content::ServiceInfo image_decoder_info; |
| 236 image_decoder_info.factory = base::Bind(&CreateImageDecoderService); | 244 image_decoder_info.factory = base::Bind(&CreateImageDecoderService); |
| 237 services->insert( | 245 services->insert( |
| 238 std::make_pair(image_decoder::mojom::kServiceName, image_decoder_info)); | 246 std::make_pair(image_decoder::mojom::kServiceName, image_decoder_info)); |
| 247 |
| 248 // Register pdf composer service. |
| 249 content::ServiceInfo pdf_compositor_info; |
| 250 pdf_compositor_info.factory = base::Bind(&CreatePdfCompositorService); |
| 251 services->insert( |
| 252 std::make_pair(pdf_compositor::mojom::kServiceName, pdf_compositor_info)); |
| 239 } | 253 } |
| 240 | 254 |
| 241 // static | 255 // static |
| 242 void ChromeContentUtilityClient::PreSandboxStartup() { | 256 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 243 #if BUILDFLAG(ENABLE_EXTENSIONS) | 257 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 244 extensions::ExtensionsHandler::PreSandboxStartup(); | 258 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 245 #endif | 259 #endif |
| 246 } | 260 } |
| 247 | 261 |
| 248 #if defined(OS_CHROMEOS) | 262 #if defined(OS_CHROMEOS) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 safe_browsing::zip_analyzer::Results results; | 310 safe_browsing::zip_analyzer::Results results; |
| 297 safe_browsing::dmg::AnalyzeDMGFile( | 311 safe_browsing::dmg::AnalyzeDMGFile( |
| 298 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 312 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
| 299 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 313 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
| 300 results)); | 314 results)); |
| 301 ReleaseProcessIfNeeded(); | 315 ReleaseProcessIfNeeded(); |
| 302 } | 316 } |
| 303 #endif // defined(OS_MACOSX) | 317 #endif // defined(OS_MACOSX) |
| 304 | 318 |
| 305 #endif // defined(FULL_SAFE_BROWSING) | 319 #endif // defined(FULL_SAFE_BROWSING) |
| OLD | NEW |