Chromium Code Reviews| 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/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/common/chrome_utility_messages.h" | 16 #include "chrome/common/chrome_utility_messages.h" |
| 17 #include "chrome/common/file_patcher.mojom.h" | 17 #include "chrome/common/file_patcher.mojom.h" |
| 18 #include "chrome/common/safe_browsing/zip_analyzer.h" | 18 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 19 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 19 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 20 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | |
| 21 #include "chrome/utility/utility_message_handler.h" | 20 #include "chrome/utility/utility_message_handler.h" |
| 22 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" | 21 #include "components/safe_json/utility/safe_json_parser_mojo_impl.h" |
| 23 #include "content/public/child/image_decoder_utils.h" | 22 #include "content/public/child/image_decoder_utils.h" |
| 24 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/service_info.h" | 24 #include "content/public/common/service_info.h" |
| 26 #include "content/public/utility/utility_thread.h" | 25 #include "content/public/utility/utility_thread.h" |
| 27 #include "courgette/courgette.h" | 26 #include "courgette/courgette.h" |
| 28 #include "courgette/third_party/bsdiff/bsdiff.h" | 27 #include "courgette/third_party/bsdiff/bsdiff.h" |
| 29 #include "extensions/features/features.h" | 28 #include "extensions/features/features.h" |
| 30 #include "ipc/ipc_channel.h" | 29 #include "ipc/ipc_channel.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 44 #include "net/proxy/proxy_resolver_v8.h" | 43 #include "net/proxy/proxy_resolver_v8.h" |
| 45 #endif | 44 #endif |
| 46 | 45 |
| 47 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 48 #include "chrome/utility/ipc_shell_handler_win.h" | 47 #include "chrome/utility/ipc_shell_handler_win.h" |
| 49 #include "chrome/utility/shell_handler_impl_win.h" | 48 #include "chrome/utility/shell_handler_impl_win.h" |
| 50 #endif | 49 #endif |
| 51 | 50 |
| 52 #if BUILDFLAG(ENABLE_EXTENSIONS) | 51 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 53 #include "chrome/utility/extensions/extensions_handler.h" | 52 #include "chrome/utility/extensions/extensions_handler.h" |
| 54 #include "chrome/utility/image_writer/image_writer_handler.h" | |
| 55 #endif | 53 #endif |
| 56 | 54 |
| 57 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 55 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 58 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 56 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| 59 #include "chrome/utility/printing_handler.h" | 57 #include "chrome/utility/printing_handler.h" |
| 60 #endif | 58 #endif |
| 61 | 59 |
| 62 #if defined(OS_MACOSX) && defined(FULL_SAFE_BROWSING) | 60 #if defined(OS_MACOSX) && defined(FULL_SAFE_BROWSING) |
| 63 #include "chrome/utility/safe_browsing/mac/dmg_analyzer.h" | 61 #include "chrome/utility/safe_browsing/mac/dmg_analyzer.h" |
| 64 #endif | 62 #endif |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 139 } |
| 142 #endif // !defined(OS_ANDROID) | 140 #endif // !defined(OS_ANDROID) |
| 143 | 141 |
| 144 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { | 142 std::unique_ptr<service_manager::Service> CreateImageDecoderService() { |
| 145 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 143 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 146 return image_decoder::ImageDecoderService::Create(); | 144 return image_decoder::ImageDecoderService::Create(); |
| 147 } | 145 } |
| 148 | 146 |
| 149 } // namespace | 147 } // namespace |
| 150 | 148 |
| 151 ChromeContentUtilityClient::ChromeContentUtilityClient() | 149 ChromeContentUtilityClient::ChromeContentUtilityClient() { |
| 152 : filter_messages_(false) { | |
| 153 #if BUILDFLAG(ENABLE_EXTENSIONS) | 150 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 154 handlers_.push_back(new extensions::ExtensionsHandler()); | 151 handlers_.push_back(new extensions::ExtensionsHandler()); |
| 155 handlers_.push_back(new image_writer::ImageWriterHandler()); | |
| 156 #endif | 152 #endif |
| 157 | 153 |
| 158 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ | 154 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \ |
| 159 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) | 155 (BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) |
| 160 handlers_.push_back(new printing::PrintingHandler()); | 156 handlers_.push_back(new printing::PrintingHandler()); |
| 161 #endif | 157 #endif |
| 162 | 158 |
| 163 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
| 164 handlers_.push_back(new IPCShellHandler()); | 160 handlers_.push_back(new IPCShellHandler()); |
| 165 #endif | 161 #endif |
| 166 } | 162 } |
| 167 | 163 |
| 168 ChromeContentUtilityClient::~ChromeContentUtilityClient() { | 164 ChromeContentUtilityClient::~ChromeContentUtilityClient() { |
| 169 } | 165 } |
| 170 | 166 |
| 171 void ChromeContentUtilityClient::UtilityThreadStarted() { | 167 void ChromeContentUtilityClient::UtilityThreadStarted() { |
| 172 #if BUILDFLAG(ENABLE_EXTENSIONS) | 168 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 173 extensions::UtilityHandler::UtilityThreadStarted(); | 169 extensions::UtilityHandler::UtilityThreadStarted(); |
| 174 #endif | 170 #endif |
| 175 | |
| 176 if (kMessageWhitelistSize > 0) { | |
| 177 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 178 if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) { | |
| 179 message_id_whitelist_.insert(kMessageWhitelist, | |
| 180 kMessageWhitelist + kMessageWhitelistSize); | |
| 181 filter_messages_ = true; | |
| 182 } | |
| 183 } | |
| 184 } | 171 } |
| 185 | 172 |
| 186 bool ChromeContentUtilityClient::OnMessageReceived( | 173 bool ChromeContentUtilityClient::OnMessageReceived( |
| 187 const IPC::Message& message) { | 174 const IPC::Message& message) { |
|
Sam McNally
2017/02/02 21:54:17
Shouldn't this always just return false if running
Noel Gordon
2017/02/03 13:54:56
Yeap, just checking you ain't jet-lagged. Added u
| |
| 188 if (filter_messages_ && | |
| 189 !base::ContainsKey(message_id_whitelist_, message.type())) { | |
| 190 return false; | |
| 191 } | |
| 192 | |
| 193 bool handled = true; | 175 bool handled = true; |
| 194 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) | 176 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) |
| 195 #if defined(FULL_SAFE_BROWSING) | 177 #if defined(FULL_SAFE_BROWSING) |
| 196 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 178 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
| 197 OnAnalyzeZipFileForDownloadProtection) | 179 OnAnalyzeZipFileForDownloadProtection) |
| 198 #if defined(OS_MACOSX) | 180 #if defined(OS_MACOSX) |
| 199 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeDmgFileForDownloadProtection, | 181 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeDmgFileForDownloadProtection, |
| 200 OnAnalyzeDmgFileForDownloadProtection) | 182 OnAnalyzeDmgFileForDownloadProtection) |
| 201 #endif // defined(OS_MACOSX) | 183 #endif // defined(OS_MACOSX) |
| 202 #endif // defined(FULL_SAFE_BROWSING) | 184 #endif // defined(FULL_SAFE_BROWSING) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 safe_browsing::zip_analyzer::Results results; | 303 safe_browsing::zip_analyzer::Results results; |
| 322 safe_browsing::dmg::AnalyzeDMGFile( | 304 safe_browsing::dmg::AnalyzeDMGFile( |
| 323 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 305 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
| 324 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 306 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
| 325 results)); | 307 results)); |
| 326 ReleaseProcessIfNeeded(); | 308 ReleaseProcessIfNeeded(); |
| 327 } | 309 } |
| 328 #endif // defined(OS_MACOSX) | 310 #endif // defined(OS_MACOSX) |
| 329 | 311 |
| 330 #endif // defined(FULL_SAFE_BROWSING) | 312 #endif // defined(FULL_SAFE_BROWSING) |
| OLD | NEW |