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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/common/child_process_logging.h" | 19 #include "chrome/common/child_process_logging.h" |
| 20 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/chrome_version_info.h" | 23 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/crash_keys.h" | 24 #include "chrome/common/crash_keys.h" |
23 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
24 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
25 #include "chrome/grit/common_resources.h" | 27 #include "chrome/grit/common_resources.h" |
26 #include "components/dom_distiller/core/url_constants.h" | 28 #include "components/dom_distiller/core/url_constants.h" |
27 #include "content/public/common/content_constants.h" | 29 #include "content/public/common/content_constants.h" |
28 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 base::FilePath flash_path; | 399 base::FilePath flash_path; |
398 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | 400 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
399 return false; | 401 return false; |
400 | 402 |
401 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | 403 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
402 return true; | 404 return true; |
403 #else | 405 #else |
404 return false; | 406 return false; |
405 #endif // FLAPPER_AVAILABLE | 407 #endif // FLAPPER_AVAILABLE |
406 } | 408 } |
407 #endif // defined(ENABLE_PLUGINS) | 409 |
| 410 #if defined(OS_WIN) |
| 411 const char kPepperFlashDLLBaseName[] = |
| 412 #if defined(ARCH_CPU_X86) |
| 413 "pepflashplayer32_"; |
| 414 #elif defined(ARCH_CPU_X86_64) |
| 415 "pepflashplayer64_"; |
| 416 #else |
| 417 #error Unsupported Windows CPU architecture. |
| 418 #endif // defined(ARCH_CPU_X86) |
| 419 #endif // defined(OS_WIN) |
| 420 |
| 421 bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) { |
| 422 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 423 #if defined(FLAPPER_AVAILABLE) |
| 424 // If flapper is available, only try system plugin if |
| 425 // --disable-bundled-ppapi-flash is specified. |
| 426 if (!command_line->HasSwitch(switches::kDisableBundledPpapiFlash)) |
| 427 return false; |
| 428 #endif // defined(FLAPPER_AVAILABLE) |
| 429 |
| 430 // Do not try and find System Pepper Flash if there is a specific path on |
| 431 // the commmand-line. |
| 432 if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
| 433 return false; |
| 434 |
| 435 base::FilePath flash_path; |
| 436 if (!PathService::Get(chrome::DIR_PEPPER_FLASH_SYSTEM_PLUGIN, &flash_path)) |
| 437 return false; |
| 438 |
| 439 if (!base::PathExists(flash_path)) |
| 440 return false; |
| 441 |
| 442 base::FilePath manifest_path(flash_path.AppendASCII("manifest.json")); |
| 443 |
| 444 std::string manifest_data; |
| 445 if (!base::ReadFileToString(manifest_path, &manifest_data)) |
| 446 return false; |
| 447 scoped_ptr<base::Value> manifest_value( |
| 448 base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS)); |
| 449 if (!manifest_value.get()) |
| 450 return false; |
| 451 base::DictionaryValue* manifest = NULL; |
| 452 if (!manifest_value->GetAsDictionary(&manifest)) |
| 453 return false; |
| 454 |
| 455 std::string version; |
| 456 |
| 457 if (!manifest->GetString("version", &version)) |
| 458 return false; |
| 459 |
| 460 #if defined(OS_WIN) |
| 461 // PepperFlash DLLs on Windows look like basename_v_x_y_z.dll. |
| 462 std::string filename(kPepperFlashDLLBaseName); |
| 463 filename.append(version); |
| 464 base::ReplaceChars(filename, ".", "_", &filename); |
| 465 filename.append(".dll"); |
| 466 |
| 467 base::FilePath path(flash_path.Append(base::ASCIIToUTF16(filename))); |
| 468 #else |
| 469 // PepperFlash on OS X is called PepperFlashPlayer.plugin |
| 470 base::FilePath path(flash_path.Append(chrome::kPepperFlashPluginFilename)); |
| 471 #endif |
| 472 |
| 473 if (!base::PathExists(path)) |
| 474 return false; |
| 475 |
| 476 *plugin = CreatePepperFlashInfo(path, version); |
| 477 return true; |
| 478 } |
| 479 #endif // defined(ENABLE_PLUGINS) |
408 | 480 |
409 std::string GetProduct() { | 481 std::string GetProduct() { |
410 chrome::VersionInfo version_info; | 482 chrome::VersionInfo version_info; |
411 return version_info.ProductNameAndVersionForUserAgent(); | 483 return version_info.ProductNameAndVersionForUserAgent(); |
412 } | 484 } |
413 | 485 |
414 } // namespace | 486 } // namespace |
415 | 487 |
416 std::string GetUserAgent() { | 488 std::string GetUserAgent() { |
417 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 489 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 554 |
483 void ChromeContentClient::AddPepperPlugins( | 555 void ChromeContentClient::AddPepperPlugins( |
484 std::vector<content::PepperPluginInfo>* plugins) { | 556 std::vector<content::PepperPluginInfo>* plugins) { |
485 #if defined(ENABLE_PLUGINS) | 557 #if defined(ENABLE_PLUGINS) |
486 ComputeBuiltInPlugins(plugins); | 558 ComputeBuiltInPlugins(plugins); |
487 AddPepperFlashFromCommandLine(plugins); | 559 AddPepperFlashFromCommandLine(plugins); |
488 | 560 |
489 content::PepperPluginInfo plugin; | 561 content::PepperPluginInfo plugin; |
490 if (GetBundledPepperFlash(&plugin)) | 562 if (GetBundledPepperFlash(&plugin)) |
491 plugins->push_back(plugin); | 563 plugins->push_back(plugin); |
| 564 if (GetSystemPepperFlash(&plugin)) |
| 565 plugins->push_back(plugin); |
492 #endif | 566 #endif |
493 } | 567 } |
494 | 568 |
495 void ChromeContentClient::AddAdditionalSchemes( | 569 void ChromeContentClient::AddAdditionalSchemes( |
496 std::vector<std::string>* standard_schemes, | 570 std::vector<std::string>* standard_schemes, |
497 std::vector<std::string>* savable_schemes) { | 571 std::vector<std::string>* savable_schemes) { |
498 standard_schemes->push_back(extensions::kExtensionScheme); | 572 standard_schemes->push_back(extensions::kExtensionScheme); |
499 savable_schemes->push_back(extensions::kExtensionScheme); | 573 savable_schemes->push_back(extensions::kExtensionScheme); |
500 standard_schemes->push_back(chrome::kChromeNativeScheme); | 574 standard_schemes->push_back(chrome::kChromeNativeScheme); |
501 standard_schemes->push_back(extensions::kExtensionResourceScheme); | 575 standard_schemes->push_back(extensions::kExtensionResourceScheme); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 int sandbox_type, | 630 int sandbox_type, |
557 int* sandbox_profile_resource_id) const { | 631 int* sandbox_profile_resource_id) const { |
558 DCHECK(sandbox_profile_resource_id); | 632 DCHECK(sandbox_profile_resource_id); |
559 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { | 633 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { |
560 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 634 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
561 return true; | 635 return true; |
562 } | 636 } |
563 return false; | 637 return false; |
564 } | 638 } |
565 #endif | 639 #endif |
OLD | NEW |