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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); | 224 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); |
225 widevine_cdm.permissions = kWidevineCdmPluginPermissions; | 225 widevine_cdm.permissions = kWidevineCdmPluginPermissions; |
226 plugins->push_back(widevine_cdm); | 226 plugins->push_back(widevine_cdm); |
227 } | 227 } |
228 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | 228 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) |
229 } | 229 } |
230 | 230 |
231 // Creates a PepperPluginInfo for the specified plugin. | 231 // Creates a PepperPluginInfo for the specified plugin. |
232 // |path| is the full path to the plugin. | 232 // |path| is the full path to the plugin. |
233 // |version| is a string representation of the plugin version. | 233 // |version| is a string representation of the plugin version. |
234 // |is_debug| is whether the plugin is the debug version or not. | |
235 // |is_external| is whether the plugin is supplied external to Chrome e.g. a | 234 // |is_external| is whether the plugin is supplied external to Chrome e.g. a |
236 // system installation of Adobe Flash. | 235 // system installation of Adobe Flash. |
237 // |is_bundled| distinguishes between component updated plugin and a bundled | |
238 // plugin. | |
239 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, | 236 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, |
240 const std::string& version, | 237 const std::string& version, |
241 bool is_debug, | 238 bool is_external) { |
242 bool is_external, | |
243 bool is_bundled) { | |
244 content::PepperPluginInfo plugin; | 239 content::PepperPluginInfo plugin; |
245 | 240 |
246 plugin.is_out_of_process = true; | 241 plugin.is_out_of_process = true; |
247 plugin.name = content::kFlashPluginName; | 242 plugin.name = content::kFlashPluginName; |
248 plugin.path = path; | 243 plugin.path = path; |
249 #if defined(OS_WIN) | |
250 plugin.is_on_local_drive = !base::IsOnNetworkDrive(path); | |
251 #endif | |
252 plugin.permissions = chrome::kPepperFlashPermissions; | 244 plugin.permissions = chrome::kPepperFlashPermissions; |
253 plugin.is_debug = is_debug; | |
254 plugin.is_external = is_external; | 245 plugin.is_external = is_external; |
255 plugin.is_bundled = is_bundled; | |
256 | 246 |
257 std::vector<std::string> flash_version_numbers = base::SplitString( | 247 std::vector<std::string> flash_version_numbers = base::SplitString( |
258 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 248 version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
259 if (flash_version_numbers.size() < 1) | 249 if (flash_version_numbers.size() < 1) |
260 flash_version_numbers.push_back("11"); | 250 flash_version_numbers.push_back("11"); |
261 if (flash_version_numbers.size() < 2) | 251 if (flash_version_numbers.size() < 2) |
262 flash_version_numbers.push_back("2"); | 252 flash_version_numbers.push_back("2"); |
263 if (flash_version_numbers.size() < 3) | 253 if (flash_version_numbers.size() < 3) |
264 flash_version_numbers.push_back("999"); | 254 flash_version_numbers.push_back("999"); |
265 if (flash_version_numbers.size() < 4) | 255 if (flash_version_numbers.size() < 4) |
(...skipping 20 matching lines...) Expand all Loading... |
286 switches::kPpapiFlashPath); | 276 switches::kPpapiFlashPath); |
287 if (flash_path.empty()) | 277 if (flash_path.empty()) |
288 return false; | 278 return false; |
289 | 279 |
290 // Also get the version from the command-line. Should be something like 11.2 | 280 // Also get the version from the command-line. Should be something like 11.2 |
291 // or 11.2.123.45. | 281 // or 11.2.123.45. |
292 std::string flash_version = | 282 std::string flash_version = |
293 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 283 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
294 switches::kPpapiFlashVersion); | 284 switches::kPpapiFlashVersion); |
295 | 285 |
296 *plugin = CreatePepperFlashInfo(base::FilePath(flash_path), | 286 *plugin = CreatePepperFlashInfo(base::FilePath(flash_path), flash_version, |
297 flash_version, false, true, false); | 287 true); |
298 return true; | 288 return true; |
299 } | 289 } |
300 | 290 |
301 // Check if flash player exists on disk, and if so, populate a PepperPluginInfo | 291 // Check if flash player exists on disk, and if so, populate a PepperPluginInfo |
302 // structure. Returns false if the flash player found is not compatible with the | 292 // structure. Returns false if the flash player found is not compatible with the |
303 // system (architecture, OS, versions, etc.). | 293 // system (architecture, OS, versions, etc.). |
304 bool TryCreatePepperFlashInfo(const base::FilePath& flash_filename, | 294 bool TryCreatePepperFlashInfo(const base::FilePath& flash_filename, |
305 content::PepperPluginInfo* plugin) { | 295 content::PepperPluginInfo* plugin) { |
306 if (!base::PathExists(flash_filename)) | 296 if (!base::PathExists(flash_filename)) |
307 return false; | 297 return false; |
308 | 298 |
309 base::FilePath manifest_path( | 299 base::FilePath manifest_path( |
310 flash_filename.DirName().Append(FILE_PATH_LITERAL("manifest.json"))); | 300 flash_filename.DirName().Append(FILE_PATH_LITERAL("manifest.json"))); |
311 | 301 |
312 std::string manifest_data; | 302 std::string manifest_data; |
313 if (!base::ReadFileToString(manifest_path, &manifest_data)) | 303 if (!base::ReadFileToString(manifest_path, &manifest_data)) |
314 return false; | 304 return false; |
315 | 305 |
316 std::unique_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From( | 306 std::unique_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From( |
317 base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS)); | 307 base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS)); |
318 if (!manifest) | 308 if (!manifest) |
319 return false; | 309 return false; |
320 | 310 |
321 base::Version version; | 311 base::Version version; |
322 if (!chrome::CheckPepperFlashManifest(*manifest, &version)) { | 312 if (!chrome::CheckPepperFlashManifest(*manifest, &version)) { |
323 LOG(ERROR) << "Browser not compatible with given flash manifest."; | 313 LOG(ERROR) << "Browser not compatible with given flash manifest."; |
324 return false; | 314 return false; |
325 } | 315 } |
326 | 316 |
327 *plugin = CreatePepperFlashInfo(flash_filename, version.GetString(), | 317 *plugin = CreatePepperFlashInfo(flash_filename, version.GetString(), true); |
328 chrome::IsSystemFlashScriptDebuggerPresent(), | |
329 /*is_external=*/true, | |
330 /*is_bundled=*/false); | |
331 return true; | 318 return true; |
332 } | 319 } |
333 | 320 |
334 #if defined(OS_CHROMEOS) | 321 #if defined(OS_CHROMEOS) |
335 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { | 322 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { |
336 base::FilePath flash_filename; | 323 base::FilePath flash_filename; |
337 if (!base::PathService::Get(chrome::FILE_CHROME_OS_COMPONENT_FLASH, | 324 if (!base::PathService::Get(chrome::FILE_CHROME_OS_COMPONENT_FLASH, |
338 &flash_filename)) { | 325 &flash_filename)) { |
339 return false; | 326 return false; |
340 } | 327 } |
(...skipping 22 matching lines...) Expand all Loading... |
363 &version)) { | 350 &version)) { |
364 // Test if the file can be mapped as executable. If the user's home | 351 // Test if the file can be mapped as executable. If the user's home |
365 // directory is mounted noexec, the component flash plugin will not load. | 352 // directory is mounted noexec, the component flash plugin will not load. |
366 // By testing for this, Chrome can fallback to the bundled flash plugin. | 353 // By testing for this, Chrome can fallback to the bundled flash plugin. |
367 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) { | 354 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) { |
368 LOG(WARNING) << "The component updated flash plugin could not be " | 355 LOG(WARNING) << "The component updated flash plugin could not be " |
369 "mapped as executable. Attempting to fallback to the " | 356 "mapped as executable. Attempting to fallback to the " |
370 "bundled or system plugin."; | 357 "bundled or system plugin."; |
371 return false; | 358 return false; |
372 } | 359 } |
373 *plugin = CreatePepperFlashInfo(flash_path, version, false, false, false); | 360 *plugin = CreatePepperFlashInfo(flash_path, version, false); |
374 return true; | 361 return true; |
375 } | 362 } |
376 LOG(ERROR) | 363 LOG(ERROR) |
377 << "Failed to locate and load the component updated flash plugin."; | 364 << "Failed to locate and load the component updated flash plugin."; |
378 } | 365 } |
379 #endif // defined(FLAPPER_AVAILABLE) | 366 #endif // defined(FLAPPER_AVAILABLE) |
380 return false; | 367 return false; |
381 } | 368 } |
382 #endif // defined(OS_CHROMEOS) | 369 #endif // defined(OS_CHROMEOS) |
383 | 370 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 #endif | 461 #endif |
475 } | 462 } |
476 | 463 |
477 #if defined(ENABLE_PLUGINS) | 464 #if defined(ENABLE_PLUGINS) |
478 // static | 465 // static |
479 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( | 466 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( |
480 const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins) { | 467 const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins) { |
481 if (plugins.empty()) | 468 if (plugins.empty()) |
482 return nullptr; | 469 return nullptr; |
483 | 470 |
484 using PluginSortKey = std::tuple<base::Version, bool, bool, bool, bool>; | 471 using PluginSortKey = std::tuple<base::Version, bool>; |
485 | 472 |
486 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; | 473 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; |
487 | 474 |
488 for (auto& plugin : plugins) { | 475 for (auto& plugin : plugins) { |
489 base::Version version(plugin->version); | 476 base::Version version(plugin->version); |
490 DCHECK(version.IsValid()); | 477 DCHECK(version.IsValid()); |
491 plugin_map[PluginSortKey(version, plugin->is_debug, plugin->is_bundled, | 478 plugin_map[PluginSortKey(version, plugin->is_external)] = plugin.get(); |
492 plugin->is_on_local_drive, !plugin->is_external)] = | |
493 plugin.get(); | |
494 } | 479 } |
495 | 480 |
496 return plugin_map.rbegin()->second; | 481 return plugin_map.rbegin()->second; |
497 } | 482 } |
498 #endif // defined(ENABLE_PLUGINS) | 483 #endif // defined(ENABLE_PLUGINS) |
499 | 484 |
500 void ChromeContentClient::AddPepperPlugins( | 485 void ChromeContentClient::AddPepperPlugins( |
501 std::vector<content::PepperPluginInfo>* plugins) { | 486 std::vector<content::PepperPluginInfo>* plugins) { |
502 #if defined(ENABLE_PLUGINS) | 487 #if defined(ENABLE_PLUGINS) |
503 ComputeBuiltInPlugins(plugins); | 488 ComputeBuiltInPlugins(plugins); |
(...skipping 28 matching lines...) Expand all Loading... |
532 plugins->push_back(*max_flash); | 517 plugins->push_back(*max_flash); |
533 } else { | 518 } else { |
534 #if defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) | 519 #if defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) |
535 // Add a fake Flash plugin even though it doesn't actually exist - if a | 520 // Add a fake Flash plugin even though it doesn't actually exist - if a |
536 // web page requests it, it will be component-updated on-demand. There is | 521 // web page requests it, it will be component-updated on-demand. There is |
537 // nothing that guarantees the component update will give us the | 522 // nothing that guarantees the component update will give us the |
538 // FLAPPER_VERSION_STRING version of Flash, but using this version seems | 523 // FLAPPER_VERSION_STRING version of Flash, but using this version seems |
539 // better than any other hardcoded alternative. | 524 // better than any other hardcoded alternative. |
540 plugins->push_back(CreatePepperFlashInfo( | 525 plugins->push_back(CreatePepperFlashInfo( |
541 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent), | 526 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent), |
542 FLAPPER_VERSION_STRING, false, false, true)); | 527 FLAPPER_VERSION_STRING, false)); |
543 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) | 528 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) |
544 } | 529 } |
545 #endif // defined(ENABLE_PLUGINS) | 530 #endif // defined(ENABLE_PLUGINS) |
546 } | 531 } |
547 | 532 |
548 void ChromeContentClient::AddContentDecryptionModules( | 533 void ChromeContentClient::AddContentDecryptionModules( |
549 std::vector<content::CdmInfo>* cdms) { | 534 std::vector<content::CdmInfo>* cdms) { |
550 // TODO(jrummell): Need to have a better flag to indicate systems Widevine | 535 // TODO(jrummell): Need to have a better flag to indicate systems Widevine |
551 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that | 536 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that |
552 // we can experiment between pepper and mojo. | 537 // we can experiment between pepper and mojo. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 if (!origin_trial_policy_) | 685 if (!origin_trial_policy_) |
701 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); | 686 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); |
702 return origin_trial_policy_.get(); | 687 return origin_trial_policy_.get(); |
703 } | 688 } |
704 | 689 |
705 #if defined(OS_ANDROID) | 690 #if defined(OS_ANDROID) |
706 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { | 691 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { |
707 return new ChromeMediaClientAndroid(); | 692 return new ChromeMediaClientAndroid(); |
708 } | 693 } |
709 #endif // OS_ANDROID | 694 #endif // OS_ANDROID |
OLD | NEW |