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