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

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: 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 #if !defined(OS_ANDROID) && !defined(OS_IOS)
297 void SendMediaMetadataToHost(
298 scoped_ptr<extensions::api::media_galleries::MediaMetadata> metadata) {
299 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished(
300 true, *(metadata->ToValue().get())));
301 }
302 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
303
292 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER; 304 static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER;
293 305
294 } // namespace 306 } // namespace
295 307
296 ChromeContentUtilityClient::ChromeContentUtilityClient() { 308 ChromeContentUtilityClient::ChromeContentUtilityClient() {
297 #if !defined(OS_ANDROID) 309 #if !defined(OS_ANDROID)
298 handlers_.push_back(new ProfileImportHandler()); 310 handlers_.push_back(new ProfileImportHandler());
299 #endif // OS_ANDROID 311 #endif // OS_ANDROID
300 312
301 #if defined(ENABLE_MDNS) 313 #if defined(ENABLE_MDNS)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 OnRobustJPEGDecodeImage) 347 OnRobustJPEGDecodeImage)
336 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) 348 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
337 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, 349 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
338 OnGetPrinterCapsAndDefaults) 350 OnGetPrinterCapsAndDefaults)
339 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) 351 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
340 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, 352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
341 OnAnalyzeZipFileForDownloadProtection) 353 OnAnalyzeZipFileForDownloadProtection)
342 354
343 #if !defined(OS_ANDROID) && !defined(OS_IOS) 355 #if !defined(OS_ANDROID) && !defined(OS_IOS)
344 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) 356 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
357 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata,
358 OnParseMediaMetadata)
345 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 359 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
346 360
347 #if defined(OS_CHROMEOS) 361 #if defined(OS_CHROMEOS)
348 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) 362 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile)
349 #endif // defined(OS_CHROMEOS) 363 #endif // defined(OS_CHROMEOS)
350 364
351 #if defined(OS_WIN) 365 #if defined(OS_WIN)
352 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 366 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
353 OnParseITunesPrefXml) 367 OnParseITunesPrefXml)
354 #endif // defined(OS_WIN) 368 #endif // defined(OS_WIN)
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void ChromeContentUtilityClient::OnCheckMediaFile( 766 void ChromeContentUtilityClient::OnCheckMediaFile(
753 int64 milliseconds_of_decoding, 767 int64 milliseconds_of_decoding,
754 const IPC::PlatformFileForTransit& media_file) { 768 const IPC::PlatformFileForTransit& media_file) {
755 media::MediaFileChecker checker( 769 media::MediaFileChecker checker(
756 base::File(IPC::PlatformFileForTransitToPlatformFile(media_file))); 770 base::File(IPC::PlatformFileForTransitToPlatformFile(media_file)));
757 const bool check_success = checker.Start( 771 const bool check_success = checker.Start(
758 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); 772 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding));
759 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); 773 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success));
760 ReleaseProcessIfNeeded(); 774 ReleaseProcessIfNeeded();
761 } 775 }
776
777 void ChromeContentUtilityClient::OnParseMediaMetadata(
778 const std::string& mime_type,
779 int64 total_size) {
780 // Only one IPCDataSource may be created and added to the list of handlers.
781 CHECK(!media_metadata_parser_);
782 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
783 handlers_.push_back(source);
784
785 media_metadata_parser_.reset(new metadata::MediaMetadataParser(source,
786 mime_type));
787 media_metadata_parser_->Start(base::Bind(&SendMediaMetadataToHost));
788 }
762 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 789 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
763 790
764 #if defined(OS_WIN) 791 #if defined(OS_WIN)
765 void ChromeContentUtilityClient::OnParseITunesPrefXml( 792 void ChromeContentUtilityClient::OnParseITunesPrefXml(
766 const std::string& itunes_xml_data) { 793 const std::string& itunes_xml_data) {
767 base::FilePath library_path( 794 base::FilePath library_path(
768 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); 795 itunes::FindLibraryLocationInPrefXml(itunes_xml_data));
769 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); 796 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path));
770 ReleaseProcessIfNeeded(); 797 ReleaseProcessIfNeeded();
771 } 798 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 picasa::PicasaAlbumsIndexer indexer(album_uids); 854 picasa::PicasaAlbumsIndexer indexer(album_uids);
828 indexer.ParseFolderINI(folders_inis); 855 indexer.ParseFolderINI(folders_inis);
829 856
830 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 857 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
831 indexer.albums_images())); 858 indexer.albums_images()));
832 ReleaseProcessIfNeeded(); 859 ReleaseProcessIfNeeded();
833 } 860 }
834 #endif // defined(OS_WIN) || defined(OS_MACOSX) 861 #endif // defined(OS_WIN) || defined(OS_MACOSX)
835 862
836 } // namespace chrome 863 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/utility/chrome_content_utility_client.h ('k') | chrome/utility/media_galleries/ipc_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698