| 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/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" | 
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" | 
| 15 #include "chrome/common/chrome_utility_messages.h" | 15 #include "chrome/common/chrome_utility_messages.h" | 
| 16 #include "chrome/common/safe_browsing/zip_analyzer.h" | 16 #include "chrome/common/safe_browsing/zip_analyzer.h" | 
| 17 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 17 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 
| 18 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 18 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 
| 19 #include "chrome/utility/image_decoder_impl.h" |  | 
| 20 #include "chrome/utility/utility_message_handler.h" | 19 #include "chrome/utility/utility_message_handler.h" | 
| 21 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" | 20 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" | 
| 22 #include "content/public/child/image_decoder_utils.h" | 21 #include "content/public/child/image_decoder_utils.h" | 
| 23 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" | 
|  | 23 #include "content/public/common/service_info.h" | 
| 24 #include "content/public/utility/utility_thread.h" | 24 #include "content/public/utility/utility_thread.h" | 
| 25 #include "courgette/courgette.h" | 25 #include "courgette/courgette.h" | 
| 26 #include "courgette/third_party/bsdiff/bsdiff.h" | 26 #include "courgette/third_party/bsdiff/bsdiff.h" | 
| 27 #include "ipc/ipc_channel.h" | 27 #include "ipc/ipc_channel.h" | 
| 28 #include "mojo/public/cpp/bindings/strong_binding.h" | 28 #include "mojo/public/cpp/bindings/strong_binding.h" | 
| 29 #include "printing/features/features.h" | 29 #include "printing/features/features.h" | 
|  | 30 #include "services/image_decoder/image_decoder_service.h" | 
|  | 31 #include "services/image_decoder/public/cpp/constants.h" | 
| 30 #include "services/service_manager/public/cpp/interface_registry.h" | 32 #include "services/service_manager/public/cpp/interface_registry.h" | 
| 31 #include "third_party/zlib/google/zip.h" | 33 #include "third_party/zlib/google/zip.h" | 
| 32 #include "ui/gfx/geometry/size.h" | 34 #include "ui/gfx/geometry/size.h" | 
| 33 | 35 | 
| 34 #if !defined(OS_ANDROID) | 36 #if !defined(OS_ANDROID) | 
| 35 #include "chrome/common/resource_usage_reporter.mojom.h" | 37 #include "chrome/common/resource_usage_reporter.mojom.h" | 
| 36 #include "chrome/utility/profile_import_handler.h" | 38 #include "chrome/utility/profile_import_handler.h" | 
| 37 #include "mojo/public/cpp/bindings/strong_binding.h" | 39 #include "mojo/public/cpp/bindings/strong_binding.h" | 
| 38 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 40 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 
| 39 #include "net/proxy/proxy_resolver_v8.h" | 41 #include "net/proxy/proxy_resolver_v8.h" | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 93   } | 95   } | 
| 94 }; | 96 }; | 
| 95 | 97 | 
| 96 void CreateResourceUsageReporter( | 98 void CreateResourceUsageReporter( | 
| 97     mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) { | 99     mojo::InterfaceRequest<mojom::ResourceUsageReporter> request) { | 
| 98   mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(), | 100   mojo::MakeStrongBinding(base::MakeUnique<ResourceUsageReporterImpl>(), | 
| 99                           std::move(request)); | 101                           std::move(request)); | 
| 100 } | 102 } | 
| 101 #endif  // !defined(OS_ANDROID) | 103 #endif  // !defined(OS_ANDROID) | 
| 102 | 104 | 
| 103 void CreateImageDecoder(mojo::InterfaceRequest<mojom::ImageDecoder> request) { | 105 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { | 
| 104   content::UtilityThread::Get()->EnsureBlinkInitialized(); | 106   content::UtilityThread::Get()->EnsureBlinkInitialized(); | 
| 105   mojo::MakeStrongBinding(base::MakeUnique<ImageDecoderImpl>(), | 107   return image_decoder::ImageDecoderService::Create(); | 
| 106                           std::move(request)); |  | 
| 107 } | 108 } | 
| 108 | 109 | 
| 109 }  // namespace | 110 }  // namespace | 
| 110 | 111 | 
| 111 ChromeContentUtilityClient::ChromeContentUtilityClient() | 112 ChromeContentUtilityClient::ChromeContentUtilityClient() | 
| 112     : filter_messages_(false) { | 113     : filter_messages_(false) { | 
| 113 #if !defined(OS_ANDROID) | 114 #if !defined(OS_ANDROID) | 
| 114   handlers_.push_back(new ProfileImportHandler()); | 115   handlers_.push_back(new ProfileImportHandler()); | 
| 115 #endif | 116 #endif | 
| 116 | 117 | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 199   // TODO(amistry): Use a whitelist once the whistlisted IPCs have been | 200   // TODO(amistry): Use a whitelist once the whistlisted IPCs have been | 
| 200   // converted to Mojo. | 201   // converted to Mojo. | 
| 201   if (filter_messages_) | 202   if (filter_messages_) | 
| 202     return; | 203     return; | 
| 203 | 204 | 
| 204 #if !defined(OS_ANDROID) | 205 #if !defined(OS_ANDROID) | 
| 205   registry->AddInterface<net::interfaces::ProxyResolverFactory>( | 206   registry->AddInterface<net::interfaces::ProxyResolverFactory>( | 
| 206       base::Bind(CreateProxyResolverFactory)); | 207       base::Bind(CreateProxyResolverFactory)); | 
| 207   registry->AddInterface(base::Bind(CreateResourceUsageReporter)); | 208   registry->AddInterface(base::Bind(CreateResourceUsageReporter)); | 
| 208 #endif | 209 #endif | 
| 209   registry->AddInterface(base::Bind(&CreateImageDecoder)); |  | 
| 210   registry->AddInterface( | 210   registry->AddInterface( | 
| 211       base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); | 211       base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); | 
| 212 #if defined(OS_WIN) | 212 #if defined(OS_WIN) | 
| 213   registry->AddInterface(base::Bind(&ShellHandlerImpl::Create)); | 213   registry->AddInterface(base::Bind(&ShellHandlerImpl::Create)); | 
| 214 #endif | 214 #endif | 
| 215 } | 215 } | 
| 216 | 216 | 
|  | 217 void ChromeContentUtilityClient::RegisterServices(StaticServiceMap* services) { | 
|  | 218   content::ServiceInfo image_decoder_info; | 
|  | 219   image_decoder_info.factory = base::Bind(&CreateImageDecoderService); | 
|  | 220   services->insert( | 
|  | 221       std::make_pair(image_decoder::kServiceName, image_decoder_info)); | 
|  | 222 } | 
|  | 223 | 
| 217 void ChromeContentUtilityClient::AddHandler( | 224 void ChromeContentUtilityClient::AddHandler( | 
| 218     std::unique_ptr<UtilityMessageHandler> handler) { | 225     std::unique_ptr<UtilityMessageHandler> handler) { | 
| 219   handlers_.push_back(std::move(handler)); | 226   handlers_.push_back(std::move(handler)); | 
| 220 } | 227 } | 
| 221 | 228 | 
| 222 // static | 229 // static | 
| 223 void ChromeContentUtilityClient::PreSandboxStartup() { | 230 void ChromeContentUtilityClient::PreSandboxStartup() { | 
| 224 #if defined(ENABLE_EXTENSIONS) | 231 #if defined(ENABLE_EXTENSIONS) | 
| 225   extensions::ExtensionsHandler::PreSandboxStartup(); | 232   extensions::ExtensionsHandler::PreSandboxStartup(); | 
| 226 #endif | 233 #endif | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 308   safe_browsing::zip_analyzer::Results results; | 315   safe_browsing::zip_analyzer::Results results; | 
| 309   safe_browsing::dmg::AnalyzeDMGFile( | 316   safe_browsing::dmg::AnalyzeDMGFile( | 
| 310       IPC::PlatformFileForTransitToFile(dmg_file), &results); | 317       IPC::PlatformFileForTransitToFile(dmg_file), &results); | 
| 311   Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 318   Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 
| 312       results)); | 319       results)); | 
| 313   ReleaseProcessIfNeeded(); | 320   ReleaseProcessIfNeeded(); | 
| 314 } | 321 } | 
| 315 #endif  // defined(OS_MACOSX) | 322 #endif  // defined(OS_MACOSX) | 
| 316 | 323 | 
| 317 #endif  // defined(FULL_SAFE_BROWSING) | 324 #endif  // defined(FULL_SAFE_BROWSING) | 
| OLD | NEW | 
|---|