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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/scoped_native_library.h" | 15 #include "base/scoped_native_library.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_utility_messages.h" | 18 #include "chrome/common/chrome_utility_messages.h" |
19 #include "chrome/common/extensions/chrome_extensions_client.h" | 19 #include "chrome/common/extensions/chrome_extensions_client.h" |
20 #include "chrome/common/extensions/extension_l10n_util.h" | 20 #include "chrome/common/extensions/extension_l10n_util.h" |
21 #include "chrome/common/extensions/update_manifest.h" | 21 #include "chrome/common/extensions/update_manifest.h" |
22 #include "chrome/common/safe_browsing/zip_analyzer.h" | 22 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 23 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
23 #include "chrome/utility/cloud_print/bitmap_image.h" | 24 #include "chrome/utility/cloud_print/bitmap_image.h" |
24 #include "chrome/utility/cloud_print/pwg_encoder.h" | 25 #include "chrome/utility/cloud_print/pwg_encoder.h" |
25 #include "chrome/utility/extensions/unpacker.h" | 26 #include "chrome/utility/extensions/unpacker.h" |
26 #include "chrome/utility/profile_import_handler.h" | 27 #include "chrome/utility/profile_import_handler.h" |
27 #include "chrome/utility/web_resource_unpacker.h" | 28 #include "chrome/utility/web_resource_unpacker.h" |
28 #include "content/public/child/image_decoder_utils.h" | 29 #include "content/public/child/image_decoder_utils.h" |
29 #include "content/public/common/content_paths.h" | 30 #include "content/public/common/content_paths.h" |
| 31 #include "content/public/common/content_switches.h" |
30 #include "content/public/utility/utility_thread.h" | 32 #include "content/public/utility/utility_thread.h" |
31 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
32 #include "extensions/common/manifest.h" | 34 #include "extensions/common/manifest.h" |
33 #include "media/base/media.h" | 35 #include "media/base/media.h" |
34 #include "media/base/media_file_checker.h" | 36 #include "media/base/media_file_checker.h" |
35 #include "printing/page_range.h" | 37 #include "printing/page_range.h" |
36 #include "printing/pdf_render_settings.h" | 38 #include "printing/pdf_render_settings.h" |
37 #include "third_party/skia/include/core/SkBitmap.h" | 39 #include "third_party/skia/include/core/SkBitmap.h" |
38 #include "third_party/zlib/google/zip.h" | 40 #include "third_party/zlib/google/zip.h" |
39 #include "ui/base/ui_base_switches.h" | 41 #include "ui/base/ui_base_switches.h" |
(...skipping 25 matching lines...) Expand all Loading... |
65 #include "chrome/utility/media_galleries/media_metadata_parser.h" | 67 #include "chrome/utility/media_galleries/media_metadata_parser.h" |
66 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 68 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
67 | 69 |
68 #if defined(ENABLE_FULL_PRINTING) | 70 #if defined(ENABLE_FULL_PRINTING) |
69 #include "chrome/common/crash_keys.h" | 71 #include "chrome/common/crash_keys.h" |
70 #include "printing/backend/print_backend.h" | 72 #include "printing/backend/print_backend.h" |
71 #endif | 73 #endif |
72 | 74 |
73 #if defined(ENABLE_MDNS) | 75 #if defined(ENABLE_MDNS) |
74 #include "chrome/utility/local_discovery/service_discovery_message_handler.h" | 76 #include "chrome/utility/local_discovery/service_discovery_message_handler.h" |
75 #include "content/public/common/content_switches.h" | |
76 #endif // ENABLE_MDNS | 77 #endif // ENABLE_MDNS |
77 | 78 |
78 namespace chrome { | 79 namespace chrome { |
79 | 80 |
80 namespace { | 81 namespace { |
81 | 82 |
82 bool Send(IPC::Message* message) { | 83 bool Send(IPC::Message* message) { |
83 return content::UtilityThread::Get()->Send(message); | 84 return content::UtilityThread::Get()->Send(message); |
84 } | 85 } |
85 | 86 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 scoped_ptr<extensions::api::media_galleries::MediaMetadata> metadata) { | 299 scoped_ptr<extensions::api::media_galleries::MediaMetadata> metadata) { |
299 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( | 300 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( |
300 true, *(metadata->ToValue().get()))); | 301 true, *(metadata->ToValue().get()))); |
301 } | 302 } |
302 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 303 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
303 | 304 |
304 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER; | 305 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER; |
305 | 306 |
306 } // namespace | 307 } // namespace |
307 | 308 |
308 ChromeContentUtilityClient::ChromeContentUtilityClient() { | 309 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 310 : filter_messages_(false) { |
309 #if !defined(OS_ANDROID) | 311 #if !defined(OS_ANDROID) |
310 handlers_.push_back(new ProfileImportHandler()); | 312 handlers_.push_back(new ProfileImportHandler()); |
311 #endif // OS_ANDROID | 313 #endif // OS_ANDROID |
312 | 314 |
313 #if defined(ENABLE_MDNS) | 315 #if defined(ENABLE_MDNS) |
314 if (CommandLine::ForCurrentProcess()->HasSwitch( | 316 if (CommandLine::ForCurrentProcess()->HasSwitch( |
315 switches::kUtilityProcessEnableMDns)) { | 317 switches::kUtilityProcessEnableMDns)) { |
316 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); | 318 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); |
317 } | 319 } |
318 #endif // ENABLE_MDNS | 320 #endif // ENABLE_MDNS |
319 } | 321 } |
320 | 322 |
321 ChromeContentUtilityClient::~ChromeContentUtilityClient() { | 323 ChromeContentUtilityClient::~ChromeContentUtilityClient() { |
322 } | 324 } |
323 | 325 |
324 void ChromeContentUtilityClient::UtilityThreadStarted() { | 326 void ChromeContentUtilityClient::UtilityThreadStarted() { |
325 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 327 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
326 std::string lang = command_line->GetSwitchValueASCII(switches::kLang); | 328 std::string lang = command_line->GetSwitchValueASCII(switches::kLang); |
327 if (!lang.empty()) | 329 if (!lang.empty()) |
328 extension_l10n_util::SetProcessLocale(lang); | 330 extension_l10n_util::SetProcessLocale(lang); |
| 331 |
| 332 if (command_line->HasSwitch(switches::kUtilityProcessRunningElevated)) { |
| 333 message_id_whitelist_.insert(kMessageWhitelist, |
| 334 kMessageWhitelist + kMessageWhitelistSize); |
| 335 filter_messages_ = true; |
| 336 } |
329 } | 337 } |
330 | 338 |
331 bool ChromeContentUtilityClient::OnMessageReceived( | 339 bool ChromeContentUtilityClient::OnMessageReceived( |
332 const IPC::Message& message) { | 340 const IPC::Message& message) { |
| 341 if (filter_messages_ && |
| 342 (message_id_whitelist_.find(message.type()) == |
| 343 message_id_whitelist_.end())) { |
| 344 return false; |
| 345 } |
| 346 |
333 bool handled = true; | 347 bool handled = true; |
334 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) | 348 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) |
335 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) | 349 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) |
336 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource, | 350 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource, |
337 OnUnpackWebResource) | 351 OnUnpackWebResource) |
338 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest, | 352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest, |
339 OnParseUpdateManifest) | 353 OnParseUpdateManifest) |
340 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) | 354 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) |
341 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) | 355 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) |
342 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile, | 356 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile, |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 picasa::PicasaAlbumsIndexer indexer(album_uids); | 893 picasa::PicasaAlbumsIndexer indexer(album_uids); |
880 indexer.ParseFolderINI(folders_inis); | 894 indexer.ParseFolderINI(folders_inis); |
881 | 895 |
882 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 896 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
883 indexer.albums_images())); | 897 indexer.albums_images())); |
884 ReleaseProcessIfNeeded(); | 898 ReleaseProcessIfNeeded(); |
885 } | 899 } |
886 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 900 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
887 | 901 |
888 } // namespace chrome | 902 } // namespace chrome |
OLD | NEW |