| 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" | 19 #include "chrome/utility/image_decoder_impl.h" |
| 20 #include "chrome/utility/utility_message_handler.h" | 20 #include "chrome/utility/utility_message_handler.h" |
| 21 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" | 21 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" |
| 22 #include "content/public/child/image_decoder_utils.h" | 22 #include "content/public/child/image_decoder_utils.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.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 "extensions/features/features.h" |
| 27 #include "ipc/ipc_channel.h" | 28 #include "ipc/ipc_channel.h" |
| 28 #include "mojo/public/cpp/bindings/strong_binding.h" | 29 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 29 #include "printing/features/features.h" | 30 #include "printing/features/features.h" |
| 30 #include "services/service_manager/public/cpp/interface_registry.h" | 31 #include "services/service_manager/public/cpp/interface_registry.h" |
| 31 #include "third_party/zlib/google/zip.h" | 32 #include "third_party/zlib/google/zip.h" |
| 32 #include "ui/gfx/geometry/size.h" | 33 #include "ui/gfx/geometry/size.h" |
| 33 | 34 |
| 34 #if !defined(OS_ANDROID) | 35 #if !defined(OS_ANDROID) |
| 35 #include "chrome/common/resource_usage_reporter.mojom.h" | 36 #include "chrome/common/resource_usage_reporter.mojom.h" |
| 36 #include "chrome/utility/profile_import_handler.h" | 37 #include "chrome/utility/profile_import_handler.h" |
| 37 #include "mojo/public/cpp/bindings/strong_binding.h" | 38 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 38 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 39 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 39 #include "net/proxy/proxy_resolver_v8.h" | 40 #include "net/proxy/proxy_resolver_v8.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| 43 #include "chrome/utility/ipc_shell_handler_win.h" | 44 #include "chrome/utility/ipc_shell_handler_win.h" |
| 44 #include "chrome/utility/shell_handler_impl_win.h" | 45 #include "chrome/utility/shell_handler_impl_win.h" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 #if defined(ENABLE_EXTENSIONS) | 48 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 48 #include "chrome/utility/extensions/extensions_handler.h" | 49 #include "chrome/utility/extensions/extensions_handler.h" |
| 49 #include "chrome/utility/image_writer/image_writer_handler.h" | 50 #include "chrome/utility/image_writer/image_writer_handler.h" |
| 50 #endif | 51 #endif |
| 51 | 52 |
| 52 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 53 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 53 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 54 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| 54 #include "chrome/utility/printing_handler.h" | 55 #include "chrome/utility/printing_handler.h" |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if defined(OS_MACOSX) && defined(FULL_SAFE_BROWSING) | 58 #if defined(OS_MACOSX) && defined(FULL_SAFE_BROWSING) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 117 #if defined(ENABLE_EXTENSIONS) | 118 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 118 handlers_.push_back(new extensions::ExtensionsHandler(this)); | 119 handlers_.push_back(new extensions::ExtensionsHandler(this)); |
| 119 handlers_.push_back(new image_writer::ImageWriterHandler()); | 120 handlers_.push_back(new image_writer::ImageWriterHandler()); |
| 120 #endif | 121 #endif |
| 121 | 122 |
| 122 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 123 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 123 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 124 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| 124 handlers_.push_back(new printing::PrintingHandler()); | 125 handlers_.push_back(new printing::PrintingHandler()); |
| 125 #endif | 126 #endif |
| 126 | 127 |
| 127 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 128 handlers_.push_back(new IPCShellHandler()); | 129 handlers_.push_back(new IPCShellHandler()); |
| 129 #endif | 130 #endif |
| 130 } | 131 } |
| 131 | 132 |
| 132 ChromeContentUtilityClient::~ChromeContentUtilityClient() { | 133 ChromeContentUtilityClient::~ChromeContentUtilityClient() { |
| 133 } | 134 } |
| 134 | 135 |
| 135 void ChromeContentUtilityClient::UtilityThreadStarted() { | 136 void ChromeContentUtilityClient::UtilityThreadStarted() { |
| 136 #if defined(ENABLE_EXTENSIONS) | 137 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 137 extensions::UtilityHandler::UtilityThreadStarted(); | 138 extensions::UtilityHandler::UtilityThreadStarted(); |
| 138 #endif | 139 #endif |
| 139 | 140 |
| 140 if (kMessageWhitelistSize > 0) { | 141 if (kMessageWhitelistSize > 0) { |
| 141 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 142 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 142 if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) { | 143 if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) { |
| 143 message_id_whitelist_.insert(kMessageWhitelist, | 144 message_id_whitelist_.insert(kMessageWhitelist, |
| 144 kMessageWhitelist + kMessageWhitelistSize); | 145 kMessageWhitelist + kMessageWhitelistSize); |
| 145 filter_messages_ = true; | 146 filter_messages_ = true; |
| 146 } | 147 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 #endif | 215 #endif |
| 215 } | 216 } |
| 216 | 217 |
| 217 void ChromeContentUtilityClient::AddHandler( | 218 void ChromeContentUtilityClient::AddHandler( |
| 218 std::unique_ptr<UtilityMessageHandler> handler) { | 219 std::unique_ptr<UtilityMessageHandler> handler) { |
| 219 handlers_.push_back(std::move(handler)); | 220 handlers_.push_back(std::move(handler)); |
| 220 } | 221 } |
| 221 | 222 |
| 222 // static | 223 // static |
| 223 void ChromeContentUtilityClient::PreSandboxStartup() { | 224 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 224 #if defined(ENABLE_EXTENSIONS) | 225 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 225 extensions::ExtensionsHandler::PreSandboxStartup(); | 226 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 226 #endif | 227 #endif |
| 227 } | 228 } |
| 228 | 229 |
| 229 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
| 230 void ChromeContentUtilityClient::OnCreateZipFile( | 231 void ChromeContentUtilityClient::OnCreateZipFile( |
| 231 const base::FilePath& src_dir, | 232 const base::FilePath& src_dir, |
| 232 const std::vector<base::FilePath>& src_relative_paths, | 233 const std::vector<base::FilePath>& src_relative_paths, |
| 233 const base::FileDescriptor& dest_fd) { | 234 const base::FileDescriptor& dest_fd) { |
| 234 // dest_fd should be closed in the function. See ipc/ipc_message_util.h for | 235 // dest_fd should be closed in the function. See ipc/ipc_message_util.h for |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 safe_browsing::zip_analyzer::Results results; | 309 safe_browsing::zip_analyzer::Results results; |
| 309 safe_browsing::dmg::AnalyzeDMGFile( | 310 safe_browsing::dmg::AnalyzeDMGFile( |
| 310 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 311 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
| 311 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 312 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
| 312 results)); | 313 results)); |
| 313 ReleaseProcessIfNeeded(); | 314 ReleaseProcessIfNeeded(); |
| 314 } | 315 } |
| 315 #endif // defined(OS_MACOSX) | 316 #endif // defined(OS_MACOSX) |
| 316 | 317 |
| 317 #endif // defined(FULL_SAFE_BROWSING) | 318 #endif // defined(FULL_SAFE_BROWSING) |
| OLD | NEW |