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/common/service_registry.h" | |
25 #include "content/public/utility/utility_thread.h" | 24 #include "content/public/utility/utility_thread.h" |
26 #include "courgette/courgette.h" | 25 #include "courgette/courgette.h" |
27 #include "courgette/third_party/bsdiff/bsdiff.h" | 26 #include "courgette/third_party/bsdiff/bsdiff.h" |
28 #include "ipc/ipc_channel.h" | 27 #include "ipc/ipc_channel.h" |
| 28 #include "services/shell/public/cpp/interface_registry.h" |
29 #include "third_party/zlib/google/zip.h" | 29 #include "third_party/zlib/google/zip.h" |
30 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
31 | 31 |
32 #if !defined(OS_ANDROID) | 32 #if !defined(OS_ANDROID) |
33 #include "chrome/common/resource_usage_reporter.mojom.h" | 33 #include "chrome/common/resource_usage_reporter.mojom.h" |
34 #include "chrome/utility/profile_import_handler.h" | 34 #include "chrome/utility/profile_import_handler.h" |
35 #include "mojo/public/cpp/bindings/strong_binding.h" | 35 #include "mojo/public/cpp/bindings/strong_binding.h" |
36 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 36 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
37 #include "net/proxy/proxy_resolver_v8.h" | 37 #include "net/proxy/proxy_resolver_v8.h" |
38 #endif | 38 #endif |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // |handlers_| to become invalid. Therefore, it is necessary to break the | 183 // |handlers_| to become invalid. Therefore, it is necessary to break the |
184 // loop at this point instead of evaluating it as a loop condition (if the | 184 // loop at this point instead of evaluating it as a loop condition (if the |
185 // for loop was using iterators explicitly, as originally done). | 185 // for loop was using iterators explicitly, as originally done). |
186 if (handler->OnMessageReceived(message)) | 186 if (handler->OnMessageReceived(message)) |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 return false; | 190 return false; |
191 } | 191 } |
192 | 192 |
193 void ChromeContentUtilityClient::RegisterMojoServices( | 193 void ChromeContentUtilityClient::RegisterMojoInterfaces( |
194 content::ServiceRegistry* registry) { | 194 shell::InterfaceRegistry* registry) { |
195 // When the utility process is running with elevated privileges, we need to | 195 // When the utility process is running with elevated privileges, we need to |
196 // filter messages so that only a whitelist of IPCs can run. In Mojo, there's | 196 // filter messages so that only a whitelist of IPCs can run. In Mojo, there's |
197 // no way of filtering individual messages. Instead, we can avoid adding | 197 // no way of filtering individual messages. Instead, we can avoid adding |
198 // non-whitelisted Mojo services to the ServiceRegistry. | 198 // non-whitelisted Mojo services to the shell::InterfaceRegistry. |
199 // TODO(amistry): Use a whitelist once the whistlisted IPCs have been | 199 // TODO(amistry): Use a whitelist once the whistlisted IPCs have been |
200 // converted to Mojo. | 200 // converted to Mojo. |
201 if (filter_messages_) | 201 if (filter_messages_) |
202 return; | 202 return; |
203 | 203 |
204 #if !defined(OS_ANDROID) | 204 #if !defined(OS_ANDROID) |
205 registry->AddService<net::interfaces::ProxyResolverFactory>( | 205 registry->AddInterface<net::interfaces::ProxyResolverFactory>( |
206 base::Bind(CreateProxyResolverFactory)); | 206 base::Bind(CreateProxyResolverFactory)); |
207 registry->AddService(base::Bind(CreateResourceUsageReporter)); | 207 registry->AddInterface(base::Bind(CreateResourceUsageReporter)); |
208 #endif | 208 #endif |
209 registry->AddService(base::Bind(&CreateImageDecoder)); | 209 registry->AddInterface(base::Bind(&CreateImageDecoder)); |
210 registry->AddService(base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); | 210 registry->AddInterface( |
| 211 base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); |
211 } | 212 } |
212 | 213 |
213 void ChromeContentUtilityClient::AddHandler( | 214 void ChromeContentUtilityClient::AddHandler( |
214 std::unique_ptr<UtilityMessageHandler> handler) { | 215 std::unique_ptr<UtilityMessageHandler> handler) { |
215 handlers_.push_back(std::move(handler)); | 216 handlers_.push_back(std::move(handler)); |
216 } | 217 } |
217 | 218 |
218 // static | 219 // static |
219 void ChromeContentUtilityClient::PreSandboxStartup() { | 220 void ChromeContentUtilityClient::PreSandboxStartup() { |
220 #if defined(ENABLE_EXTENSIONS) | 221 #if defined(ENABLE_EXTENSIONS) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 safe_browsing::zip_analyzer::Results results; | 305 safe_browsing::zip_analyzer::Results results; |
305 safe_browsing::dmg::AnalyzeDMGFile( | 306 safe_browsing::dmg::AnalyzeDMGFile( |
306 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 307 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
307 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 308 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
308 results)); | 309 results)); |
309 ReleaseProcessIfNeeded(); | 310 ReleaseProcessIfNeeded(); |
310 } | 311 } |
311 #endif // defined(OS_MACOSX) | 312 #endif // defined(OS_MACOSX) |
312 | 313 |
313 #endif // defined(FULL_SAFE_BROWSING) | 314 #endif // defined(FULL_SAFE_BROWSING) |
OLD | NEW |