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/files/file_path.h" | |
10 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | |
15 #include "base/time/time.h" | |
13 #include "chrome/common/chrome_utility_messages.h" | 16 #include "chrome/common/chrome_utility_messages.h" |
14 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 17 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
15 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/extension_l10n_util.h" | 19 #include "chrome/common/extensions/extension_l10n_util.h" |
17 #include "chrome/common/extensions/manifest.h" | 20 #include "chrome/common/extensions/manifest.h" |
18 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | 21 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
19 #include "chrome/common/extensions/update_manifest.h" | 22 #include "chrome/common/extensions/update_manifest.h" |
20 #include "chrome/common/safe_browsing/zip_analyzer.h" | 23 #include "chrome/common/safe_browsing/zip_analyzer.h" |
21 #include "chrome/utility/extensions/unpacker.h" | 24 #include "chrome/utility/extensions/unpacker.h" |
22 #include "chrome/utility/profile_import_handler.h" | 25 #include "chrome/utility/profile_import_handler.h" |
23 #include "chrome/utility/web_resource_unpacker.h" | 26 #include "chrome/utility/web_resource_unpacker.h" |
24 #include "content/public/child/image_decoder_utils.h" | 27 #include "content/public/child/image_decoder_utils.h" |
28 #include "content/public/common/content_paths.h" | |
25 #include "content/public/utility/utility_thread.h" | 29 #include "content/public/utility/utility_thread.h" |
30 #include "media/base/media.h" | |
31 #include "media/base/media_file_checker.h" | |
26 #include "printing/page_range.h" | 32 #include "printing/page_range.h" |
27 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
28 #include "third_party/zlib/google/zip.h" | 34 #include "third_party/zlib/google/zip.h" |
29 #include "ui/base/ui_base_switches.h" | 35 #include "ui/base/ui_base_switches.h" |
30 #include "ui/gfx/codec/jpeg_codec.h" | 36 #include "ui/gfx/codec/jpeg_codec.h" |
31 #include "ui/gfx/rect.h" | 37 #include "ui/gfx/rect.h" |
32 #include "ui/gfx/size.h" | 38 #include "ui/gfx/size.h" |
33 | 39 |
34 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
35 #include "base/file_util.h" | 41 #include "base/file_util.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 OnRenderPDFPagesToMetafile) | 123 OnRenderPDFPagesToMetafile) |
118 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, | 124 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, |
119 OnRobustJPEGDecodeImage) | 125 OnRobustJPEGDecodeImage) |
120 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) | 126 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) |
121 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, | 127 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
122 OnGetPrinterCapsAndDefaults) | 128 OnGetPrinterCapsAndDefaults) |
123 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) | 129 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) |
124 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 130 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
125 OnAnalyzeZipFileForDownloadProtection) | 131 OnAnalyzeZipFileForDownloadProtection) |
126 | 132 |
133 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
134 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) | |
135 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | |
136 | |
127 #if defined(OS_CHROMEOS) | 137 #if defined(OS_CHROMEOS) |
128 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) | 138 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) |
129 #endif // defined(OS_CHROMEOS) | 139 #endif // defined(OS_CHROMEOS) |
130 | 140 |
131 #if defined(OS_WIN) | 141 #if defined(OS_WIN) |
132 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, | 142 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, |
133 OnParseITunesPrefXml) | 143 OnParseITunesPrefXml) |
134 #endif // defined(OS_WIN) | 144 #endif // defined(OS_WIN) |
135 | 145 |
136 #if defined(OS_WIN) || defined(OS_MACOSX) | 146 #if defined(OS_WIN) || defined(OS_MACOSX) |
137 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, | 147 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, |
138 OnParseITunesLibraryXmlFile) | 148 OnParseITunesLibraryXmlFile) |
139 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, | 149 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, |
140 OnParsePicasaPMPDatabase) | 150 OnParsePicasaPMPDatabase) |
141 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 151 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
142 | 152 |
143 IPC_MESSAGE_UNHANDLED(handled = false) | 153 IPC_MESSAGE_UNHANDLED(handled = false) |
144 IPC_END_MESSAGE_MAP() | 154 IPC_END_MESSAGE_MAP() |
145 | 155 |
146 for (Handlers::iterator it = handlers_.begin(); | 156 for (Handlers::iterator it = handlers_.begin(); |
147 !handled && it != handlers_.end(); ++it) { | 157 !handled && it != handlers_.end(); ++it) { |
148 handled = (*it)->OnMessageReceived(message); | 158 handled = (*it)->OnMessageReceived(message); |
149 } | 159 } |
150 | 160 |
151 return handled; | 161 return handled; |
152 } | 162 } |
153 | 163 |
164 // static | |
154 void ChromeContentUtilityClient::PreSandboxStartup() { | 165 void ChromeContentUtilityClient::PreSandboxStartup() { |
155 #if defined(ENABLE_MDNS) | 166 #if defined(ENABLE_MDNS) |
156 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); | 167 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); |
157 #endif // ENABLE_MDNS | 168 #endif // ENABLE_MDNS |
169 | |
170 // Load media libraries for media file validation. | |
171 base::FilePath media_path; | |
172 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); | |
173 if (!media_path.empty()) | |
174 media::InitializeMediaLibrary(media_path); | |
158 } | 175 } |
159 | 176 |
160 void ChromeContentUtilityClient::OnUnpackExtension( | 177 void ChromeContentUtilityClient::OnUnpackExtension( |
161 const base::FilePath& extension_path, | 178 const base::FilePath& extension_path, |
162 const std::string& extension_id, | 179 const std::string& extension_id, |
163 int location, | 180 int location, |
164 int creation_flags) { | 181 int creation_flags) { |
165 CHECK_GT(location, extensions::Manifest::INVALID_LOCATION); | 182 CHECK_GT(location, extensions::Manifest::INVALID_LOCATION); |
166 CHECK_LT(location, extensions::Manifest::NUM_LOCATIONS); | 183 CHECK_LT(location, extensions::Manifest::NUM_LOCATIONS); |
167 extensions::PermissionsInfo::GetInstance()->InitializeWithDelegate( | 184 extensions::PermissionsInfo::GetInstance()->InitializeWithDelegate( |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( | 524 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( |
508 IPC::PlatformFileForTransit zip_file) { | 525 IPC::PlatformFileForTransit zip_file) { |
509 safe_browsing::zip_analyzer::Results results; | 526 safe_browsing::zip_analyzer::Results results; |
510 safe_browsing::zip_analyzer::AnalyzeZipFile( | 527 safe_browsing::zip_analyzer::AnalyzeZipFile( |
511 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); | 528 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); |
512 Send(new ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished( | 529 Send(new ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished( |
513 results)); | 530 results)); |
514 ReleaseProcessIfNeeded(); | 531 ReleaseProcessIfNeeded(); |
515 } | 532 } |
516 | 533 |
534 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
535 void ChromeContentUtilityClient::OnCheckMediaFile( | |
536 int64 milliseconds_of_decoding, | |
537 IPC::PlatformFileForTransit media_file) { | |
538 bool check_success = false; | |
DaleCurtis
2013/08/08 21:04:33
const and move this declaration below to checker.S
vandebo (ex-Chrome)
2013/08/08 23:04:18
Done.
| |
539 media::MediaFileChecker | |
540 checker(IPC::PlatformFileForTransitToPlatformFile(media_file)); | |
541 check_success = checker.Start( | |
542 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding)); | |
543 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success)); | |
544 ReleaseProcessIfNeeded(); | |
545 } | |
546 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | |
547 | |
517 #if defined(OS_WIN) | 548 #if defined(OS_WIN) |
518 void ChromeContentUtilityClient::OnParseITunesPrefXml( | 549 void ChromeContentUtilityClient::OnParseITunesPrefXml( |
519 const std::string& itunes_xml_data) { | 550 const std::string& itunes_xml_data) { |
520 base::FilePath library_path( | 551 base::FilePath library_path( |
521 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); | 552 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); |
522 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); | 553 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); |
523 ReleaseProcessIfNeeded(); | 554 ReleaseProcessIfNeeded(); |
524 } | 555 } |
525 #endif // defined(OS_WIN) | 556 #endif // defined(OS_WIN) |
526 | 557 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 indexer.ParseFolderINI(it->folder_path, it->ini_contents); | 604 indexer.ParseFolderINI(it->folder_path, it->ini_contents); |
574 } | 605 } |
575 | 606 |
576 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 607 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
577 indexer.albums_images())); | 608 indexer.albums_images())); |
578 ReleaseProcessIfNeeded(); | 609 ReleaseProcessIfNeeded(); |
579 } | 610 } |
580 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 611 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
581 | 612 |
582 } // namespace chrome | 613 } // namespace chrome |
OLD | NEW |