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" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { | 108 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { |
109 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 109 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
110 return image_decoder::ImageDecoderService::Create(); | 110 return image_decoder::ImageDecoderService::Create(); |
111 } | 111 } |
112 | 112 |
113 } // namespace | 113 } // namespace |
114 | 114 |
115 ChromeContentUtilityClient::ChromeContentUtilityClient() | 115 ChromeContentUtilityClient::ChromeContentUtilityClient() |
116 : filter_messages_(false) { | 116 : filter_messages_(false) { |
117 #if BUILDFLAG(ENABLE_EXTENSIONS) | 117 #if BUILDFLAG(ENABLE_EXTENSIONS) |
118 handlers_.push_back(new extensions::ExtensionsHandler(this)); | 118 handlers_.push_back(new extensions::ExtensionsHandler()); |
119 handlers_.push_back(new image_writer::ImageWriterHandler()); | 119 handlers_.push_back(new image_writer::ImageWriterHandler()); |
120 #endif | 120 #endif |
121 | 121 |
122 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 122 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
123 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 123 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
124 handlers_.push_back(new printing::PrintingHandler()); | 124 handlers_.push_back(new printing::PrintingHandler()); |
125 #endif | 125 #endif |
126 | 126 |
127 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
128 handlers_.push_back(new IPCShellHandler()); | 128 handlers_.push_back(new IPCShellHandler()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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::ExposeInterfacesToBrowser( | 193 void ChromeContentUtilityClient::ExposeInterfacesToBrowser( |
194 service_manager::InterfaceRegistry* registry) { | 194 service_manager::InterfaceRegistry* registry) { |
195 // When the utility process is running with elevated privileges, we need to | 195 const bool running_elevated = |
196 // filter messages so that only a whitelist of IPCs can run. In Mojo, there's | 196 base::CommandLine::ForCurrentProcess()->HasSwitch( |
197 // no way of filtering individual messages. Instead, we can avoid adding | 197 switches::kUtilityProcessRunningElevated); |
198 // non-whitelisted Mojo services to the service_manager::InterfaceRegistry. | 198 #if BUILDFLAG(ENABLE_EXTENSIONS) |
199 // TODO(amistry): Use a whitelist once the whistlisted IPCs have been | 199 extensions::ExtensionsHandler::ExposeInterfacesToBrowser(registry, this, |
200 // converted to Mojo. | 200 running_elevated); |
201 if (filter_messages_) | 201 #endif |
202 // If our process runs with elevated privileges, only add elevated | |
203 // Mojo services to the service_manager::InterfaceRegistry. | |
Sam McNally
2017/01/10 06:55:14
I don't think the service_manager:: prefix is need
Noel Gordon
2017/01/10 22:52:36
Done. "service_manager::InterfaceRegistry." -> "i
| |
204 if (running_elevated) | |
202 return; | 205 return; |
203 | 206 |
204 #if !defined(OS_ANDROID) | 207 #if !defined(OS_ANDROID) |
205 registry->AddInterface<net::interfaces::ProxyResolverFactory>( | 208 registry->AddInterface<net::interfaces::ProxyResolverFactory>( |
206 base::Bind(CreateProxyResolverFactory)); | 209 base::Bind(CreateProxyResolverFactory)); |
207 registry->AddInterface(base::Bind(CreateResourceUsageReporter)); | 210 registry->AddInterface(base::Bind(CreateResourceUsageReporter)); |
208 registry->AddInterface(base::Bind(&ProfileImportHandler::Create)); | 211 registry->AddInterface(base::Bind(&ProfileImportHandler::Create)); |
209 #endif | 212 #endif |
210 registry->AddInterface( | 213 registry->AddInterface( |
211 base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); | 214 base::Bind(&safe_json::SafeJsonParserMojoImpl::Create)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 safe_browsing::zip_analyzer::Results results; | 311 safe_browsing::zip_analyzer::Results results; |
309 safe_browsing::dmg::AnalyzeDMGFile( | 312 safe_browsing::dmg::AnalyzeDMGFile( |
310 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 313 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
311 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 314 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
312 results)); | 315 results)); |
313 ReleaseProcessIfNeeded(); | 316 ReleaseProcessIfNeeded(); |
314 } | 317 } |
315 #endif // defined(OS_MACOSX) | 318 #endif // defined(OS_MACOSX) |
316 | 319 |
317 #endif // defined(FULL_SAFE_BROWSING) | 320 #endif // defined(FULL_SAFE_BROWSING) |
OLD | NEW |