| 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/memory/scoped_ptr.h" | |
| 15 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 16 #include "base/scoped_native_library.h" | 15 #include "base/scoped_native_library.h" |
| 17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 18 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_utility_messages.h" | 18 #include "chrome/common/chrome_utility_messages.h" |
| 20 #include "chrome/common/extensions/chrome_extensions_client.h" | 19 #include "chrome/common/extensions/chrome_extensions_client.h" |
| 21 #include "chrome/common/extensions/extension_l10n_util.h" | 20 #include "chrome/common/extensions/extension_l10n_util.h" |
| 22 #include "chrome/common/extensions/update_manifest.h" | 21 #include "chrome/common/extensions/update_manifest.h" |
| 23 #include "chrome/common/safe_browsing/zip_analyzer.h" | 22 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 24 #include "chrome/utility/cloud_print/bitmap_image.h" | 23 #include "chrome/utility/cloud_print/bitmap_image.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 54 #include "chrome/utility/media_galleries/iphoto_library_parser.h" | 53 #include "chrome/utility/media_galleries/iphoto_library_parser.h" |
| 55 #endif // defined(OS_MACOSX) | 54 #endif // defined(OS_MACOSX) |
| 56 | 55 |
| 57 #if defined(OS_WIN) || defined(OS_MACOSX) | 56 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 58 #include "chrome/utility/media_galleries/iapps_xml_utils.h" | 57 #include "chrome/utility/media_galleries/iapps_xml_utils.h" |
| 59 #include "chrome/utility/media_galleries/itunes_library_parser.h" | 58 #include "chrome/utility/media_galleries/itunes_library_parser.h" |
| 60 #include "chrome/utility/media_galleries/picasa_album_table_reader.h" | 59 #include "chrome/utility/media_galleries/picasa_album_table_reader.h" |
| 61 #include "chrome/utility/media_galleries/picasa_albums_indexer.h" | 60 #include "chrome/utility/media_galleries/picasa_albums_indexer.h" |
| 62 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 61 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 63 | 62 |
| 63 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 64 #include "chrome/utility/media_galleries/ipc_tunnel_data_reader.h" |
| 65 #include "chrome/utility/media_galleries/media_metadata_parser.h" |
| 66 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 67 |
| 64 #if defined(ENABLE_FULL_PRINTING) | 68 #if defined(ENABLE_FULL_PRINTING) |
| 65 #include "chrome/common/crash_keys.h" | 69 #include "chrome/common/crash_keys.h" |
| 66 #include "printing/backend/print_backend.h" | 70 #include "printing/backend/print_backend.h" |
| 67 #endif | 71 #endif |
| 68 | 72 |
| 69 #if defined(ENABLE_MDNS) | 73 #if defined(ENABLE_MDNS) |
| 70 #include "chrome/utility/local_discovery/service_discovery_message_handler.h" | 74 #include "chrome/utility/local_discovery/service_discovery_message_handler.h" |
| 71 #include "content/public/common/content_switches.h" | 75 #include "content/public/common/content_switches.h" |
| 72 #endif // ENABLE_MDNS | 76 #endif // ENABLE_MDNS |
| 73 | 77 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 RenderPDFPageToDCProc render_pdf_to_dc_func_; | 286 RenderPDFPageToDCProc render_pdf_to_dc_func_; |
| 283 | 287 |
| 284 DISALLOW_COPY_AND_ASSIGN(PdfFunctionsWin); | 288 DISALLOW_COPY_AND_ASSIGN(PdfFunctionsWin); |
| 285 }; | 289 }; |
| 286 | 290 |
| 287 typedef PdfFunctionsWin PdfFunctions; | 291 typedef PdfFunctionsWin PdfFunctions; |
| 288 #else // OS_WIN | 292 #else // OS_WIN |
| 289 typedef PdfFunctionsBase PdfFunctions; | 293 typedef PdfFunctionsBase PdfFunctions; |
| 290 #endif // OS_WIN | 294 #endif // OS_WIN |
| 291 | 295 |
| 296 void SendMediaMetadataToHost( |
| 297 scoped_ptr<extensions::api::media_galleries::MediaMetadata> metadata) { |
| 298 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( |
| 299 true, *(metadata->ToValue().get()))); |
| 300 } |
| 301 |
| 292 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER; | 302 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER; |
| 293 | 303 |
| 294 } // namespace | 304 } // namespace |
| 295 | 305 |
| 296 ChromeContentUtilityClient::ChromeContentUtilityClient() { | 306 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 307 #ifdef !defined(OS_ANDROID) && !defined(OS_IOS) |
| 308 : ipc_tunnel_data_reader_(NULL) |
| 309 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 310 { |
| 297 #if !defined(OS_ANDROID) | 311 #if !defined(OS_ANDROID) |
| 298 handlers_.push_back(new ProfileImportHandler()); | 312 handlers_.push_back(new ProfileImportHandler()); |
| 299 #endif // OS_ANDROID | 313 #endif // OS_ANDROID |
| 300 | 314 |
| 301 #if defined(ENABLE_MDNS) | 315 #if defined(ENABLE_MDNS) |
| 302 if (CommandLine::ForCurrentProcess()->HasSwitch( | 316 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 303 switches::kUtilityProcessEnableMDns)) { | 317 switches::kUtilityProcessEnableMDns)) { |
| 304 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); | 318 handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); |
| 305 } | 319 } |
| 306 #endif // ENABLE_MDNS | 320 #endif // ENABLE_MDNS |
| (...skipping 28 matching lines...) Expand all Loading... |
| 335 OnRobustJPEGDecodeImage) | 349 OnRobustJPEGDecodeImage) |
| 336 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) | 350 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) |
| 337 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, | 351 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
| 338 OnGetPrinterCapsAndDefaults) | 352 OnGetPrinterCapsAndDefaults) |
| 339 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) | 353 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) |
| 340 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 354 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
| 341 OnAnalyzeZipFileForDownloadProtection) | 355 OnAnalyzeZipFileForDownloadProtection) |
| 342 | 356 |
| 343 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 357 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 344 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) | 358 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) |
| 359 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, |
| 360 OnParseMediaMetadata) |
| 361 IPC_MESSAGE_HANDLER( |
| 362 ChromeUtilityMsg_ParseMediaMetadata_RequestBlobBytes_Finished, |
| 363 OnParseMediaMetadataRequestBlobBytesFinished) |
| 345 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 364 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 346 | 365 |
| 347 #if defined(OS_CHROMEOS) | 366 #if defined(OS_CHROMEOS) |
| 348 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) | 367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) |
| 349 #endif // defined(OS_CHROMEOS) | 368 #endif // defined(OS_CHROMEOS) |
| 350 | 369 |
| 351 #if defined(OS_WIN) | 370 #if defined(OS_WIN) |
| 352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, | 371 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, |
| 353 OnParseITunesPrefXml) | 372 OnParseITunesPrefXml) |
| 354 #endif // defined(OS_WIN) | 373 #endif // defined(OS_WIN) |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 void ChromeContentUtilityClient::OnCheckMediaFile( | 771 void ChromeContentUtilityClient::OnCheckMediaFile( |
| 753 int64 milliseconds_of_decoding, | 772 int64 milliseconds_of_decoding, |
| 754 const IPC::PlatformFileForTransit& media_file) { | 773 const IPC::PlatformFileForTransit& media_file) { |
| 755 media::MediaFileChecker | 774 media::MediaFileChecker |
| 756 checker(IPC::PlatformFileForTransitToPlatformFile(media_file)); | 775 checker(IPC::PlatformFileForTransitToPlatformFile(media_file)); |
| 757 const bool check_success = checker.Start( | 776 const bool check_success = checker.Start( |
| 758 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); | 777 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); |
| 759 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); | 778 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); |
| 760 ReleaseProcessIfNeeded(); | 779 ReleaseProcessIfNeeded(); |
| 761 } | 780 } |
| 781 |
| 782 void ChromeContentUtilityClient::OnParseMediaMetadata( |
| 783 const std::string& mime_type) { |
| 784 DCHECK(!media_metadata_parser_); |
| 785 DCHECK(!ipc_tunnel_data_reader_); |
| 786 |
| 787 ipc_tunnel_data_reader_ = new metadata::IPCTunnelDataReader; |
| 788 media_metadata_parser_.reset( |
| 789 new metadata::MediaMetadataParser(ipc_tunnel_data_reader_, mime_type)); |
| 790 media_metadata_parser_->Start(base::Bind(&SendMediaMetadataToHost)); |
| 791 } |
| 792 |
| 793 void ChromeContentUtilityClient::OnParseMediaMetadataRequestBlobBytesFinished( |
| 794 int64 request_id, |
| 795 const std::string& bytes) { |
| 796 if (!ipc_tunnel_data_reader_) |
| 797 return; |
| 798 ipc_tunnel_data_reader_->ReceiveBytes(request_id, bytes); |
| 799 } |
| 762 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 800 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 763 | 801 |
| 764 #if defined(OS_WIN) | 802 #if defined(OS_WIN) |
| 765 void ChromeContentUtilityClient::OnParseITunesPrefXml( | 803 void ChromeContentUtilityClient::OnParseITunesPrefXml( |
| 766 const std::string& itunes_xml_data) { | 804 const std::string& itunes_xml_data) { |
| 767 base::FilePath library_path( | 805 base::FilePath library_path( |
| 768 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); | 806 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); |
| 769 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); | 807 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); |
| 770 ReleaseProcessIfNeeded(); | 808 ReleaseProcessIfNeeded(); |
| 771 } | 809 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 picasa::PicasaAlbumsIndexer indexer(album_uids); | 865 picasa::PicasaAlbumsIndexer indexer(album_uids); |
| 828 indexer.ParseFolderINI(folders_inis); | 866 indexer.ParseFolderINI(folders_inis); |
| 829 | 867 |
| 830 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 868 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
| 831 indexer.albums_images())); | 869 indexer.albums_images())); |
| 832 ReleaseProcessIfNeeded(); | 870 ReleaseProcessIfNeeded(); |
| 833 } | 871 } |
| 834 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 872 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 835 | 873 |
| 836 } // namespace chrome | 874 } // namespace chrome |
| OLD | NEW |