Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 103283003: Media Galleries API Metadata: SafeMediaMetadataParser and IPCTunnelDataReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ownership issues Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_source.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
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() {
297 #if !defined(OS_ANDROID) 307 #if !defined(OS_ANDROID)
298 handlers_.push_back(new ProfileImportHandler()); 308 handlers_.push_back(new ProfileImportHandler());
299 #endif // OS_ANDROID 309 #endif // OS_ANDROID
300 310
301 #if defined(ENABLE_MDNS) 311 #if defined(ENABLE_MDNS)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 OnRobustJPEGDecodeImage) 345 OnRobustJPEGDecodeImage)
336 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) 346 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
337 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, 347 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
338 OnGetPrinterCapsAndDefaults) 348 OnGetPrinterCapsAndDefaults)
339 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) 349 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
340 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, 350 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
341 OnAnalyzeZipFileForDownloadProtection) 351 OnAnalyzeZipFileForDownloadProtection)
342 352
343 #if !defined(OS_ANDROID) && !defined(OS_IOS) 353 #if !defined(OS_ANDROID) && !defined(OS_IOS)
344 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) 354 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
355 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata,
356 OnParseMediaMetadata)
357 IPC_MESSAGE_HANDLER(
358 ChromeUtilityMsg_ParseMediaMetadata_RequestBlobBytes_Finished,
359 OnParseMediaMetadataRequestBlobBytesFinished)
345 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 360 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
346 361
347 #if defined(OS_CHROMEOS) 362 #if defined(OS_CHROMEOS)
348 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) 363 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile)
349 #endif // defined(OS_CHROMEOS) 364 #endif // defined(OS_CHROMEOS)
350 365
351 #if defined(OS_WIN) 366 #if defined(OS_WIN)
352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
353 OnParseITunesPrefXml) 368 OnParseITunesPrefXml)
354 #endif // defined(OS_WIN) 369 #endif // defined(OS_WIN)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void ChromeContentUtilityClient::OnCheckMediaFile( 767 void ChromeContentUtilityClient::OnCheckMediaFile(
753 int64 milliseconds_of_decoding, 768 int64 milliseconds_of_decoding,
754 const IPC::PlatformFileForTransit& media_file) { 769 const IPC::PlatformFileForTransit& media_file) {
755 media::MediaFileChecker 770 media::MediaFileChecker
756 checker(IPC::PlatformFileForTransitToPlatformFile(media_file)); 771 checker(IPC::PlatformFileForTransitToPlatformFile(media_file));
757 const bool check_success = checker.Start( 772 const bool check_success = checker.Start(
758 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); 773 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding));
759 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); 774 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success));
760 ReleaseProcessIfNeeded(); 775 ReleaseProcessIfNeeded();
761 } 776 }
777
778 void ChromeContentUtilityClient::OnParseMediaMetadata(
779 const std::string& mime_type,
780 int64 total_size) {
781 DCHECK(!media_metadata_parser_);
782 DCHECK(!ipc_tunnel_data_source_);
783
784 ipc_tunnel_data_source_.reset(new metadata::IPCTunnelDataSource(total_size));
785 media_metadata_parser_.reset(new metadata::MediaMetadataParser(
786 ipc_tunnel_data_source_.get(), mime_type));
787 media_metadata_parser_->Start(base::Bind(&SendMediaMetadataToHost));
788 }
789
790 void ChromeContentUtilityClient::OnParseMediaMetadataRequestBlobBytesFinished(
vandebo (ex-Chrome) 2014/01/07 18:34:59 I suggest making IPCDataSource a message Listener
tommycli 2014/01/07 20:23:31 Done. This is better, but I have one concern left:
791 int64 request_id,
792 const std::string& bytes) {
793 if (!ipc_tunnel_data_source_)
794 return;
795 ipc_tunnel_data_source_->ReceiveBytes(request_id, bytes);
796 }
762 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 797 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
763 798
764 #if defined(OS_WIN) 799 #if defined(OS_WIN)
765 void ChromeContentUtilityClient::OnParseITunesPrefXml( 800 void ChromeContentUtilityClient::OnParseITunesPrefXml(
766 const std::string& itunes_xml_data) { 801 const std::string& itunes_xml_data) {
767 base::FilePath library_path( 802 base::FilePath library_path(
768 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); 803 itunes::FindLibraryLocationInPrefXml(itunes_xml_data));
769 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); 804 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path));
770 ReleaseProcessIfNeeded(); 805 ReleaseProcessIfNeeded();
771 } 806 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 picasa::PicasaAlbumsIndexer indexer(album_uids); 862 picasa::PicasaAlbumsIndexer indexer(album_uids);
828 indexer.ParseFolderINI(folders_inis); 863 indexer.ParseFolderINI(folders_inis);
829 864
830 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 865 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
831 indexer.albums_images())); 866 indexer.albums_images()));
832 ReleaseProcessIfNeeded(); 867 ReleaseProcessIfNeeded();
833 } 868 }
834 #endif // defined(OS_WIN) || defined(OS_MACOSX) 869 #endif // defined(OS_WIN) || defined(OS_MACOSX)
835 870
836 } // namespace chrome 871 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698