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

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: assign callback on io thread 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_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(
vandebo (ex-Chrome) 2014/01/08 17:48:06 This probably should be in an ifdef block.
tommycli 2014/01/08 18:59:37 Done.
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)
345 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 357 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
346 358
347 #if defined(OS_CHROMEOS) 359 #if defined(OS_CHROMEOS)
348 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) 360 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile)
349 #endif // defined(OS_CHROMEOS) 361 #endif // defined(OS_CHROMEOS)
350 362
351 #if defined(OS_WIN) 363 #if defined(OS_WIN)
352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 364 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
353 OnParseITunesPrefXml) 365 OnParseITunesPrefXml)
354 #endif // defined(OS_WIN) 366 #endif // defined(OS_WIN)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void ChromeContentUtilityClient::OnCheckMediaFile( 764 void ChromeContentUtilityClient::OnCheckMediaFile(
753 int64 milliseconds_of_decoding, 765 int64 milliseconds_of_decoding,
754 const IPC::PlatformFileForTransit& media_file) { 766 const IPC::PlatformFileForTransit& media_file) {
755 media::MediaFileChecker checker( 767 media::MediaFileChecker checker(
756 base::File(IPC::PlatformFileForTransitToPlatformFile(media_file))); 768 base::File(IPC::PlatformFileForTransitToPlatformFile(media_file)));
757 const bool check_success = checker.Start( 769 const bool check_success = checker.Start(
758 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); 770 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding));
759 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); 771 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success));
760 ReleaseProcessIfNeeded(); 772 ReleaseProcessIfNeeded();
761 } 773 }
774
775 void ChromeContentUtilityClient::OnParseMediaMetadata(
776 const std::string& mime_type,
777 int64 total_size) {
778 // Only one IPCDataSource may be created and added to the list of handlers.
779 CHECK(!media_metadata_parser_);
780 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
781 handlers_.push_back(source);
782
783 media_metadata_parser_.reset(new metadata::MediaMetadataParser(source,
784 mime_type));
785 media_metadata_parser_->Start(base::Bind(&SendMediaMetadataToHost));
786 }
762 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 787 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
763 788
764 #if defined(OS_WIN) 789 #if defined(OS_WIN)
765 void ChromeContentUtilityClient::OnParseITunesPrefXml( 790 void ChromeContentUtilityClient::OnParseITunesPrefXml(
766 const std::string& itunes_xml_data) { 791 const std::string& itunes_xml_data) {
767 base::FilePath library_path( 792 base::FilePath library_path(
768 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); 793 itunes::FindLibraryLocationInPrefXml(itunes_xml_data));
769 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); 794 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path));
770 ReleaseProcessIfNeeded(); 795 ReleaseProcessIfNeeded();
771 } 796 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 picasa::PicasaAlbumsIndexer indexer(album_uids); 852 picasa::PicasaAlbumsIndexer indexer(album_uids);
828 indexer.ParseFolderINI(folders_inis); 853 indexer.ParseFolderINI(folders_inis);
829 854
830 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 855 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
831 indexer.albums_images())); 856 indexer.albums_images()));
832 ReleaseProcessIfNeeded(); 857 ReleaseProcessIfNeeded();
833 } 858 }
834 #endif // defined(OS_WIN) || defined(OS_MACOSX) 859 #endif // defined(OS_WIN) || defined(OS_MACOSX)
835 860
836 } // namespace chrome 861 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698